comparison mercurial/hgweb/common.py @ 7107:125c8fedcbe0

Allow hgweb to search for templates in more than one path. This patch is constructed to make it easy for external extensions to provide their own templates, by updating templater.path.
author Brendan Cully <brendan@kublai.com>
date Fri, 17 Oct 2008 11:34:31 -0700
parents b84d27386285
children 9c399c53469d
comparison
equal deleted inserted replaced
7106:4674706b5b95 7107:125c8fedcbe0
80 2. templatepath/map-style 80 2. templatepath/map-style
81 3. templatepath/map 81 3. templatepath/map
82 """ 82 """
83 locations = style and [os.path.join(style, "map"), "map-"+style] or [] 83 locations = style and [os.path.join(style, "map"), "map-"+style] or []
84 locations.append("map") 84 locations.append("map")
85 for location in locations: 85 if isinstance(templatepath, str):
86 mapfile = os.path.join(templatepath, location) 86 templatepath = [templatepath]
87 if os.path.isfile(mapfile): 87 for path in templatepath:
88 return mapfile 88 for location in locations:
89 mapfile = os.path.join(path, location)
90 if os.path.isfile(mapfile):
91 return mapfile
89 raise RuntimeError("No hgweb templates found in %r" % templatepath) 92 raise RuntimeError("No hgweb templates found in %r" % templatepath)
90 93
91 def paritygen(stripecount, offset=0): 94 def paritygen(stripecount, offset=0):
92 """count parity of horizontal stripes for easier reading""" 95 """count parity of horizontal stripes for easier reading"""
93 if stripecount and offset: 96 if stripecount and offset: