diff MoinMoin/themes/__init__.py @ 1110:5479a3b62b9f

Change shorten_revid to shorten_id everywhere. Also, fix the usage of length function arg in filter shorten_id
author Bilal Akhtar <bilalakhtar@ubuntu.com>
date Mon, 28 Nov 2011 18:38:10 -0500
parents b703c5e590a3
children ebc4f8213e74
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Mon Nov 28 18:09:58 2011 -0500
+++ b/MoinMoin/themes/__init__.py	Mon Nov 28 18:38:10 2011 -0500
@@ -344,20 +344,20 @@
             name = u'{0}...{1}'.format(name[:half + left], name[-half:])
     return name
 
-def shorten_revid(name, length=7):
+def shorten_id(name, length=7):
     """
-    Shorten revision IDs
+    Shorten IDs to specified length
 
-    Shorten long hex revids into just the first 7 characters. There's
-    no need to display the whole revids everywhere.
+    Shorten long IDs into just the first <length> characters. There's
+    no need to display the whole IDs everywhere.
 
     :param name: item name, unicode
-    :param length: Maximum length of the resulting revid, int
+    :param length: Maximum length of the resulting ID, int
     :rtype: unicode
-    :returns: truncated version
+    :returns: <name> truncated to <length> characters
     """
 
-    return name[:7]
+    return name[:length]
 
 MIMETYPE_TO_CLASS = {
     'application/pdf': 'pdf',
@@ -393,7 +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['shorten_id'] = shorten_id
     app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
     # please note that these filters are installed by flask-babel:
     # datetimeformat, dateformat, timeformat, timedeltaformat