changeset 1494:cdcdab722a96

domain-specific search is implemented
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Fri, 25 Aug 2006 14:40:12 +0200
parents 91f8863f0c13
children f3df2ca6658f
files MoinMoin/macro/AdvancedSearch.py MoinMoin/search/builtin.py MoinMoin/search/queryparser.py
diffstat 3 files changed, 24 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/AdvancedSearch.py	Fri Aug 25 14:23:30 2006 +0200
+++ b/MoinMoin/macro/AdvancedSearch.py	Fri Aug 25 14:40:12 2006 +0200
@@ -115,14 +115,12 @@
                 (form_get(request, 'case') and ' checked' or '',
                     _('Case-sensitive search'))),
                 ('', '<input type="checkbox" name="excludeunderlay" '
-                    'value="1"%s%s>%s</input>' %
+                    'value="1"%s>%s</input>' %
                 (form_get(request, 'excludeunderlay') and ' checked' or '',
-                    disabledIfMoinSearch,
                     _('Exclude underlay'))),
                 ('', '<input type="checkbox" name="nosystemitems" '
-                    'value="1"%s%s>%s</input>' %
+                    'value="1"%s>%s</input>' %
                 (form_get(request, 'nosystemitems') and ' checked' or '',
-                    disabledIfMoinSearch,
                     _('No system items'))),
                 ('', '<input type="checkbox" name="historysearch" '
                     'value="1"%s%s>%s</input>' %
--- a/MoinMoin/search/builtin.py	Fri Aug 25 14:23:30 2006 +0200
+++ b/MoinMoin/search/builtin.py	Fri Aug 25 14:40:12 2006 +0200
@@ -629,11 +629,11 @@
         will happen later on the hits, which is faster with current
         slow storage.
         """
-        filter = self.query.pageFilter()
-        if filter:
+        filter_ = self.query.pageFilter()
+        if filter_:
             # There is no need to filter the results again.
             self.filtered = True
-            return self.request.rootpage.getPageList(filter=filter)
+            return self.request.rootpage.getPageList(filter=filter_)
         else:
             return self.request.rootpage.getPageList(user='', exists=0)
         
--- a/MoinMoin/search/queryparser.py	Fri Aug 25 14:23:30 2006 +0200
+++ b/MoinMoin/search/queryparser.py	Fri Aug 25 14:40:12 2006 +0200
@@ -11,7 +11,7 @@
 """
 
 import re
-from MoinMoin import config
+from MoinMoin import config, wikiutil
 from MoinMoin.search.results import Match, TitleMatch, TextMatch
 
 try:
@@ -618,7 +618,7 @@
             match = True
 
         # Decide what to do with the results.
-            if self.negated and match:
+        if self.negated and match:
             return None
         elif match or (self.negated and not match):
             return [Match()]
@@ -735,10 +735,7 @@
         return ""
 
     def search(self, page):
-        if not self.xapian_called:
-            return []
-        else:
-            return [Match()]
+        return None
 
     def xapian_wanted(self):
         return True             # only easy regexps possible
@@ -798,10 +795,23 @@
         return ""
 
     def search(self, page):
-        if not self.xapian_called:
+        checks = {'underlay': page.isUnderlayPage,
+                  'standard': page.isStandardPage,
+                  'system': wikiutil.isSystemPage(page.request, page.page_name),
+                 }
+
+        try:
+            match = checks[self.pattern]()
+        except KeyError:
+            match = False
+
+        # Decide what to do with the results.
+        if self.negated and match:
+            return None
+        elif match or (self.negated and not match):
+            return [Match()]
+        else:
             return []
-        else:
-            return [Match()]
 
     def xapian_wanted(self):
         return True             # only easy regexps possible