comparison mercurial/hgweb/hgweb_mod.py @ 45338:c37ab438ff31

hgweb: rely on open_template()'s fallback to using templatedir() Differential Revision: https://phab.mercurial-scm.org/D8900
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 05 Aug 2020 14:03:45 -0700
parents 1b983985edd9
children 1a4f925f72c3
comparison
equal deleted inserted replaced
45337:1b983985edd9 45338:c37ab438ff31
63 1. templatepath/style/map 63 1. templatepath/style/map
64 2. templatepath/map-style 64 2. templatepath/map-style
65 3. templatepath/map 65 3. templatepath/map
66 """ 66 """
67 67
68 if path is None: 68 for style in styles:
69 path = templater.templatedir() 69 # only plain name is allowed to honor template paths
70 70 if (
71 if path is not None: 71 not style
72 for style in styles: 72 or style in (pycompat.oscurdir, pycompat.ospardir)
73 # only plain name is allowed to honor template paths 73 or pycompat.ossep in style
74 if ( 74 or pycompat.osaltsep
75 not style 75 and pycompat.osaltsep in style
76 or style in (pycompat.oscurdir, pycompat.ospardir) 76 ):
77 or pycompat.ossep in style 77 continue
78 or pycompat.osaltsep 78 locations = (os.path.join(style, b'map'), b'map-' + style, b'map')
79 and pycompat.osaltsep in style 79
80 ): 80 for location in locations:
81 continue 81 mapfile, fp = templater.open_template(location, path)
82 locations = (os.path.join(style, b'map'), b'map-' + style, b'map') 82 if mapfile:
83 83 return style, mapfile
84 for location in locations:
85 mapfile, fp = templater.open_template(location, path)
86 if mapfile:
87 return style, mapfile
88 84
89 raise RuntimeError(b"No hgweb templates found in %r" % path) 85 raise RuntimeError(b"No hgweb templates found in %r" % path)
90 86
91 87
92 def makebreadcrumb(url, prefix=b''): 88 def makebreadcrumb(url, prefix=b''):