changeset 54:2d6a32f75c2d

WikiConfig: remove macro, create admin view
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 01 Mar 2011 23:19:20 +0100
parents 62166a1c4f2a
children 32b88d45d63c
files MoinMoin/apps/admin/templates/index.html MoinMoin/apps/admin/templates/wikiconfig.html MoinMoin/apps/admin/views.py MoinMoin/macro/WikiConfig.py
diffstat 4 files changed, 90 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/admin/templates/index.html	Tue Mar 01 21:42:10 2011 +0100
+++ b/MoinMoin/apps/admin/templates/index.html	Tue Mar 01 23:19:20 2011 +0100
@@ -4,6 +4,7 @@
 <ul>
     <li><a href="{{ url_for('admin.userbrowser') }}">{{ _("User Browser") }}</a></li>
     <li><a href="{{ url_for('admin.sysitems_upgrade') }}">{{ _("Upgrade system items") }}</a></li>
+    <li><a href="{{ url_for('admin.wikiconfig') }}">{{ _("Show Wiki Configuration") }}</a></li>
 </ul>
 {% endblock %}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/apps/admin/templates/wikiconfig.html	Tue Mar 01 23:19:20 2011 +0100
@@ -0,0 +1,36 @@
+{% extends theme("layout.html") %}
+{% block content %}
+<h1>{{ _("Wiki configuration") }}</h1>
+<p>
+{{ _("This table shows all settings in this wiki that do not have default values. "
+     "Settings that the configuration system doesn't know about are shown in italic, "
+     "those may be due to third-party extensions needing configuration or settings that "
+     "were removed from Moin.")
+}}
+</p>
+<table>
+<thead>
+<tr>
+<td><strong>{{ _('Variable name') }}</strong></td>
+<td><strong>{{ _('Setting') }}</strong></td>
+</tr>
+</thead>
+<tbody>
+{% for name, value in found %}
+<tr>
+<td>
+    {% if name in settings %}
+        {{ name }}
+    {% else %}
+        <em>{{ name }}</em>
+    {% endif %}
+</td>
+<td>
+    <code>{{ "%r" % (value, ) }}</code>
+</td>
+</tr>
+{% endfor %}
+</tdbody>
+</table>
+{% endblock %}
+
--- a/MoinMoin/apps/admin/views.py	Tue Mar 01 21:42:10 2011 +0100
+++ b/MoinMoin/apps/admin/views.py	Tue Mar 01 23:19:20 2011 +0100
@@ -1,13 +1,14 @@
-# Copyright: 2008-2010 MoinMoin:ThomasWaldmann
+# Copyright: 2008-2011 MoinMoin:ThomasWaldmann
 # Copyright: 2001-2003 Juergen Hermann <jh@web.de>
+# Copyright: 2008 MoinMoin:JohannesBerg
 # Copyright: 2010 MoinMoin:DiogenesAugusto
 # Copyright: 2010 MoinMoin:ReimarBauer
 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
 
 """
-    MoinMoin - admin views
+MoinMoin - admin views
 
-    This shows the user interface for wiki admins.
+This shows the user interface for wiki admins.
 """
 
 
@@ -109,3 +110,52 @@
             flash(_('System items have been upgraded successfully!'))
         return redirect(url_for('admin.index'))
 
