comparison MoinMoin/themes/__init__.py @ 2944:afe523052a7f

rework global history styling for modernized and basic themes, add user and comment fields, partial fix #471
author RogerHaase <haaserd@gmail.com>
date Sun, 10 May 2015 13:51:39 -0700
parents 456c68761e96
children
comparison
equal deleted inserted replaced
2943:39d57a15fdef 2944:afe523052a7f
7 MoinMoin - Theme Support 7 MoinMoin - Theme Support
8 """ 8 """
9 9
10 10
11 import urllib 11 import urllib
12 import datetime
12 13
13 from json import dumps 14 from json import dumps
14 15
15 from flask import current_app as app 16 from flask import current_app as app
16 from flask import g as flaskg 17 from flask import g as flaskg
649 :returns: user understandable version of contenttype 650 :returns: user understandable version of contenttype
650 """ 651 """
651 return CONTENTTYPES_MAP.get(contenttype, "Unknown") 652 return CONTENTTYPES_MAP.get(contenttype, "Unknown")
652 653
653 654
655 def time_hh_mm(dt):
656 """
657 Convert a datetime object into a short string of the form HH:MM
658 where HH varies from 0 to 23.
659 """
660 return datetime.datetime.fromtimestamp(dt).strftime('%H:%M')
661
662
654 def setup_jinja_env(): 663 def setup_jinja_env():
655 app.jinja_env.filters['shorten_fqname'] = shorten_fqname 664 app.jinja_env.filters['shorten_fqname'] = shorten_fqname
656 app.jinja_env.filters['shorten_item_name'] = shorten_item_name 665 app.jinja_env.filters['shorten_item_name'] = shorten_item_name
657 app.jinja_env.filters['shorten_id'] = shorten_id 666 app.jinja_env.filters['shorten_id'] = shorten_id
658 app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class 667 app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
659 app.jinja_env.filters['json_dumps'] = dumps 668 app.jinja_env.filters['json_dumps'] = dumps
660 app.jinja_env.filters['shorten_ctype'] = shorten_ctype 669 app.jinja_env.filters['shorten_ctype'] = shorten_ctype
670 app.jinja_env.filters['time_hh_mm'] = time_hh_mm
661 # please note that these filters are installed by flask-babel: 671 # please note that these filters are installed by flask-babel:
662 # datetimeformat, dateformat, timeformat, timedeltaformat 672 # datetimeformat, dateformat, timeformat, timedeltaformat
663 673
664 app.jinja_env.globals.update({ 674 app.jinja_env.globals.update({
665 # please note that flask-babel/jinja2.ext installs: 675 # please note that flask-babel/jinja2.ext installs: