changeset 94:990fdbe2d52c

admin/itemsize view (replaces PageSize macro)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 07 Mar 2011 21:00:33 +0100
parents efce6cdc8237
children 15629036f800
files MoinMoin/apps/admin/templates/itemsize.html MoinMoin/apps/admin/views.py MoinMoin/macro/PageSize.py
diffstat 3 files changed, 33 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/apps/admin/templates/itemsize.html	Mon Mar 07 21:00:33 2011 +0100
@@ -0,0 +1,7 @@
+{% import "utils.html" as utils %}
+{% extends theme("layout.html") %}
+{% block content %}
+<h1>{{ _("Item sizes (latest revision)") }}</h1>
+{{ utils.table(headings, rows) }}
+{% endblock %}
+
--- a/MoinMoin/apps/admin/views.py	Mon Mar 07 20:45:28 2011 +0100
+++ b/MoinMoin/apps/admin/views.py	Mon Mar 07 21:00:33 2011 +0100
@@ -21,6 +21,8 @@
 from MoinMoin.themes import render_template
 from MoinMoin.apps.admin import admin
 from MoinMoin import user
+from MoinMoin.storage.error import NoSuchRevisionError
+
 
 @admin.route('/')
 def index():
@@ -209,6 +211,7 @@
                            headings=headings,
                            rows=rows)
 
+
 @admin.route('/interwikihelp', methods=['GET', ])
 def interwikihelp():
     """display a table with list of known interwiki names / urls"""
@@ -221,3 +224,26 @@
                            headings=headings,
                            rows=rows)
 
+
+@admin.route('/itemsize', methods=['GET', ])
+def itemsize():
+    """display a table with item sizes"""
+    headings = [_('Size'),
+                _('Item name'),
+               ]
+    rows = []
+    for item in flaskg.storage.iteritems():
+        try:
+            rev = item.get_revision(-1)
+        except NoSuchRevisionError:
+            # XXX we currently also get user items, they have no revisions -
+            # but in the end, they should not be readable by the user anyways
+            continue
+        rows.append((rev.size, item.name))
+    rows = sorted(rows, reverse=True)
+    return render_template('admin/itemsize.html',
+                           item_name="+admin/itemsize",
+                           headings=headings,
+                           rows=rows)
+
+
--- a/MoinMoin/macro/PageSize.py	Mon Mar 07 20:45:28 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-# Copyright: 2002 Juergen Hermann <jh@web.de>
-# Copyright: 2008,2011 MoinMoin:ThomasWaldmann
-# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
-
-"""
-MoinMoin - PageSize Macro displays an ordered list with page sizes and names
-"""
-
-from flask import flaskg
-from MoinMoin.storage.error import NoSuchRevisionError
-from MoinMoin.macro._base import MacroNumberPageLinkListBase
-
-class Macro(MacroNumberPageLinkListBase):
-    def macro(self, content, arguments, page_url, alternative):
-        sizes_pagenames = []
-        for item in flaskg.storage.iteritems():
-            try:
-                rev = item.get_revision(-1)
-            except NoSuchRevisionError:
-                # XXX we currently also get user items, they have no revisions -
-                # but in the end, they should not be readable by the user anyways
-                continue
-            sizes_pagenames.append((rev.size, item.name))
-        sizes_pagenames.sort()
-        sizes_pagenames.reverse()
-
-        return self.create_number_pagelink_list(sizes_pagenames)
-