comparison MoinMoin/themes/__init__.py @ 216:661a57c747bd

replace mimetype by contenttype, use more constants to deal correctly with text items, we do not just need the simple mimetype like "text/plain", but rather the contenttype like "text/plain;charset=utf-8" or, for content from moin 1.9, "text/x.moin.wiki;format=1.9;charset=utf-8" to make moin use the moinwiki19_in converter. this changeset mostly deals with the stupid task of renaming the constant, the attributes, the arguments, qs arg names, etc. - so that everything that does not mean a basic mimetype major/minor should be named contenttype now. it also fixes a few places that used strings and not the constants from MoinMoin.config or where imports were missing. further changes will be needed to really deal with the charset and other params. also, the value of MoinMoin.config.CONTENTTYPE will need to get changed later.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 07 May 2011 20:22:30 +0200
parents e8f61cbd661b
children 1a1dab306214
comparison
equal deleted inserted replaced
213:1c835a7297ea 216:661a57c747bd
359 359
360 MIMETYPE_TO_CLASS = { 360 MIMETYPE_TO_CLASS = {
361 'application/pdf': 'pdf', 361 'application/pdf': 'pdf',
362 } 362 }
363 363
364 def mimetype_to_class(mimetype): 364 def contenttype_to_class(contenttype):
365 """ 365 """
366 Convert a mimetype string to a css class. 366 Convert a contenttype string to a css class.
367 """ 367 """
368 cls = MIMETYPE_TO_CLASS.get(mimetype) 368 cls = MIMETYPE_TO_CLASS.get(contenttype)
369 if not cls: 369 if not cls:
370 # just use the major part of mimetype 370 # just use the major part of mimetype
371 cls = mimetype.split('/', 1)[0] 371 cls = contenttype.split('/', 1)[0]
372 return 'moin-mime-%s' % cls 372 return 'moin-mime-%s' % cls
373 373
374 374
375 def setup_jinja_env(): 375 def setup_jinja_env():
376 app.jinja_env.filters['shorten_item_name'] = shorten_item_name 376 app.jinja_env.filters['shorten_item_name'] = shorten_item_name
377 app.jinja_env.filters['mimetype_to_class'] = mimetype_to_class 377 app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
378 # please note that these filters are installed by flask-babel: 378 # please note that these filters are installed by flask-babel:
379 # datetimeformat, dateformat, timeformat, timedeltaformat 379 # datetimeformat, dateformat, timeformat, timedeltaformat
380 380
381 app.jinja_env.globals.update({ 381 app.jinja_env.globals.update({
382 # please note that flask-babel/jinja2.ext installs: 382 # please note that flask-babel/jinja2.ext installs: