changeset 1109:b703c5e590a3

Create new template filter "shorten_revid" which shortens the specified text to 7 chars Make use of templates in history, show and diff_text HTML templates. Also, in history.html, render revids in monospace fonts.
author Bilal Akhtar <bilalakhtar@ubuntu.com>
date Mon, 28 Nov 2011 18:09:58 -0500
parents df49aab5d88a
children 5479a3b62b9f
files MoinMoin/templates/diff_text.html MoinMoin/templates/history.html MoinMoin/templates/show.html MoinMoin/themes/__init__.py
diffstat 4 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/templates/diff_text.html	Mon Nov 28 12:51:57 2011 +0100
+++ b/MoinMoin/templates/diff_text.html	Mon Nov 28 18:09:58 2011 -0500
@@ -3,7 +3,7 @@
 {% macro show_meta(rev) %}
     <div class="moin-diff-info moin-diff-info-rev-id">
         <span class="moin-diff-info-caption">Revision:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['revid'] }}</span>
+        <span class="moin-diff-info-value">{{ rev.meta['revid'] | shorten_revid }}</span>
     </div>
     <div class="moin-diff-info moin-diff-info-rev-author">
         <span class="moin-diff-info-caption">Editor:</span>
--- a/MoinMoin/templates/history.html	Mon Nov 28 12:51:57 2011 +0100
+++ b/MoinMoin/templates/history.html	Mon Nov 28 18:09:58 2011 -0500
@@ -30,7 +30,7 @@
             {% for doc in history %}
             <tr>
                 <td class="moin-wordbreak">{{ doc.name }}</td>
-                <td class="moin-integer">{{ doc.revid }}</td>
+                <td class="moin-integer"><tt>{{ doc.revid|shorten_revid }}</tt></td>
                 <td>{{ doc.mtime|datetimeformat }}</td>
                 <td class="moin-integer">{{ doc.size }}</td>
                 <td>
--- a/MoinMoin/templates/show.html	Mon Nov 28 12:51:57 2011 +0100
+++ b/MoinMoin/templates/show.html	Mon Nov 28 18:09:58 2011 -0500
@@ -64,7 +64,7 @@
 {% block footer_meta %}
     {% if rev %}
     <p id="moin-pageinfo" lang="{{ theme_supp.ui_lang }}" dir="{{ theme_supp.ui_dir }}">
-        {% if cfg.show_interwiki %}{{ cfg.interwikiname }}:{% endif %}{{ item_name }} (rev {{rev.revid}}),
+        {% if cfg.show_interwiki %}{{ cfg.interwikiname }}:{% endif %}{{ item_name }} (rev {{rev.revid | shorten_revid}}),
         {{ _("modified") }} {{ rev.meta['mtime']|datetimeformat }}
         {{ _("by") }} {{ utils.editor_info(rev.meta) }}{% if rev.tags %},
         {{ _("tagged") }}
--- a/MoinMoin/themes/__init__.py	Mon Nov 28 12:51:57 2011 +0100
+++ b/MoinMoin/themes/__init__.py	Mon Nov 28 18:09:58 2011 -0500
@@ -344,6 +344,20 @@
             name = u'{0}...{1}'.format(name[:half + left], name[-half:])
     return name
 
+def shorten_revid(name, length=7):
+    """
+    Shorten revision IDs
+
+    Shorten long hex revids into just the first 7 characters. There's
+    no need to display the whole revids everywhere.
+
+    :param name: item name, unicode
+    :param length: Maximum length of the resulting revid, int
+    :rtype: unicode
+    :returns: truncated version
+    """
+
+    return name[:7]
 
 MIMETYPE_TO_CLASS = {
     'application/pdf': 'pdf',
@@ -379,6 +393,7 @@
 
 def setup_jinja_env():
     app.jinja_env.filters['shorten_item_name'] = shorten_item_name
+    app.jinja_env.filters['shorten_revid'] = shorten_revid
     app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
     # please note that these filters are installed by flask-babel:
     # datetimeformat, dateformat, timeformat, timedeltaformat