annotate MoinMoin/action/fullsearch.py @ 5829:a744f573fe30

advancedsearch: fix problem with non-ascii chars breaking up words for OR and NOT terms
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 04 Feb 2012 16:52:24 +0100
parents a488e4332862
children 570e430cd08c
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - fullsearch action
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
5 This is the backend of the search form. Search pages and print results.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2218
diff changeset
6
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1905
diff changeset
7 @copyright: 2001 by Juergen Hermann <jh@web.de>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
11 import re, time
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12 from MoinMoin.Page import Page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 from MoinMoin import wikiutil
5567
a488e4332862 do not use MoinMoin.support.* to import 3rd party code, give dist packages a chance
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5255
diff changeset
14 from parsedatetime.parsedatetime import Calendar
5255
ec00e39ec3f8 use correct check_surge_protect() call
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5252
diff changeset
15 from MoinMoin.web.utils import check_surge_protect
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16
1561
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
17 def checkTitleSearch(request):
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
18 """ Return 1 for title search, 0 for full text search, -1 for idiot spammer
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
19 who tries to press all buttons at once.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2218
diff changeset
20
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21 When used in FullSearch macro, we have 'titlesearch' parameter with
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 '0' or '1'. In standard search, we have either 'titlesearch' or
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 'fullsearch' with localized string. If both missing, default to
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
24 True (might happen with Safari) if this isn't an advanced search.
1561
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
25 """
4253
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
26 form = request.values
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
27 if 'titlesearch' in form and 'fullsearch' in form:
1561
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
28 ret = -1 # spammer / bot
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
29 else:
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
30 try:
4201
40acd13fb3d6 Changed form access to MultiDict forms
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
31 ret = int(form['titlesearch'])
1561
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
32 except ValueError:
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
33 ret = 1
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
34 except KeyError:
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
35 ret = ('fullsearch' not in form and not isAdvancedSearch(request)) and 1 or 0
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
36 return ret
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
37
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1280
diff changeset
38 def isAdvancedSearch(request):
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
39 """ Return True if advanced search is requested """
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1280
diff changeset
40 try:
4253
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
41 return int(request.values['advancedsearch'])
1373
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
42 except KeyError:
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1280
diff changeset
43 return False
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
45
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
46 def searchHints(f, hints):
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
47 """ Return a paragraph showing hints for a search
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
48
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
49 @param f: the formatter to use
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
50 @param hints: list of hints (as strings) to show
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
51 """
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
52 return ''.join([
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
53 f.paragraph(1, attr={'class': 'searchhint'}),
1518
986be5c76da5 Fixed BR error in fullsearch.py, reworded title search hint.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1509
diff changeset
54 # this is illegal formatter usage anyway, so we can directly use a literal
986be5c76da5 Fixed BR error in fullsearch.py, reworded title search hint.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1509
diff changeset
55 "<br>".join(hints),
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
56 f.paragraph(0),
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
57 ])
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
58
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
59
2943
fa428b3c7d64 introduced hitsInfo keyword for results.pageList (default is 0). Action fullsearch does set it to 1. So the macro FullSearch does not show the hits info.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2936
diff changeset
60 def execute(pagename, request, fieldname='value', titlesearch=0, statistic=0):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
61 _ = request.getText
1561
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
62 titlesearch = checkTitleSearch(request)
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
63 if titlesearch < 0:
5255
ec00e39ec3f8 use correct check_surge_protect() call
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5252
diff changeset
64 check_surge_protect(request, kick=True) # get rid of spammer
1561
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
65 return
d12202b5791c check if multiple submit buttons are pressed at once (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1518
diff changeset
66
1369
0a291dcb0555 more work on the advanced ui.. css, mimetype and language stuff
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1280
diff changeset
67 advancedsearch = isAdvancedSearch(request)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
68
4253
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
69 form = request.values
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
70
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
71 # context is relevant only for full search
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 921
diff changeset
72 if titlesearch:
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 921
diff changeset
73 context = 0
1373
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
74 elif advancedsearch:
1832
b180f047d918 comments only: cleaned up TODO, XXX, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
75 context = 180 # XXX: hardcoded context count for advancedsearch
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
76 else:
4253
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
77 context = int(form.get('context', 0))
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 921
diff changeset
78
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79 # Get other form parameters
4253
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
80 needle = form.get(fieldname, '')
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
81 case = int(form.get('case', 0))
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
82 regex = int(form.get('regex', 0)) # no interface currently
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
83 hitsFrom = int(form.get('from', 0))
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
84 mtime = None
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
85 msg = ''
1441
05482b439f89 optional history indexing and search is working
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1434
diff changeset
86 historysearch = 0
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
88 # if advanced search is enabled we construct our own search query
1373
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
89 if advancedsearch:
4253
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
90 and_terms = form.get('and_terms', '').strip()
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
91 or_terms = form.get('or_terms', '').strip()
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
92 not_terms = form.get('not_terms', '').strip()
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
93 #xor_terms = form.get('xor_terms', '').strip()
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
94 categories = form.getlist('categories') or ['']
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
95 timeframe = form.get('time', '').strip()
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
96 language = form.getlist('language') or ['']
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
97 mimetype = form.getlist('mimetype') or [0]
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
98 excludeunderlay = form.get('excludeunderlay', 0)
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
99 nosystemitems = form.get('nosystemitems', 0)
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
100 historysearch = form.get('historysearch', 0)
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
101
4253
f8615334d5ab Fixed: search used only POST-formdata
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4201
diff changeset
102 mtime = form.get('mtime', '')
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
103 if mtime:
1507
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
104 mtime_parsed = None
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
105
1507
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
106 # get mtime from known date/time formats
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
107 for fmt in (request.user.datetime_fmt,
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
108 request.cfg.datetime_fmt, request.user.date_fmt,
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
109 request.cfg.date_fmt):
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
110 try:
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
111 mtime_parsed = time.strptime(mtime, fmt)
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
112 except ValueError:
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
113 continue
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
114 else:
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
115 break
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
116
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
117 if mtime_parsed:
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
118 mtime = time.mktime(mtime_parsed)
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
119 else:
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
120 # didn't work, let's try parsedatetime
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
121 cal = Calendar()
5186
edd5719d5f07 parsedatetime 0.8.7 uses the 2nd element of the returned tuple to indicate what it successfully parsed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5153
diff changeset
122 mtime_parsed, parsed_what = cal.parse(mtime)
2218
c391df32467f fixed crash of xapian AdvancedSearch (fullsearch action) if mtime string is invalid, e.g. '2 days'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
123 # XXX it is unclear if usage of localtime here and in parsedatetime module is correct.
c391df32467f fixed crash of xapian AdvancedSearch (fullsearch action) if mtime string is invalid, e.g. '2 days'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
124 # time.localtime is the SERVER's local time and of no relevance to the user (being
c391df32467f fixed crash of xapian AdvancedSearch (fullsearch action) if mtime string is invalid, e.g. '2 days'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
125 # somewhere in the world)
c391df32467f fixed crash of xapian AdvancedSearch (fullsearch action) if mtime string is invalid, e.g. '2 days'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
126 # mktime is reverse function for localtime, so this maybe fixes it again!?
5186
edd5719d5f07 parsedatetime 0.8.7 uses the 2nd element of the returned tuple to indicate what it successfully parsed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5153
diff changeset
127 if parsed_what > 0 and mtime_parsed <= time.localtime():
2218
c391df32467f fixed crash of xapian AdvancedSearch (fullsearch action) if mtime string is invalid, e.g. '2 days'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
128 mtime = time.mktime(mtime_parsed)
c391df32467f fixed crash of xapian AdvancedSearch (fullsearch action) if mtime string is invalid, e.g. '2 days'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
129 else:
c391df32467f fixed crash of xapian AdvancedSearch (fullsearch action) if mtime string is invalid, e.g. '2 days'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
130 mtime_parsed = None # we don't use invalid stuff
1507
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
131
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
132 # show info
9618ce536d46 first try to recognize mtimes from known datetime-formats, then try parsedatime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1505
diff changeset
133 if mtime_parsed:
2218
c391df32467f fixed crash of xapian AdvancedSearch (fullsearch action) if mtime string is invalid, e.g. '2 days'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
134 # XXX mtime_msg is not shown in some cases
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3113
diff changeset
135 mtime_msg = _("(!) Only pages changed since '''%s''' are being displayed!",
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3113
diff changeset
136 wiki=True) % request.user.getFormattedDateTime(mtime)
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
137 else:
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
138 mtime_msg = _('/!\\ The modification date you entered was not '
1503
632b4aa23c17 show the parsed mtime for the user to check
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1500
diff changeset
139 'recognized and is therefore not considered for the '
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3113
diff changeset
140 'search results!', wiki=True)
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
141 else:
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
142 mtime_msg = None
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
143
5829
a744f573fe30 advancedsearch: fix problem with non-ascii chars breaking up words for OR and NOT terms
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5567
diff changeset
144 word_re = re.compile(r'(\"[\w\s]+"|\w+)', re.UNICODE)
1373
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
145 needle = ''
3113
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3077
diff changeset
146 if categories[0]:
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3077
diff changeset
147 needle += 'category:%s ' % ','.join(categories)
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3077
diff changeset
148 if language[0]:
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3077
diff changeset
149 needle += 'language:%s ' % ','.join(language)
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3077
diff changeset
150 if mimetype[0]:
3489709aa99f AdvancedSearch: make multipe categories/languages/mimetype selections possible, thanks to James Sun (crptone@gmail.com, ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3077
diff changeset
151 needle += 'mimetype:%s ' % ','.join(mimetype)
1460
44a52e7ff380 s/pages/items/g and s/include/exclude/g underlay
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1452
diff changeset
152 if excludeunderlay:
1377
bb37beca7545 fixed system pages search, added underlay search, started with mtime filtering
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1376
diff changeset
153 needle += '-domain:underlay '
1460
44a52e7ff380 s/pages/items/g and s/include/exclude/g underlay
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1452
diff changeset
154 if nosystemitems:
1448
4012f0814295 optional excluding of system pages
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1446
diff changeset
155 needle += '-domain:system '
1373
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
156 if and_terms:
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
157 needle += '(%s) ' % and_terms
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
158 if not_terms:
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
159 needle += '(%s) ' % ' '.join(['-%s' % t for t in word_re.findall(not_terms)])
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
160 if or_terms:
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
161 needle += '(%s) ' % ' or '.join(word_re.findall(or_terms))
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
162
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
163 # check for sensible search term
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
164 stripped = needle.strip()
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
165 if len(stripped) == 0:
2967
a310264ad186 Added a few add_msg calls (by Federico Lorenzi).
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2966
diff changeset
166 request.theme.add_msg(_('Please use a more selective search term instead '
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3113
diff changeset
167 'of {{{"%s"}}}', wiki=True) % wikiutil.escape(needle), "error")
2967
a310264ad186 Added a few add_msg calls (by Federico Lorenzi).
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2966
diff changeset
168 Page(request, pagename).send_page()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
169 return
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
170 needle = stripped
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
171
1237
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
172 # Setup for type of search
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
173 if titlesearch:
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
174 title = _('Title Search: "%s"')
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
175 sort = 'page_name'
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
176 else:
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
177 if advancedsearch:
1500
3b37616c6b57 fix small typo
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1499
diff changeset
178 title = _('Advanced Search: "%s"')
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
179 else:
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
180 title = _('Full Text Search: "%s"')
1237
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
181 sort = 'weight'
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
182
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
183 # search the pages
4514
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3273
diff changeset
184 from MoinMoin.search import searchPages, QueryParser, QueryError
1451
ad6bfa51d16c nailed down a bug when there's no revision
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1450
diff changeset
185 try:
1452
95a46e89778e forgot the indentation..
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1451
diff changeset
186 query = QueryParser(case=case, regex=regex,
1443
d5a240018922 handle invalid search queries
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1442
diff changeset
187 titlesearch=titlesearch).parse_query(needle)
4514
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3273
diff changeset
188 except QueryError: # catch errors in the search query
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2943
diff changeset
189 request.theme.add_msg(_('Your search query {{{"%s"}}} is invalid. Please refer to '
3269
398ab9187a50 getText calls: fix some percent=... args
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
190 'HelpOnSearching for more information.', wiki=True, percent=True) % wikiutil.escape(needle), "error")
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2943
diff changeset
191 Page(request, pagename).send_page()
1451
ad6bfa51d16c nailed down a bug when there's no revision
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1450
diff changeset
192 return
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
193
4514
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3273
diff changeset
194 results = searchPages(request, query, sort, mtime, historysearch)
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3273
diff changeset
195
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3273
diff changeset
196 # directly show a single hit for title searches
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3273
diff changeset
197 # this is the "quick jump" functionality if you don't remember
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3273
diff changeset
198 # the pagename exactly, but just some parts of it
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3273
diff changeset
199 if titlesearch and len(results.hits) == 1:
437
f96c2c8d7c91 attachment search (lupy only)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 435
diff changeset
200 page = results.hits[0]
f96c2c8d7c91 attachment search (lupy only)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 435
diff changeset
201 if not page.attachment: # we did not find an attachment
f96c2c8d7c91 attachment search (lupy only)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 435
diff changeset
202 page = Page(request, page.page_name)
3014
dc970f2d146c avoid empty highlight query arg, do not use highlight for titlesearch terms (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2967
diff changeset
203 highlight = query.highlight_re()
dc970f2d146c avoid empty highlight query arg, do not use highlight for titlesearch terms (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2967
diff changeset
204 if highlight:
dc970f2d146c avoid empty highlight query arg, do not use highlight for titlesearch terms (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2967
diff changeset
205 querydict = {'highlight': highlight}
dc970f2d146c avoid empty highlight query arg, do not use highlight for titlesearch terms (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2967
diff changeset
206 else:
dc970f2d146c avoid empty highlight query arg, do not use highlight for titlesearch terms (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2967
diff changeset
207 querydict = {}
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3122
diff changeset
208 url = page.url(request, querystr=querydict)
437
f96c2c8d7c91 attachment search (lupy only)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 435
diff changeset
209 request.http_redirect(url)
618
e0cbf33ff15c remove MoinMoinNoFooter (not needed and more), please call theme.send_closing_html() for closing what send_title() opened
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 617
diff changeset
210 return
4514
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3273
diff changeset
211 if not results.hits: # no hits?
1490
1660b71d2316 show full-search hint if no results found with titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1489
diff changeset
212 f = request.formatter
5153
f4fcdeaab409 fix wrong usage of parseQueryString result
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4516
diff changeset
213 querydict = dict(wikiutil.parseQueryString(request.query_string))
1490
1660b71d2316 show full-search hint if no results found with titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1489
diff changeset
214 querydict.update({'titlesearch': 0})
1660b71d2316 show full-search hint if no results found with titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1489
diff changeset
215
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2943
diff changeset
216 request.theme.add_msg(_('Your search query {{{"%s"}}} didn\'t return any results. '
1487
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
217 'Please change some terms and refer to HelpOnSearching for '
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3113
diff changeset
218 'more information.%s', wiki=True, percent=True) % (wikiutil.escape(needle),
1490
1660b71d2316 show full-search hint if no results found with titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1489
diff changeset
219 titlesearch and ''.join([
1660b71d2316 show full-search hint if no results found with titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1489
diff changeset
220 '<br>',
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3113
diff changeset
221 _('(!) Consider performing a', wiki=True), ' ',
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3122
diff changeset
222 f.url(1, href=request.page.url(request, querydict, escape=0)),
1490
1660b71d2316 show full-search hint if no results found with titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1489
diff changeset
223 _('full-text search with your search terms'),
1660b71d2316 show full-search hint if no results found with titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1489
diff changeset
224 f.url(0), '.',
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2943
diff changeset
225 ]) or ''), "error")
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2943
diff changeset
226 Page(request, pagename).send_page()
1487
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
227 return
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
228
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
229 # This action generates data using the user language
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
230 request.setContentLanguage(request.lang)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
231
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4253
diff changeset
232 request.theme.send_title(title % needle, pagename=pagename)
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 921
diff changeset
233
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
234 # Start content (important for RTL support)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
235 request.write(request.formatter.startContent("content"))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
236
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
237 # Hints
1489
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
238 f = request.formatter
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
239 hints = []
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
240
1489
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
241 if titlesearch:
5153
f4fcdeaab409 fix wrong usage of parseQueryString result
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4516
diff changeset
242 querydict = dict(wikiutil.parseQueryString(request.query_string))
1489
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
243 querydict.update({'titlesearch': 0})
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
244
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
245 hints.append(''.join([
1518
986be5c76da5 Fixed BR error in fullsearch.py, reworded title search hint.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1509
diff changeset
246 _("(!) You're performing a title search that might not include"
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3113
diff changeset
247 ' all related results of your search query in this wiki. <<BR>>', wiki=True),
1489
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
248 ' ',
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3122
diff changeset
249 f.url(1, href=request.page.url(request, querydict, escape=0)),
1489
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
250 f.text(_('Click here to perform a full-text search with your '
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
251 'search terms!')),
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
252 f.url(0),
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
253 ]))
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
254
1508
f446b7c83b85 fix backtrace for mtime_msg if advancedsearch isn't used
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1507
diff changeset
255 if advancedsearch and mtime_msg:
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
256 hints.append(mtime_msg)
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
257
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
258 if hints:
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
259 request.write(searchHints(f, hints))
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
260
1489
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
261 # Search stats
1487
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
262 request.write(results.stats(request, request.formatter, hitsFrom))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
263
1487
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
264 # Then search results
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
265 info = not titlesearch
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
266 if context:
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
267 output = results.pageListWithContext(request, request.formatter,
2943
fa428b3c7d64 introduced hitsInfo keyword for results.pageList (default is 0). Action fullsearch does set it to 1. So the macro FullSearch does not show the hits info.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2936
diff changeset
268 info=info, context=context, hitsFrom=hitsFrom, hitsInfo=1)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
269 else:
1487
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
270 output = results.pageList(request, request.formatter, info=info,
2943
fa428b3c7d64 introduced hitsInfo keyword for results.pageList (default is 0). Action fullsearch does set it to 1. So the macro FullSearch does not show the hits info.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2936
diff changeset
271 hitsFrom=hitsFrom, hitsInfo=1)
1487
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
272
ad473f8dc533 output no results found message as a msg to the previous page
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1486
diff changeset
273 request.write(output)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
274
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
275 request.write(request.formatter.endContent())
616
3b08d9413589 move send_title/footer from wikiutil to theme.__init__
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 437
diff changeset
276 request.theme.send_footer(pagename)
617
cf420addd95c removed MoinMoinNoFooter at many places, added call to theme.send_closing_html() where needed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 616
diff changeset
277 request.theme.send_closing_html()
435
368e6a8e4f98 lupy: tokenizer adds the complete CamelCase word to the index (not only the splitted words), lowered mergeFactor, cleaner dir structure in cache directory, source cleanup
Thomas Waldmann <tw@waldmann-edv.de>
parents: 391
diff changeset
278