~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/macro/PageList.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
    MoinMoin - PageList
 
4
 
 
5
    print a list of pages whose title matches the search term
 
6
 
 
7
    @copyright: @copyright: 2001-2003 Juergen Hermann <jh@web.de>,
 
8
                2003-2008 MoinMoin:ThomasWaldmann
 
9
                2008 MoinMoin:ReimarBauer
 
10
    @license: GNU GPL, see COPYING for details.
 
11
"""
 
12
 
 
13
Dependencies = ["namespace"]
 
14
from MoinMoin import search, wikiutil
 
15
 
 
16
def execute(macro, args):
 
17
    _ = macro._
 
18
    case = 0
 
19
 
 
20
    # If called with empty or no argument, default to regex search for .+, the full page list.
 
21
    needle = wikiutil.get_unicode(macro.request, args, 'needle', u'regex:.+')
 
22
 
 
23
    # With whitespace argument, return same error message as FullSearch
 
24
    if not needle.strip():
 
25
        err = _('Please use a more selective search term instead of {{{"%s"}}}', wiki=True) % needle
 
26
        return '<span class="error">%s</span>' % err
 
27
 
 
28
    # Return a title search for needle, sorted by name.
 
29
    try:
 
30
        results = search.searchPages(macro.request, needle,
 
31
                                     titlesearch=1, case=case,
 
32
                                     sort='page_name')
 
33
        ret = results.pageList(macro.request, macro.formatter, paging=False)
 
34
    except ValueError:
 
35
        # same error as in MoinMoin/action/fullsearch.py, keep it that way!
 
36
        ret = ''.join([macro.formatter.text('<<PageList('),
 
37
                      _('Your search query {{{"%s"}}} is invalid. Please refer to '
 
38
                        'HelpOnSearching for more information.', wiki=True,
 
39
                        percent=True) % wikiutil.escape(needle),
 
40
                      macro.formatter.text(')>>')])
 
41
    return ret