diff mercurial/hgweb/hgweb_mod.py @ 3275: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 e0cd1b98bf8d
children 98ec107ce723
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -14,7 +14,7 @@ demandload(globals(), "re zlib ConfigPar
 demandload(globals(), 'urllib')
 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,streamclone,patch")
 demandload(globals(), "mercurial:templater")
-demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile")
+demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile,style_map")
 from mercurial.node import *
 from mercurial.i18n import gettext as _
 
@@ -743,15 +743,10 @@ class hgweb(object):
         expand_form(req.form)
         rewrite_request(req)
 
-        m = os.path.join(self.templatepath, "map")
         style = self.repo.ui.config("web", "style", "")
         if req.form.has_key('style'):
             style = req.form['style'][0]
-        if style:
-            b = os.path.basename("map-" + style)
-            p = os.path.join(self.templatepath, b)
-            if os.path.isfile(p):
-                m = p
+        mapfile = style_map(self.templatepath, style)
 
         if not req.url:
             port = req.env["SERVER_PORT"]
@@ -766,7 +761,7 @@ class hgweb(object):
                              or req.env.get('REPO_NAME')
                              or req.url.strip('/') or self.repo.root)
 
-        self.t = templater.templater(m, templater.common_filters,
+        self.t = templater.templater(mapfile, templater.common_filters,
                                      defaults={"url": req.url,
                                                "repo": self.reponame,
                                                "header": header,