Description

In typing in the URL for a page like MoinMoinBug that happens to be MoinMoinBugs the error page given to users gives two columns: Page Templates and "Existing pages with similar names:" However this special and common case is not recognized, so the link to the intended page is way down mixed in with many other search results.

Steps to reproduce

  1. Create page with the name MoinMoinBugs

  2. type in the url for MoinMoinBug

Example

URL: http://moinmo.in/MoinMoinBug

Component selection

Details

This Wiki.

Workaround

type the s

I am sure that the pseudo code fix for this will look something like: if (MoinMoinBug not found) and exists (MoinMoinBugs) then put it at the top of the list of "Existing pages with similar names:"

Discussion

If you can provide code doing this for all languages we support, we'll take it. :)

After some discussion on #moinmoin we came up with this - untested so far. LikePages.py.diff

   1 --- moin-1.7.0/MoinMoin/action/LikePages.py.orig   2008-03-16 12:29:48.000000000 -0700
   2 +++ moin-1.7.0/MoinMoin/action/LikePages.py        2008-06-26 16:13:53.000000000 -0700
   3 @@ -107,6 +107,10 @@
   4          if not (page.exists() and request.user.may.read(name)):`
   5              del matches[name]
   6  
   7 +    plural = "%ss" % pagename
   8 +    if plural in pages:
   9 +        close_matches[plural] = 9
  10 +
  11      # Finally, merge both dicts
  12      matches.update(close_matches)
  13  
  14 @@ -204,6 +208,7 @@
  15  def showMatches(pagename, request, start, end, matches, show_count=True):
  16      keys = matches.keys()
  17      keys.sort()
  18 +    _showMatchGroup(request, matches, keys, 9, pagename, show_count)
  19      _showMatchGroup(request, matches, keys, 8, pagename, show_count)
  20      _showMatchGroup(request, matches, keys, 4, "%s/..." % pagename, show_count)
  21      _showMatchGroup(request, matches, keys, 3, "%s...%s" % (start, end), show_count)

another idea is to make it more robust using something like

-- GrantBow 2008-06-26 23:40:04

Actually, the real solution would look something like this:

   1 --- moin-1.7.0/MoinMoin/action/LikePages.py.orig   2008-03-16 12:29:48.000000000 -0700
   2 +++ moin-1.7.0/MoinMoin/action/LikePages.py        2008-06-26 16:13:53.000000000 -0700
   3 @@ -107,6 +107,10 @@
   4          if not (page.exists() and request.user.may.read(name)):`
   5              del matches[name]
   6  
   7 +    plural = get_plural_name(pagename, request.language)
   8 +    if plural in pages:
   9 +        close_matches[plural] = 9
  10 +
  11      # Finally, merge both dicts
  12      matches.update(close_matches)
  13  
  14 @@ -204,6 +208,7 @@
  15  def showMatches(pagename, request, start, end, matches, show_count=True):
  16      keys = matches.keys()
  17      keys.sort()
  18 +    _showMatchGroup(request, matches, keys, 9, pagename, show_count)
  19      _showMatchGroup(request, matches, keys, 8, pagename, show_count)
  20      _showMatchGroup(request, matches, keys, 4, "%s/..." % pagename, show_count)
  21      _showMatchGroup(request, matches, keys, 3, "%s...%s" % (start, end), show_count)

...where get_plural_name would be an universal function able to generate a plural form of any page name (or, actually, many plural forms, as you could have different parts of title pluralized) in any of the supported languages. Of course, this is not possible, but maybe translators would have some sensible ideas for approximations, at least for some languages...

In reality, a good stemmer would suffice... -- RadomirDopieralski 2008-06-26 23:45:04

We have a good stemmer, at least if Xapian is there. I don't like the above solution because it is language specific (and just works for English or a few hardcoded languages). Better would be to just use the "word in foundword" solution and then sort the shorted of those to the top. -- ThomasWaldmann 2008-06-27 06:40:52

Plan


CategoryMoinMoinNoBug

MoinMoin: MoinMoinBugs/NotFoundPlural (last edited 2008-06-27 06:40:53 by ThomasWaldmann)