Mercurial > public > src > rhodecode
diff pylons_app/controllers/hg.py @ 31:2963f2894a7a
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
author | Marcin Kuzminski <marcin@python-blog.com> |
---|---|
date | Thu, 04 Mar 2010 23:13:12 +0100 |
parents | 3142616771cd |
children | f93b523c0be3 |
line wrap: on
line diff
--- a/pylons_app/controllers/hg.py Thu Mar 04 23:08:57 2010 +0100 +++ b/pylons_app/controllers/hg.py Thu Mar 04 23:13:12 2010 +0100 @@ -10,7 +10,7 @@ from mercurial import ui, hg from mercurial.error import RepoError from ConfigParser import ConfigParser - +import encodings log = logging.getLogger(__name__) class HgController(BaseController): @@ -18,24 +18,28 @@ def __before__(self): c.repos_prefix = 'etelko' - def view(self, *args, **kwargs): response = g.hgapp(request.environ, self.start_response) - #for mercurial protocols we can't wrap into mako - if request.environ['HTTP_ACCEPT'].find("mercurial") >= 0: + #for mercurial protocols and raw files we can't wrap into mako + if request.environ['HTTP_ACCEPT'].find("mercurial") != -1 or \ + request.environ['PATH_INFO'].find('raw-file') != -1: return response - #wrap the murcurial response in a mako template. - template = Template("".join(response), - lookup = request.environ['pylons.pylons']\ + tmpl = ''.join(response) + + template = Template(tmpl, lookup=request.environ['pylons.pylons']\ .config['pylons.g'].mako_lookup) - return template.render(g = g, c = c, session = session, h = h) + return template.render(g=g, c=c, session=session, h=h) def manage_hgrc(self): pass + def hgrc(self, dirname): + filename = os.path.join(dirname, '.hg', 'hgrc') + return filename + def add_repo(self, new_repo): c.staticurl = g.statics