Short description
When there is only one search result, MoinMoin jumps to that page right away. This is the right thing (tm) most of the time, but not for some specific uses of MoinMoin.
My client wanted to disable this behavior for his CMS-like site with the following patch. It would be nice to have this as a config option in the wikiconfig.
Always return a results page, regardless of the number of results. Needs polishing but seems to work. This should be configurable. --- /usr/local/lib/python2.5/site-packages/MoinMoin/action/fullsearch.py.orig 2008-02-19 21:46:32.000000000 +0000 +++ /usr/local/lib/python2.5/site-packages/MoinMoin/action/fullsearch.py 2008-06-09 14:41:26.000000000 +0000 @@ -191,6 +191,7 @@ Page(request, pagename).send_page(msg=err) return + """ always return a results page, regardless of the number of results # directly show a single hit # Note: can't work with attachment search # improve if we have one... @@ -224,6 +225,7 @@ ]) or '') Page(request, pagename).send_page(msg=err) return + """ # always return a results page request.emit_http_headers() @@ -240,6 +242,10 @@ f = request.formatter hints = [] + if not results.hits: # no hits? + hints.append(_('Your search query {{{"%s"}}} didn\'t return any results. ', + formatted=True, percent=True) % (wikiutil.escape(needle))) + if titlesearch: querydict = wikiutil.parseQueryString(request.query_string) querydict.update({'titlesearch': 0}) @@ -262,7 +268,8 @@ request.write(searchHints(f, hints)) # Search stats - request.write(results.stats(request, request.formatter, hitsFrom)) + if results.hits: + request.write(results.stats(request, request.formatter, hitsFrom)) # Then search results info = not titlesearch
(patch courtesy of Alex Rousskov)