Commits

Bilal Akhtar committed b703c5e

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.

Comments (0)

Files changed (4)

MoinMoin/templates/diff_text.html

 {% 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>

MoinMoin/templates/history.html

             {% 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>

MoinMoin/templates/show.html

 {% 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") }}

MoinMoin/themes/__init__.py

             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',
 
 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