51 styles = ( |
51 styles = ( |
52 req.qsparams.get(b'style', None), |
52 req.qsparams.get(b'style', None), |
53 configfn(b'web', b'style'), |
53 configfn(b'web', b'style'), |
54 b'paper', |
54 b'paper', |
55 ) |
55 ) |
56 return styles, templater.stylemap(styles, templatepath) |
56 return styles, _stylemap(styles, templatepath) |
|
57 |
|
58 |
|
59 def _stylemap(styles, path=None): |
|
60 """Return path to mapfile for a given style. |
|
61 |
|
62 Searches mapfile in the following locations: |
|
63 1. templatepath/style/map |
|
64 2. templatepath/map-style |
|
65 3. templatepath/map |
|
66 """ |
|
67 |
|
68 if path is None: |
|
69 path = templater.templatedir() |
|
70 |
|
71 if path is not None: |
|
72 for style in styles: |
|
73 # only plain name is allowed to honor template paths |
|
74 if ( |
|
75 not style |
|
76 or style in (pycompat.oscurdir, pycompat.ospardir) |
|
77 or pycompat.ossep in style |
|
78 or pycompat.osaltsep |
|
79 and pycompat.osaltsep in style |
|
80 ): |
|
81 continue |
|
82 locations = [os.path.join(style, b'map'), b'map-' + style] |
|
83 locations.append(b'map') |
|
84 |
|
85 for location in locations: |
|
86 mapfile = os.path.join(path, location) |
|
87 if os.path.isfile(mapfile): |
|
88 return style, mapfile |
|
89 |
|
90 raise RuntimeError(b"No hgweb templates found in %r" % path) |
57 |
91 |
58 |
92 |
59 def makebreadcrumb(url, prefix=b''): |
93 def makebreadcrumb(url, prefix=b''): |
60 '''Return a 'URL breadcrumb' list |
94 '''Return a 'URL breadcrumb' list |
61 |
95 |