changeset 1189:0e352443948b

make FullSearch macro work again (without paging)
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Tue, 18 Jul 2006 19:33:59 +0200
parents f4f7b0c2a9f2
children 1d5fd64c356e
files MoinMoin/macro/FullSearch.py MoinMoin/macro/__init__.py MoinMoin/search/results.py docs/CHANGES.fpletz
diffstat 4 files changed, 29 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/FullSearch.py	Tue Jul 18 17:15:45 2006 +0200
+++ b/MoinMoin/macro/FullSearch.py	Tue Jul 18 19:33:59 2006 +0200
@@ -57,6 +57,6 @@
     results = search.searchPages(request, needle)
     results.sortByPagename()
 
-    return results.pageList(request, macro.formatter)
+    return results.pageList(request, macro.formatter, paging=False)
 
 
--- a/MoinMoin/macro/__init__.py	Tue Jul 18 17:15:45 2006 +0200
+++ b/MoinMoin/macro/__init__.py	Tue Jul 18 19:33:59 2006 +0200
@@ -332,7 +332,7 @@
         results = search.searchPages(self.request, needle,
                 titlesearch=1, case=case)
         results.sortByPagename()
-        return results.pageList(self.request, self.formatter)
+        return results.pageList(self.request, self.formatter, paging=False)
 
     def _macro_InterWiki(self, args):
         from StringIO import StringIO
--- a/MoinMoin/search/results.py	Tue Jul 18 17:15:45 2006 +0200
+++ b/MoinMoin/search/results.py	Tue Jul 18 19:33:59 2006 +0200
@@ -289,13 +289,14 @@
         return ''.join(output)
 
     def pageList(self, request, formatter, info=0, numbered=1,
-            hitsFrom=0):
+            paging=True, hitsFrom=0):
         """ Format a list of found pages
 
         @param request: current request
         @param formatter: formatter to use
         @param info: show match info in title
         @param numbered: use numbered list for display
+        @param paging: toggle paging
         @param hitsFrom: current position in the hits
         @rtype: unicode
         @return formatted page list
@@ -313,8 +314,13 @@
             write(list(1))
             
             # XXX: Do some xapian magic here
-            hitsTo = hitsFrom + request.cfg.search_results_per_page
-            for page in self.hits[hitsFrom:hitsTo]:
+            if paging:
+                hitsTo = hitsFrom + request.cfg.search_results_per_page
+                displayHits = self.hits[hitsFrom:hitsTo]
+            else:
+                displayHits = self.hits
+
+            for page in displayHits:
                 if page.attachment:
                     querydict = {
                         'action': 'AttachFile',
@@ -338,14 +344,15 @@
                     ]
                 write(''.join(item))
             write(list(0))
-            write(self.formatPrevNextPageLinks(hitsFrom=hitsFrom,
-                hitsPerPage=request.cfg.search_results_per_page,
-                hitsNum=len(self.hits)))
+            if paging:
+                write(self.formatPrevNextPageLinks(hitsFrom=hitsFrom,
+                    hitsPerPage=request.cfg.search_results_per_page,
+                    hitsNum=len(self.hits)))
 
         return self.getvalue()
 
     def pageListWithContext(self, request, formatter, info=1, context=180,
-                            maxlines=1, hitsFrom=0):
+                            maxlines=1, paging=True, hitsFrom=0):
         """ Format a list of found pages with context
 
         The default parameter values will create Google-like search
@@ -358,6 +365,7 @@
         @param info: show match info near the page link
         @param context: how many characters to show around each match.
         @param maxlines: how many contexts lines to show.
+        @param paging: toggle paging
         @param hitsFrom: current position in the hits
         @rtype: unicode
         @return formatted page list with context
@@ -371,8 +379,13 @@
             write(f.definition_list(1))
 
             # XXX: Do some xapian magic here
-            hitsTo = hitsFrom+request.cfg.search_results_per_page
-            for page in self.hits[hitsFrom:hitsTo]:
+            if paging:
+                hitsTo = hitsFrom+request.cfg.search_results_per_page
+                displayHits = self.hits[hitsFrom:hitsTo]
+            else:
+                displayHits = self.hits
+
+            for page in displayHits:
                 matchInfo = ''
                 if info:
                     matchInfo = self.formatInfo(f, page)
@@ -403,9 +416,10 @@
                     ]
                 write(''.join(item))
             write(f.definition_list(0))
-            write(self.formatPrevNextPageLinks(hitsFrom=hitsFrom,
-                hitsPerPage=request.cfg.search_results_per_page,
-                hitsNum=len(self.hits)))
+            if paging:
+                write(self.formatPrevNextPageLinks(hitsFrom=hitsFrom,
+                    hitsPerPage=request.cfg.search_results_per_page,
+                    hitsNum=len(self.hits)))
         
         return self.getvalue()
 
--- a/docs/CHANGES.fpletz	Tue Jul 18 17:15:45 2006 +0200
+++ b/docs/CHANGES.fpletz	Tue Jul 18 19:33:59 2006 +0200
@@ -160,5 +160,5 @@
 2006-07-18
     * Fixed some bugs, whitespaces at EOL, better i18n for SystemInfo
     * Implemented paging support for searches, needs some style
-      adjustments, breaks FullSearch macro for now
+      adjustments