changeset 3014:dc970f2d146c

avoid empty highlight query arg, do not use highlight for titlesearch terms (port from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 06 Jan 2008 20:00:40 +0100
parents 6238e1b2fd7f
children 8d691fbdc929
files MoinMoin/action/fullsearch.py MoinMoin/search/queryparser.py MoinMoin/search/results.py
diffstat 3 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/fullsearch.py	Sun Jan 06 19:24:28 2008 +0100
+++ b/MoinMoin/action/fullsearch.py	Sun Jan 06 20:00:40 2008 +0100
@@ -198,7 +198,12 @@
         page = results.hits[0]
         if not page.attachment: # we did not find an attachment
             page = Page(request, page.page_name)
-            url = page.url(request, querystr={'highlight': query.highlight_re()}, relative=False)
+            highlight = query.highlight_re()
+            if highlight:
+                querydict = {'highlight': highlight}
+            else:
+                querydict = {}
+            url = page.url(request, querystr=querydict, relative=False)
             request.http_redirect(url)
             return
     elif not results.hits: # no hits?
--- a/MoinMoin/search/queryparser.py	Sun Jan 06 19:24:28 2008 +0100
+++ b/MoinMoin/search/queryparser.py	Sun Jan 06 20:00:40 2008 +0100
@@ -424,7 +424,8 @@
         return u'%s!"%s"' % (neg, unicode(self._pattern))
 
     def highlight_re(self):
-        return u"(%s)" % self._pattern
+        return u'' # do not highlight text with stuff from titlesearch,
+                   # was: return u"(%s)" % self._pattern
 
     def pageFilter(self):
         """ Page filter function for single title search """
--- a/MoinMoin/search/results.py	Sun Jan 06 19:24:28 2008 +0100
+++ b/MoinMoin/search/results.py	Sun Jan 06 20:00:40 2008 +0100
@@ -760,7 +760,9 @@
         if querydict is None:
             querydict = {}
         if 'action' not in querydict or querydict['action'] == 'AttachFile':
-            querydict.update({'highlight': self.query.highlight_re()})
+            highlight = self.query.highlight_re()
+            if highlight:
+                querydict.update({'highlight': highlight})
         querystr = wikiutil.makeQueryString(querydict)
         return querystr