~ubuntu-branches/ubuntu/jaunty/moin/jaunty-security

« back to all changes in this revision

Viewing changes to MoinMoin/macro/WikiConfigHelp.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-11-13 16:45:52 UTC
  • mfrom: (0.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20081113164552-49t6zf2t2o5bqigh
Tags: 1.8.0-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop recommendation of python-xml, the packages isn't anymore in
    sys.path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
    MoinMoin - Wiki Configuration Help
 
4
"""
 
5
from MoinMoin.config import multiconfig
 
6
 
 
7
Dependencies = []
 
8
generates_headings = True
 
9
 
 
10
def macro_WikiConfigHelp(macro):
 
11
    request = macro.request
 
12
    _ = request.getText
 
13
    f = macro.request.formatter
 
14
    ret = []
 
15
 
 
16
    groups = []
 
17
    for groupname in multiconfig.options:
 
18
        groups.append((groupname, True, multiconfig.options))
 
19
    for groupname in multiconfig.options_no_group_name:
 
20
        groups.append((groupname, False, multiconfig.options_no_group_name))
 
21
    groups.sort()
 
22
 
 
23
    for groupname, addgroup, optsdict in groups:
 
24
        heading, desc, opts = optsdict[groupname]
 
25
        ret.extend([
 
26
            f.heading(1, 1, id=groupname),
 
27
            ## XXX: translate description?
 
28
            f.text(heading),
 
29
            f.heading(0, 1),
 
30
        ])
 
31
        if desc:
 
32
            ret.extend([
 
33
                f.paragraph(1),
 
34
                f.text(desc),
 
35
                f.paragraph(0)
 
36
            ])
 
37
        ret.extend([
 
38
            f.table(1),
 
39
            f.table_row(1),
 
40
            f.table_cell(1), f.strong(1), f.text(_('Variable name')), f.strong(0), f.table_cell(0),
 
41
            f.table_cell(1), f.strong(1), f.text(_('Default')), f.strong(0), f.table_cell(0),
 
42
            f.table_cell(1), f.strong(1), f.text(_('Description')), f.strong(0), f.table_cell(0),
 
43
            f.table_row(0),
 
44
        ])
 
45
        opts = list(opts)
 
46
        opts.sort()
 
47
        for name, default, description in opts:
 
48
            if addgroup:
 
49
                name = groupname + '_' + name
 
50
            if isinstance(default, multiconfig.DefaultExpression):
 
51
                default_txt = default.text
 
52
            else:
 
53
                default_txt = '%r' % (default, )
 
54
                if len(default_txt) <= 30:
 
55
                    default_txt = f.text(default_txt)
 
56
                else:
 
57
                    default_txt = f.span(1, title=default_txt) + f.text('...') + f.span(0)
 
58
                description = _(description or '', wiki=True)
 
59
            ret.extend([
 
60
                f.table_row(1),
 
61
                f.table_cell(1), f.text(name), f.table_cell(0),
 
62
                f.table_cell(1), f.code(1, css="backtick"), default_txt, f.code(0), f.table_cell(0),
 
63
                f.table_cell(1), description, f.table_cell(0),
 
64
                f.table_row(0),
 
65
            ])
 
66
        ret.append(f.table(0))
 
67
 
 
68
    return ''.join(ret)