changeset 1280:6d5d345599a1

special message when no results found
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Mon, 14 Aug 2006 23:52:48 +0200
parents 835c392be95d
children 7df93b9b320b
files MoinMoin/action/fullsearch.py MoinMoin/macro/SystemInfo.py
diffstat 2 files changed, 22 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/fullsearch.py	Mon Aug 14 23:28:54 2006 +0200
+++ b/MoinMoin/action/fullsearch.py	Mon Aug 14 23:52:48 2006 +0200
@@ -92,18 +92,27 @@
     # Start content (important for RTL support)
     request.write(request.formatter.startContent("content"))
 
-    # First search stats
-    request.write(results.stats(request, request.formatter, hitsFrom))
+    # Did we get any hits?
+    if results.hits:
+        # First search stats
+        request.write(results.stats(request, request.formatter, hitsFrom))
 
-    # Then search results
-    info = not titlesearch
-    if context:
-        output = results.pageListWithContext(request, request.formatter,
-                info=info, context=context, hitsFrom=hitsFrom)
+        # Then search results
+        info = not titlesearch
+        if context:
+            output = results.pageListWithContext(request, request.formatter,
+                    info=info, context=context, hitsFrom=hitsFrom)
+        else:
+            output = results.pageList(request, request.formatter, info=info,
+                    hitsFrom=hitsFrom)
+        request.write(output)
     else:
-        output = results.pageList(request, request.formatter, info=info,
-                hitsFrom=hitsFrom)
-    request.write(output)
+        f = request.formatter
+        request.write(''.join([
+            f.heading(1, 3),
+            f.text(_('Your search query didn\'t return any results.')),
+            f.heading(0, 3),
+        ]))
 
     request.write(request.formatter.endContent())
     request.theme.send_footer(pagename)
--- a/MoinMoin/macro/SystemInfo.py	Mon Aug 14 23:28:54 2006 +0200
+++ b/MoinMoin/macro/SystemInfo.py	Mon Aug 14 23:52:48 2006 +0200
@@ -115,7 +115,7 @@
     from MoinMoin.search.builtin import Search
     xapState = (_('Disabled'), _('Enabled'))
     idxState = (_('index available'), _('index unavailable'))
-    out = xapState[request.cfg.xapian_search]
+    xapRow = xapState[request.cfg.xapian_search]
 
     if request.cfg.xapian_search:
         idx = Search._xapianIndex(request)
@@ -124,9 +124,9 @@
                 request.user.getFormattedDateTime(
                     wikiutil.version2timestamp(idx.mtime())) or
                     _('N/A'))
-        out += ', %s, %s' % (available, mtime)
+        xapRow += ', %s, %s' % (available, mtime)
 
-    row(_('Xapian search'), out)
+    row(_('Xapian search'), xapRow)
     row(_('Xapian stemming'), xapState[request.cfg.xapian_stemming])
 
     row(_('Active threads'), t_count or _('N/A'))