Imported bugzilla extension from mercurial 1.3.1.
1 # vim: set ts=4 sw=4 tw=99 et ft=python:
3 '''allows overriding of templates directory for hgwebdir
5 The code in hgweb/hgweb_mod.py allows you to override the templates directory path using the
6 web.templates option. However, this is not allowed by hgweb/hgwebdir_mod.py. This extension fixes
7 this problem by using the same web.templates option.
9 However, extensions are not normally loaded when hgwebdir is in use. In order to fix this, you must
10 modify the hgwebdir CGI script like so:
12 from mercurial import extensions
13 from mercurial.hgweb.hgwebdir_mod import hgwebdir
14 import mercurial.hgweb.wsgicgi as wsgicgi
16 application = hgwebdir('hgweb.config')
17 extensions.loadall(application.ui)
18 wsgicgi.launch(application)
20 To enable this extension:
23 templatepath = /path/to/templatepath.py
27 from mercurial import extensions, templater
34 extensions.wrapfunction(templater, 'templatepath', hook_templatepath)
36 def hook_templatepath(orig, name=None):
37 templates = _ui.config('web', 'templates')
43 path = os.path.join(templates, name)
44 if os.path.exists(path):
45 return os.path.normpath(path)