Back to index

moin  1.9.0~rc2
PageList.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - PageList
00004 
00005     print a list of pages whose title matches the search term
00006 
00007     @copyright: @copyright: 2001-2003 Juergen Hermann <jh@web.de>,
00008                 2003-2008 MoinMoin:ThomasWaldmann
00009                 2008 MoinMoin:ReimarBauer
00010     @license: GNU GPL, see COPYING for details.
00011 """
00012 
00013 Dependencies = ["namespace"]
00014 from MoinMoin import search, wikiutil
00015 
00016 def execute(macro, args):
00017     _ = macro._
00018     case = 0
00019 
00020     # If called with empty or no argument, default to regex search for .+, the full page list.
00021     needle = wikiutil.get_unicode(macro.request, args, 'needle', u'regex:.+')
00022 
00023     # With whitespace argument, return same error message as FullSearch
00024     if not needle.strip():
00025         err = _('Please use a more selective search term instead of {{{"%s"}}}', wiki=True) % needle
00026         return '<span class="error">%s</span>' % err
00027 
00028     # Return a title search for needle, sorted by name.
00029     try:
00030         results = search.searchPages(macro.request, needle,
00031                                      titlesearch=1, case=case,
00032                                      sort='page_name')
00033         ret = results.pageList(macro.request, macro.formatter, paging=False)
00034     except ValueError:
00035         # same error as in MoinMoin/action/fullsearch.py, keep it that way!
00036         ret = ''.join([macro.formatter.text('<<PageList('),
00037                       _('Your search query {{{"%s"}}} is invalid. Please refer to '
00038                         'HelpOnSearching for more information.', wiki=True,
00039                         percent=True) % wikiutil.escape(needle),
00040                       macro.formatter.text(')>>')])
00041     return ret