annotate MoinMoin/action/fullsearch.py @ 4072:8bbb028087f1

merge changes from moin/1.7
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 07 Sep 2008 16:22:59 +0200
parents 9c6900a92a64
children 85884c67228d af09c1b3a153
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
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
14 from MoinMoin.support.parsedatetime.parsedatetime import Calendar
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15
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
16 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
17 """ 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
18 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
19
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
20 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
21 '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
22 '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
23 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
24 """
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 form = request.form
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
26 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
27 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
28 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
29 try:
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 ret = int(form['titlesearch'][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
31 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
32 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
33 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
34 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
35 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
36
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
37 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
38 """ 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
39 try:
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 return int(request.form['advancedsearch'][0])
1373
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
41 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
42 return False
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
44
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
45 def searchHints(f, hints):
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
46 """ 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
47
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
48 @param f: the formatter to use
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
49 @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
50 """
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
51 return ''.join([
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
52 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
53 # 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
54 "<br>".join(hints),
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
55 f.paragraph(0),
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
56 ])
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
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
59 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
60 _ = 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
61 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
62 if titlesearch < 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
63 request.makeForbidden403()
1570
8bfaae6fa0a5 kick spammers by triggering surge protection
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1561
diff changeset
64 request.surge_protect(kick_him=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
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
69 # 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
70 if titlesearch:
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 921
diff changeset
71 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
72 elif advancedsearch:
1832
b180f047d918 comments only: cleaned up TODO, XXX, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
73 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
74 else:
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 921
diff changeset
75 context = int(request.form.get('context', [0])[0])
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 921
diff changeset
76
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
77 # Get other form parameters
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
78 needle = request.form.get(fieldname, [''])[0]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79 case = int(request.form.get('case', [0])[0])
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
80 regex = int(request.form.get('regex', [0])[0]) # no interface currently
1187
1bdac55acc14 paging support for fullsearch action, fullsearch macro broken
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 949
diff changeset
81 hitsFrom = int(request.form.get('from', [0])[0])
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
82 mtime = None
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
83 msg = ''
1441
05482b439f89 optional history indexing and search is working
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1434
diff changeset
84 historysearch = 0
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
85
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
86 # 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
87 if advancedsearch:
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
88 and_terms = request.form.get('and_terms', [''])[0].strip()
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
89 or_terms = request.form.get('or_terms', [''])[0].strip()
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
90 not_terms = request.form.get('not_terms', [''])[0].strip()
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
91 #xor_terms = request.form.get('xor_terms', [''])[0].strip()
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
92 categories = request.form.get('categories', [''])
1373
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
93 timeframe = request.form.get('time', [''])[0].strip()
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
94 language = request.form.get('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
95 mimetype = request.form.get('mimetype', [0])
1460
44a52e7ff380 s/pages/items/g and s/include/exclude/g underlay
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1452
diff changeset
96 excludeunderlay = request.form.get('excludeunderlay', [0])[0]
44a52e7ff380 s/pages/items/g and s/include/exclude/g underlay
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1452
diff changeset
97 nosystemitems = request.form.get('nosystemitems', [0])[0]
1441
05482b439f89 optional history indexing and search is working
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1434
diff changeset
98 historysearch = request.form.get('historysearch', [0])[0]
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
99
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
100 mtime = request.form.get('mtime', [''])[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 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
102 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
103
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 # 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
105 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
106 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
107 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
108 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
109 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
110 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
111 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
112 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
113 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
114
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 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
116 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
117 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
118 # 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
119 cal = Calendar()
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
120 mtime_parsed, invalid_flag = cal.parse(mtime)
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
121 # 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
122 # 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
123 # 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
124 # mktime is reverse function for localtime, so this maybe fixes it again!?
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 if not invalid_flag and mtime_parsed <= time.localtime():
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 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
127 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
128 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
129
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
130 # 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
131 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
132 # 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
133 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
134 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
135 else:
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
136 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
137 '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
138 'search results!', wiki=True)
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
139 else:
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
140 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
141
1373
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
142 word_re = re.compile(r'(\"[\w\s]+"|\w+)')
90cb8fe71cdf get fullsearch action working with the advanced search dialogue
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1369
diff changeset
143 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
144 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
145 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
146 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
147 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
148 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
149 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
150 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
151 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
152 if nosystemitems:
1448
4012f0814295 optional excluding of system pages
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1446
diff changeset
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
161 # 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
162 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
163 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
164 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
165 '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
166 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
167 return
1433
6b0ea72d7665 mtime search works, added MoinMoin.support.parsedatetime, small fixes
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1377
diff changeset
168 needle = stripped
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
169
1237
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
170 # Setup for type of search
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
171 if titlesearch:
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
172 title = _('Title Search: "%s"')
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
173 sort = 'page_name'
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
174 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
175 if advancedsearch:
1500
3b37616c6b57 fix small typo
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1499
diff changeset
176 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
177 else:
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
178 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
179 sort = 'weight'
0a947454dec7 use xapian for sorting search results
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1213
diff changeset
180
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
181 # search the pages
921
45e286183872 abstraction work on search engine index & cleanups
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 919
diff changeset
182 from MoinMoin.search import searchPages, QueryParser
1451
ad6bfa51d16c nailed down a bug when there's no revision
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1450
diff changeset
183 try:
1452
95a46e89778e forgot the indentation..
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1451
diff changeset
184 query = QueryParser(case=case, regex=regex,
1443
d5a240018922 handle invalid search queries
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1442
diff changeset
185 titlesearch=titlesearch).parse_query(needle)
1452
95a46e89778e forgot the indentation..
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1451
diff changeset
186 results = searchPages(request, query, sort, mtime, historysearch)
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
187 except ValueError: # 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
188 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
189 '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
190 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
191 return
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
192
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
193 # directly show a single hit
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
194 # Note: can't work with attachment search
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
195 # improve if we have one...
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
196 if len(results.hits) == 1:
437
f96c2c8d7c91 attachment search (lupy only)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 435
diff changeset
197 page = results.hits[0]
f96c2c8d7c91 attachment search (lupy only)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 435
diff changeset
198 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
199 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
200 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
201 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
202 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
203 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
204 querydict = {}
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3122
diff changeset
205 url = page.url(request, querystr=querydict)
437
f96c2c8d7c91 attachment search (lupy only)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 435
diff changeset
206 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
207 return
1499
ffa0d1f81059 final polishing round adding docstrings, comments and fixing small issues
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1490
diff changeset
208 elif 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
209 f = request.formatter
1660b71d2316 show full-search hint if no results found with titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1489
diff changeset
210 querydict = wikiutil.parseQueryString(request.query_string)
1660b71d2316 show full-search hint if no results found with titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1489
diff changeset
211 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
212
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
213 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
214 '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
215 '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
216 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
217 '<br>',
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3113
diff changeset
218 _('(!) 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
219 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
220 _('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
221 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
222 ]) 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
223 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
224 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
225
1068
ecece5db5288 use emit_http_headers
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 949
diff changeset
226 request.emit_http_headers()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
227
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
228 # 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
229 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
230
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3269
diff changeset
231 request.theme.send_title(title % needle, form=request.form, pagename=pagename)
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 921
diff changeset
232
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
233 # 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
234 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
235
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
236 # 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
237 f = request.formatter
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
238 hints = []
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
239
1489
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
240 if titlesearch:
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
241 querydict = wikiutil.parseQueryString(request.query_string)
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
242 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
243
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
244 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
245 _("(!) 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
246 ' 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
247 ' ',
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3122
diff changeset
248 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
249 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
250 '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
251 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
252 ]))
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
253
1508
f446b7c83b85 fix backtrace for mtime_msg if advancedsearch isn't used
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1507
diff changeset
254 if advancedsearch and mtime_msg:
1505
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
255 hints.append(mtime_msg)
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
256
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
257 if hints:
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
258 request.write(searchHints(f, hints))
c4f111e61e16 reformat output of mtime
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1504
diff changeset
259
1489
cd788728a7ec Show hint to consider full-text search if using titlesearch
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1487
diff changeset
260 # 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
261 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
262
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
263 # 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
264 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
265 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
266 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
267 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
268 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
269 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
270 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
271
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 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
273
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
274 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
275 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
276 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
277