+
+from MoinMoin.config import default as defaultconfig
+
+@admin.route('/wikiconfig', methods=['GET', ])
+def wikiconfig():
+    if not flaskg.user or not flaskg.user.isSuperUser():
+        return ''
+
+    settings = {}
+    for groupname in defaultconfig.options:
+        heading, desc, opts = defaultconfig.options[groupname]
+        for name, default, description in opts:
+            name = groupname + '_' + name
+            if isinstance(default, defaultconfig.DefaultExpression):
+                default = default.value
+            settings[name] = default
+    for groupname in defaultconfig.options_no_group_name:
+        heading, desc, opts = defaultconfig.options_no_group_name[groupname]
+        for name, default, description in opts:
+            if isinstance(default, defaultconfig.DefaultExpression):
+                default = default.value
+            settings[name] = default
+
+    def iter_vnames(cfg):
+        dedup = {}
+        for name in cfg.__dict__:
+            dedup[name] = True
+            yield name, cfg.__dict__[name]
+        for cls in cfg.__class__.mro():
+            if cls == defaultconfig.ConfigFunctionality:
+                break
+            for name in cls.__dict__:
+                if not name in dedup:
+                    dedup[name] = True
+                    yield name, cls.__dict__[name]
+
+    found = []
+    for vname, value in iter_vnames(app.cfg):
+        if hasattr(defaultconfig.ConfigFunctionality, vname):
+            continue
+        if vname in settings and settings[vname] == value:
+            continue
+        found.append((vname, value))
+
+    found.sort()
+    return render_template('admin/wikiconfig.html',
+                           item_name="+admin/wikiconfig",
+                           found=found, settings=settings)
+
--- a/MoinMoin/macro/WikiConfig.py	Tue Mar 01 21:42:10 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-# Copyright: 2008 MoinMoin:JohannesBerg
-# Copyright: 2008,2011 MoinMoin:ThomasWaldmann
-# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
-
-"""
-MoinMoin - Show Wiki Configuration
-"""
-
-
-from flask import current_app as app
-
-from flask import flaskg
-
-from MoinMoin.i18n import _, L_, N_
-from MoinMoin.config import default as defaultconfig
-from MoinMoin.macro._base import MacroBlockBase
-from MoinMoin.util.tree import moin_page
-
-class Macro(MacroBlockBase):
-    def macro(self, content, arguments, page_url, alternative):
-        if not flaskg.user or not flaskg.user.isSuperUser():
-            return ''
-
-        settings = {}
-        for groupname in defaultconfig.options:
-            heading, desc, opts = defaultconfig.options[groupname]
-            for name, default, description in opts:
-                name = groupname + '_' + name
-                if isinstance(default, defaultconfig.DefaultExpression):
-                    default = default.value
-                settings[name] = default
-        for groupname in defaultconfig.options_no_group_name:
-            heading, desc, opts = defaultconfig.options_no_group_name[groupname]
-            for name, default, description in opts:
-                if isinstance(default, defaultconfig.DefaultExpression):
-                    default = default.value
-                settings[name] = default
-
-        result = moin_page.div()
-
-        result.append(
-            moin_page.h(attrib={moin_page.outline_level: '1'}, children=[_("Wiki configuration")]))
-
-        desc = _("This table shows all settings in this wiki that do not have default values. "
-              "Settings that the configuration system doesn't know about are shown in italic, "
-              "those may be due to third-party extensions needing configuration or settings that "
-              "were removed from Moin.")
-        result.append(moin_page.p(children=[desc]))
-
-        table = moin_page.table()
-        result.append(table)
-
-        header = moin_page.table_header()
-        table.append(header)
-
-        row = moin_page.table_row()
-        header.append(row)
-        for text in [_('Variable name'), _('Setting'), ]:
-            strong_text = moin_page.strong(children=[text])
-            row.append(moin_page.table_cell(children=[strong_text]))
-
-        body = moin_page.table_body()
-        table.append(body)
-
-        def iter_vnames(cfg):
-            dedup = {}
-            for name in cfg.__dict__:
-                dedup[name] = True
-                yield name, cfg.__dict__[name]
-            for cls in cfg.__class__.mro():
-                if cls == defaultconfig.ConfigFunctionality:
-                    break
-                for name in cls.__dict__:
-                    if not name in dedup:
-                        dedup[name] = True
-                        yield name, cls.__dict__[name]
-
-        found = []
-        for vname, value in iter_vnames(app.cfg):
-            if hasattr(defaultconfig.ConfigFunctionality, vname):
-                continue
-            if vname in settings and settings[vname] == value:
-                continue
-            found.append((vname, value))
-
-        found.sort()
-        for vname, value in found:
-            if not vname in settings:
-                vname = moin_page.emphasis(children=[vname])
-            vtxt = '%r' % (value, )
-            row = moin_page.table_row()
-            body.append(row)
-            row.append(moin_page.table_cell(children=[vname]))
-            vtxt_code = moin_page.code(children=[vtxt])
-            row.append(moin_page.table_cell(children=[vtxt_code]))
-        return result
-