def source( req, argument_text, env, aswiki =False): from trac.versioncontrol.web_ui.util import get_existing_node, get_path_rev_line ## XXX above .util is shaded by trac.util? path,rev,line = get_path_rev_line( argument_text) from trac.mimeview import Mimeview, get_mimetype, content_to_unicode repos = env.get_repository() # req.authname) node = get_existing_node( env, repos, path, rev) content = node.get_content().read() if aswiki: mimetype = 'text/x-trac-wiki' r = wiki_to_html( content_to_unicode( env, content, mimetype), env=env, req=req) else: mimetype = get_mimetype( os.path.basename( path) ) or 'text/plain ' mimeview = Mimeview( env) #charset = mimeview.get_charset( content, mimetype) #node.content_type? #content = util.to_utf8( content, charset ) r = mimeview.render( req, mimetype, content) return r, None
def mimeview_formatter(req, text): mimeview = Mimeview(self.env) context = web_context(req) return mimeview.render(context, mimetype, text)
def mimeview_formatter(req, text): mimeview = Mimeview(self.env) context = Context.from_request(req) return mimeview.render(context, mimetype, text)