diff MoinMoin/themes/__init__.py @ 2651:2003e3685733

Improved search GUI - Added information about contenttype and item size in the items metadata. Also added color coding for various stuff like green for metadata, yellow for search term suggestions, blue for item names. Also added search options to help in search - search all revisions or the latest ones, sort search results by time - newer first, older first or default, search items of particular contenttype(s). Also removed the second search bar in the upper right corner in search page.
author Ajitesh Gupta <ajgupta93@gmail.com>
date Thu, 26 Jun 2014 04:09:07 +0530
parents 92a9c6ef1ec7
children 2a50e6628a16 7798855349f6
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Thu Jun 26 02:13:49 2014 +0530
+++ b/MoinMoin/themes/__init__.py	Thu Jun 26 04:09:07 2014 +0530
@@ -23,9 +23,10 @@
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin import wikiutil, user
 from MoinMoin.constants.keys import USERID, ADDRESS, HOSTNAME, REVID, ITEMID, NAME_EXACT
+from MoinMoin.constants.contenttypes import CONTENTTYPES_MAP
 from MoinMoin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERPROFILES, NAMESPACE_ALL
 from MoinMoin.search import SearchForm
-from MoinMoin.util.interwiki import split_interwiki, getInterwikiHome, is_local_wiki, is_known_wiki, url_for_item, CompositeName, split_fqname
+from MoinMoin.util.interwiki import split_interwiki, getInterwikiHome, is_local_wiki, is_known_wiki, url_for_item, CompositeName, split_fqname, get_fqname
 from MoinMoin.util.crypto import cache_key
 from MoinMoin.util.forms import make_generator
 from MoinMoin.util.clock import timed
@@ -573,24 +574,6 @@
 }
 
 
-# TODO: Update dictionary with more content-types
-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
-    """
-    ctype = contenttype.split(';')[0]
-    if ctype in CONTENTTYPE_SHORTEN:
-        return CONTENTTYPE_SHORTEN[ctype]
-    else:
-        return "Unknown"
-
-
 def shorten_id(name, length=7):
     """
     Shorten IDs to specified length
@@ -639,13 +622,24 @@
     return timegm(dt.timetuple())
 
 
+def shorten_ctype(contenttype):
+    """
+    Returns user understandable terms for contenttype.
+
+    :param contenttype: contains the long form of the contenttype
+    :rtype: unicode
+    :returns: user understandable version of contenttype
+    """
+    return CONTENTTYPES_MAP.get(contenttype, "Unknown")
+
+
 def setup_jinja_env():
     app.jinja_env.filters['shorten_fqname'] = shorten_fqname
     app.jinja_env.filters['shorten_item_name'] = shorten_item_name
     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
+    app.jinja_env.filters['shorten_ctype'] = shorten_ctype
     # please note that these filters are installed by flask-babel:
     # datetimeformat, dateformat, timeformat, timedeltaformat
 
@@ -664,6 +658,7 @@
         'cfg': app.cfg,
         'item_name': u'@NONAMEGIVEN',  # XXX can we just use u'' ?
         'url_for_item': url_for_item,
+        'get_fqname': get_fqname,
         'get_editor_info': lambda meta: get_editor_info(meta),
         'utctimestamp': lambda dt: utctimestamp(dt),
         'gen': make_generator(),