diff MoinMoin/themes/__init__.py @ 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 5bf6d7a2ffcf
children 5479a3b62b9f
line wrap: on
line diff
--- 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