ds@0: # vim: set ts=4 sw=4 tw=99 et ft=python: ds@0: ds@0: '''allows overriding of templates directory for hgwebdir ds@0: ds@0: The code in hgweb/hgweb_mod.py allows you to override the templates directory path using the ds@0: web.templates option. However, this is not allowed by hgweb/hgwebdir_mod.py. This extension fixes ds@0: this problem by using the same web.templates option. ds@0: ds@0: However, extensions are not normally loaded when hgwebdir is in use. In order to fix this, you must ds@0: modify the hgwebdir CGI script like so: ds@0: ds@0: from mercurial import extensions ds@0: from mercurial.hgweb.hgwebdir_mod import hgwebdir ds@0: import mercurial.hgweb.wsgicgi as wsgicgi ds@0: ds@0: application = hgwebdir('hgweb.config') ds@0: extensions.loadall(application.ui) ds@0: wsgicgi.launch(application) ds@0: ds@0: To enable this extension: ds@0: ds@0: [extensions] ds@0: templatepath = /path/to/templatepath.py ds@0: ''' ds@0: ds@0: import os ds@0: from mercurial import extensions, templater ds@0: ds@0: _ui = None ds@0: ds@0: def uisetup(ui): ds@0: global _ui ds@0: _ui = ui ds@0: extensions.wrapfunction(templater, 'templatepath', hook_templatepath) ds@0: ds@0: def hook_templatepath(orig, name=None): ds@0: templates = _ui.config('web', 'templates') ds@0: ds@0: if not templates: ds@0: return orig(name) ds@0: ds@0: if name: ds@0: path = os.path.join(templates, name) ds@0: if os.path.exists(path): ds@0: return os.path.normpath(path) ds@0: ds@0: return [templates]