import gluon.template
from gluon.fileutils import open_file
markmin_dict = dict(
code_python=lambda code: str(CODE(code)),
template=lambda
code: gluon.template.render(code, context=globals()),
sup=lambda
code: '%s' % code,
br=lambda n: '
' * int(n),
groupdates=lambda group: group_feed_reader(group),
)
def get_content(b=None,
c=request.controller,
f=request.function,
l='en',
format='markmin'):
"""Gets and renders the file in
/private/content////.
"""
def openfile():
import os
path = os.path.join(
request.folder, 'private', 'content', l, c, f, b + '.' + format)
return open_file(path, mode='r')
try:
openedfile = openfile()
except (Exception, IOError):
l = 'en'
openedfile = openfile()
if format == 'markmin':
html = MARKMIN(str(T(openedfile.read())), markmin_dict)
else:
html = str(T(openedfile.read()))
openedfile.close()
return html