Mercurial > hg
comparison mercurial/hgweb/hgwebdir_mod.py @ 3276:db9d2a624521
hgweb: Search templates in templatepath/style/map, too, using a common function.
This allows for web templates to be self-contained in a directory, which makes
copying and modifying them easier.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 06 Oct 2006 18:28:50 +0200 |
parents | 3207e30bf468 |
children | 415905fad4fe |
comparison
equal
deleted
inserted
replaced
3275:7ae37d99d47e | 3276:db9d2a624521 |
---|---|
9 import os | 9 import os |
10 from mercurial.demandload import demandload | 10 from mercurial.demandload import demandload |
11 demandload(globals(), "ConfigParser mimetools cStringIO") | 11 demandload(globals(), "ConfigParser mimetools cStringIO") |
12 demandload(globals(), "mercurial:ui,hg,util,templater") | 12 demandload(globals(), "mercurial:ui,hg,util,templater") |
13 demandload(globals(), "mercurial.hgweb.hgweb_mod:hgweb") | 13 demandload(globals(), "mercurial.hgweb.hgweb_mod:hgweb") |
14 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile") | 14 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile,style_map") |
15 from mercurial.i18n import gettext as _ | 15 from mercurial.i18n import gettext as _ |
16 | 16 |
17 # This is a stopgap | 17 # This is a stopgap |
18 class hgwebdir(object): | 18 class hgwebdir(object): |
19 def __init__(self, config): | 19 def __init__(self, config): |
67 yield header_file.read() | 67 yield header_file.read() |
68 | 68 |
69 def footer(**map): | 69 def footer(**map): |
70 yield tmpl("footer", motd=self.motd, **map) | 70 yield tmpl("footer", motd=self.motd, **map) |
71 | 71 |
72 m = os.path.join(templater.templatepath(), "map") | |
73 style = self.style | 72 style = self.style |
74 if req.form.has_key('style'): | 73 if req.form.has_key('style'): |
75 style = req.form['style'][0] | 74 style = req.form['style'][0] |
76 if style != "": | 75 mapfile = style_map(templater.templatepath(), style) |
77 b = os.path.basename("map-" + style) | 76 tmpl = templater.templater(mapfile, templater.common_filters, |
78 p = os.path.join(templater.templatepath(), b) | |
79 if os.path.isfile(p): | |
80 m = p | |
81 | |
82 tmpl = templater.templater(m, templater.common_filters, | |
83 defaults={"header": header, | 77 defaults={"header": header, |
84 "footer": footer}) | 78 "footer": footer}) |
85 | 79 |
86 def archivelist(ui, nodeid, url): | 80 def archivelist(ui, nodeid, url): |
87 allowed = ui.configlist("web", "allow_archive") | 81 allowed = ui.configlist("web", "allow_archive") |