Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
3275:7ae37d99d47e | 3276:db9d2a624521 |
---|---|
40 ('Content-length', os.path.getsize(path))]) | 40 ('Content-length', os.path.getsize(path))]) |
41 return file(path, 'rb').read() | 41 return file(path, 'rb').read() |
42 except (TypeError, OSError): | 42 except (TypeError, OSError): |
43 # illegal fname or unreadable file | 43 # illegal fname or unreadable file |
44 return "" | 44 return "" |
45 | |
46 def style_map(templatepath, style): | |
47 """Return path to mapfile for a given style. | |
48 | |
49 Searches mapfile in the following locations: | |
50 1. templatepath/style/map | |
51 2. templatepath/map-style | |
52 3. templatepath/map | |
53 """ | |
54 locations = style and [os.path.join(style, "map"), "map-"+style] or [] | |
55 locations.append("map") | |
56 for location in locations: | |
57 mapfile = os.path.join(templatepath, location) | |
58 if os.path.isfile(mapfile): | |
59 return mapfile | |
60 raise RuntimeError("No hgweb templates found in %r" % templatepath) | |
61 |