Mercurial > kallithea
comparison 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 |
comparison
equal
deleted
inserted
replaced
30:424167fefd6c | 31:2963f2894a7a |
---|---|
8 from pprint import pprint | 8 from pprint import pprint |
9 import os | 9 import os |
10 from mercurial import ui, hg | 10 from mercurial import ui, hg |
11 from mercurial.error import RepoError | 11 from mercurial.error import RepoError |
12 from ConfigParser import ConfigParser | 12 from ConfigParser import ConfigParser |
13 | 13 import encodings |
14 log = logging.getLogger(__name__) | 14 log = logging.getLogger(__name__) |
15 | 15 |
16 class HgController(BaseController): | 16 class HgController(BaseController): |
17 | 17 |
18 def __before__(self): | 18 def __before__(self): |
19 c.repos_prefix = 'etelko' | 19 c.repos_prefix = 'etelko' |
20 | 20 |
21 | |
22 def view(self, *args, **kwargs): | 21 def view(self, *args, **kwargs): |
23 response = g.hgapp(request.environ, self.start_response) | 22 response = g.hgapp(request.environ, self.start_response) |
24 #for mercurial protocols we can't wrap into mako | 23 #for mercurial protocols and raw files we can't wrap into mako |
25 if request.environ['HTTP_ACCEPT'].find("mercurial") >= 0: | 24 if request.environ['HTTP_ACCEPT'].find("mercurial") != -1 or \ |
25 request.environ['PATH_INFO'].find('raw-file') != -1: | |
26 return response | 26 return response |
27 | 27 |
28 #wrap the murcurial response in a mako template. | 28 tmpl = ''.join(response) |
29 template = Template("".join(response), | 29 |
30 lookup = request.environ['pylons.pylons']\ | 30 template = Template(tmpl, lookup=request.environ['pylons.pylons']\ |
31 .config['pylons.g'].mako_lookup) | 31 .config['pylons.g'].mako_lookup) |
32 | 32 |
33 return template.render(g = g, c = c, session = session, h = h) | 33 return template.render(g=g, c=c, session=session, h=h) |
34 | 34 |
35 | 35 |
36 def manage_hgrc(self): | 36 def manage_hgrc(self): |
37 pass | 37 pass |
38 | |
39 def hgrc(self, dirname): | |
40 filename = os.path.join(dirname, '.hg', 'hgrc') | |
41 return filename | |
38 | 42 |
39 def add_repo(self, new_repo): | 43 def add_repo(self, new_repo): |
40 c.staticurl = g.statics | 44 c.staticurl = g.statics |
41 | 45 |
42 #extra check it can be add since it's the command | 46 #extra check it can be add since it's the command |