Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/common.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 | f045b049a704 |
children | c0b449154a90 |
line wrap: on
line diff
--- a/mercurial/hgweb/common.py Fri Oct 06 16:24:14 2006 +0200 +++ b/mercurial/hgweb/common.py Fri Oct 06 18:28:50 2006 +0200 @@ -42,3 +42,20 @@ except (TypeError, OSError): # illegal fname or unreadable file return "" + +def style_map(templatepath, style): + """Return path to mapfile for a given style. + + Searches mapfile in the following locations: + 1. templatepath/style/map + 2. templatepath/map-style + 3. templatepath/map + """ + locations = style and [os.path.join(style, "map"), "map-"+style] or [] + locations.append("map") + for location in locations: + mapfile = os.path.join(templatepath, location) + if os.path.isfile(mapfile): + return mapfile + raise RuntimeError("No hgweb templates found in %r" % templatepath) +