changeset 5859:570e430cd08c

action/fullsearch.py: ability to suppress highlighting in fullsearch action added.
author Eugene Syromyatnikov <evgsyr@gmail.com>
date Sun, 20 May 2012 22:53:26 +0400
parents be11f1e64e73
children 9acfab97e561
files MoinMoin/action/fullsearch.py
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/fullsearch.py	Mon May 21 01:04:38 2012 +0400
+++ b/MoinMoin/action/fullsearch.py	Sun May 20 22:53:26 2012 +0400
@@ -81,6 +81,8 @@
     case = int(form.get('case', 0))
     regex = int(form.get('regex', 0)) # no interface currently
     hitsFrom = int(form.get('from', 0))
+    highlight_titles = int(form.get('highlight_titles', 1))
+    highlight_pages = int(form.get('highlight_pages', 1))
     mtime = None
     msg = ''
     historysearch = 0
@@ -200,11 +202,11 @@
         page = results.hits[0]
         if not page.attachment: # we did not find an attachment
             page = Page(request, page.page_name)
-            highlight = query.highlight_re()
-            if highlight:
-                querydict = {'highlight': highlight}
-            else:
-                querydict = {}
+            querydict = {}
+            if highlight_pages:
+                highlight = query.highlight_re()
+                if highlight:
+                    querydict.update({'highlight': highlight})
             url = page.url(request, querystr=querydict)
             request.http_redirect(url)
             return
@@ -265,10 +267,14 @@
     info = not titlesearch
     if context:
         output = results.pageListWithContext(request, request.formatter,
-                info=info, context=context, hitsFrom=hitsFrom, hitsInfo=1)
+                info=info, context=context, hitsFrom=hitsFrom, hitsInfo=1,
+                highlight_titles=highlight_titles,
+                highlight_pages=highlight_pages)
     else:
         output = results.pageList(request, request.formatter, info=info,
-                hitsFrom=hitsFrom, hitsInfo=1)
+                hitsFrom=hitsFrom, hitsInfo=1,
+                highlight_titles=highlight_titles,
+                highlight_pages=highlight_pages)
 
     request.write(output)