changeset 91:2e0766600e8f

admin/highlighterhelp view (replaces HighlighterList macro), added table macro to utils.html template
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 07 Mar 2011 20:19:03 +0100
parents 21483835402f
children 5ff01f07c67c
files MoinMoin/apps/admin/templates/highlighterhelp.html MoinMoin/apps/admin/views.py MoinMoin/macro/HighlighterList.py MoinMoin/templates/utils.html
diffstat 4 files changed, 49 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/apps/admin/templates/highlighterhelp.html	Mon Mar 07 20:19:03 2011 +0100
@@ -0,0 +1,7 @@
+{% import "utils.html" as utils %}
+{% extends theme("layout.html") %}
+{% block content %}
+<h1>{{ _("Available Highlighters") }}</h1>
+{{ utils.table(headings, rows) }}
+{% endblock %}
+
--- a/MoinMoin/apps/admin/views.py	Mon Mar 07 19:33:02 2011 +0100
+++ b/MoinMoin/apps/admin/views.py	Mon Mar 07 20:19:03 2011 +0100
@@ -1,6 +1,7 @@
 # Copyright: 2008-2011 MoinMoin:ThomasWaldmann
 # Copyright: 2001-2003 Juergen Hermann <jh@web.de>
 # Copyright: 2008 MoinMoin:JohannesBerg
+# Copyright: 2009 MoinMoin:EugeneSyromyatnikov
 # Copyright: 2010 MoinMoin:DiogenesAugusto
 # Copyright: 2010 MoinMoin:ReimarBauer
 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
@@ -190,3 +191,21 @@
                            item_name="+admin/wikiconfighelp",
                            groups=groups)
 
+
+@admin.route('/highlighterhelp', methods=['GET', ])
+def highlighterhelp():
+    """display a table with list of available Pygments lexers"""
+    import pygments.lexers
+    headings = [_('Lexer description'),
+                _('Lexer names'),
+                _('File patterns'),
+                _('Mimetypes'),
+               ]
+    lexers = pygments.lexers.get_all_lexers()
+    rows = sorted([[desc, ' '.join(names), ' '.join(patterns), ' '.join(mimetypes), ]
+                   for desc, names, patterns, mimetypes in lexers])
+    return render_template('admin/highlighterhelp.html',
+                           item_name="+admin/highlighterhelp",
+                           headings=headings,
+                           rows=rows)
+
--- a/MoinMoin/macro/HighlighterList.py	Mon Mar 07 19:33:02 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-# Copyright: 2009 MoinMoin:EugeneSyromyatnikov
-# Copyright: 2010,2011 MoinMoin:ThomasWaldmann
-# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
-
-"""
-MoinMoin - HighlighterList Macro
-
-A simple macro for displaying a table with list of available Pygments lexers.
-
-Usage: <<HighlighterList>>
-"""
-
-
-import pygments.lexers
-
-from MoinMoin.i18n import _, L_, N_
-from MoinMoin.util.tree import moin_page
-from MoinMoin.macro._base import MacroBlockBase
-from MoinMoin.converter._table import TableMixin
-
-
-class Macro(TableMixin, MacroBlockBase):
-    def macro(self, content, arguments, page_url, alternative):
-        column_titles = [_('Lexer description'),
-                         _('Lexer names'),
-                         _('File patterns'),
-                         _('Mimetypes'),
-                        ]
-        lexers = pygments.lexers.get_all_lexers()
-        lexers = [[desc, ' '.join(names), ' '.join(patterns), ' '.join(mimetypes), ]
-                  for desc, names, patterns, mimetypes in lexers]
-
-        rows = [column_titles] + sorted(lexers)
-        return self.build_dom_table(rows)
-
--- a/MoinMoin/templates/utils.html	Mon Mar 07 19:33:02 2011 +0100
+++ b/MoinMoin/templates/utils.html	Mon Mar 07 20:19:03 2011 +0100
@@ -14,3 +14,26 @@
     </span>
   {%- endif -%}
 {% endmacro %}
+
+
+{% macro table(headings, rows) %}
+<table>
+<thead>
+    <tr>
+        {% for heading in headings %}
+        <td><strong>{{ heading }}</strong></td>
+        {% endfor %}
+    </tr>
+</thead>
+<tbody>
+{% for row in rows %}
+    <tr>
+        {% for col in row %}
+        <td>{{ col }}</td>
+        {% endfor %}
+    </tr>
+{% endfor %}
+</tbody>
+</table>
+{% endmacro %}
+