78 locations = (os.path.join(style, b'map'), b'map-' + style, b'map') |
78 locations = (os.path.join(style, b'map'), b'map-' + style, b'map') |
79 |
79 |
80 for location in locations: |
80 for location in locations: |
81 mapfile, fp = templater.open_template(location, path) |
81 mapfile, fp = templater.open_template(location, path) |
82 if mapfile: |
82 if mapfile: |
83 return style, mapfile |
83 return style, mapfile, fp |
84 |
84 |
85 raise RuntimeError(b"No hgweb templates found in %r" % path) |
85 raise RuntimeError(b"No hgweb templates found in %r" % path) |
86 |
86 |
87 |
87 |
88 def makebreadcrumb(url, prefix=b''): |
88 def makebreadcrumb(url, prefix=b''): |
178 staticurl += b'/' |
178 staticurl += b'/' |
179 |
179 |
180 # figure out which style to use |
180 # figure out which style to use |
181 |
181 |
182 vars = {} |
182 vars = {} |
183 styles, (style, mapfile) = getstyle(req, self.config, self.templatepath) |
183 styles, (style, mapfile, fp) = getstyle( |
|
184 req, self.config, self.templatepath |
|
185 ) |
184 if style == styles[0]: |
186 if style == styles[0]: |
185 vars[b'style'] = style |
187 vars[b'style'] = style |
186 |
188 |
187 sessionvars = webutil.sessionvars(vars, b'?') |
189 sessionvars = webutil.sessionvars(vars, b'?') |
188 |
190 |
221 @templatekeyword(b'motd', requires=()) |
223 @templatekeyword(b'motd', requires=()) |
222 def motd(context, mapping): |
224 def motd(context, mapping): |
223 yield self.config(b'web', b'motd') |
225 yield self.config(b'web', b'motd') |
224 |
226 |
225 tres = formatter.templateresources(self.repo.ui, self.repo) |
227 tres = formatter.templateresources(self.repo.ui, self.repo) |
226 tmpl = templater.templater.frommapfile( |
228 return templater.templater.frommapfile( |
227 mapfile, filters=filters, defaults=defaults, resources=tres |
229 mapfile, fp=fp, filters=filters, defaults=defaults, resources=tres |
228 ) |
230 ) |
229 return tmpl |
|
230 |
231 |
231 def sendtemplate(self, name, **kwargs): |
232 def sendtemplate(self, name, **kwargs): |
232 """Helper function to send a response generated from a template.""" |
233 """Helper function to send a response generated from a template.""" |
233 kwargs = pycompat.byteskwargs(kwargs) |
234 kwargs = pycompat.byteskwargs(kwargs) |
234 self.res.setbodygen(self.tmpl.generate(name, kwargs)) |
235 self.res.setbodygen(self.tmpl.generate(name, kwargs)) |