changeset 2409:51b90beddc7c

Shortens contenttype display in the history view
author sharky93 <rishabhr123@gmail.com>
date Sat, 24 Aug 2013 15:23:05 +0530
parents e0736d533b8f
children 89ce7644a01d
files MoinMoin/themes/__init__.py MoinMoin/themes/basic/templates/history.html
diffstat 2 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Sat Aug 24 01:28:27 2013 +0530
+++ b/MoinMoin/themes/__init__.py	Sat Aug 24 15:23:05 2013 +0530
@@ -473,6 +473,26 @@
             name = u'{0}...{1}'.format(name[:half + left], name[-half:])
     return name
 
+CONTENTTYPE_SHORTEN = {
+    'text/x.moin.wiki': 'MoinWiki',
+}
+
+def shorten_content_type(contenttype):
+    """
+    Shorten content-types
+
+    Shortens the content-type to terms that normal users understand.
+
+    :param name: contenttype, unicode
+    :rtype: unicode
+    :returns: shortened version of contenttype
+    """
+    print type(contenttype)
+    ctype = contenttype.split(';')[0]
+    if ctype in CONTENTTYPE_SHORTEN:
+        return CONTENTTYPE_SHORTEN[ctype]
+    else:
+        return "Unknown"
 
 def shorten_id(name, length=7):
     """
@@ -527,6 +547,7 @@
     app.jinja_env.filters['shorten_id'] = shorten_id
     app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
     app.jinja_env.filters['json_dumps'] = dumps
+    app.jinja_env.filters['shorten_ctype'] = shorten_content_type
     # please note that these filters are installed by flask-babel:
     # datetimeformat, dateformat, timeformat, timedeltaformat
 
--- a/MoinMoin/themes/basic/templates/history.html	Sat Aug 24 01:28:27 2013 +0530
+++ b/MoinMoin/themes/basic/templates/history.html	Sat Aug 24 15:23:05 2013 +0530
@@ -32,7 +32,7 @@
                     <th class="moin-integer">{{ _("Size") }}</th>
                     <th id="moin-button-diff"><button class="btn btn-primary">Diff</button></th>
                     <th>{{ _("Editor") }}</th>
-                    <th>{{ _("Content-Type") }}</th>
+                    <th>{{ _("Type") }}</th>
                     <th>{{ _("Comment") }}</th>
                     <th></th>
                 </tr>
@@ -51,7 +51,7 @@
                         </div>
                     </td>
                     <td class="moin-wordbreak">{{ utils.editor_info(doc) }}</td>
-                    <td class="moin-wordbreak">{{ doc.contenttype }}</td>
+                    <td class="moin-wordbreak" title="{{ doc.contenttype }}">{{ doc.contenttype|shorten_ctype }}</td>
                     <td class="moin-wordbreak">{{ doc.comment }}</td>
                     <td>
             <div class="btn-group dropup menu">