comparison mercurial/hgweb/hgweb_mod.py @ 36518:7937850a523d

hgweb: make templater mostly compatible with log templates Prepares for gradually switching templatekw.showsuccsandmarkers() to new API. This was a PoC showing how to reuse templatekw functions in hgweb. We could remove rev, node, author, etc. from the commonentry() table, but we'll have to carefully remove all corresponding symbols from webcommands.*(). Otherwise, we would face the issue5612. Still templatekw.keywords aren't exported. Otherwise some tests would fail because the atom template expects {files} to be empty in filelog, but templatekw.showfiles() provides the {files} implementation.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 22 Dec 2017 21:59:38 +0900
parents a87093e2805d
children 2442927cdd96
comparison
equal deleted inserted replaced
36517:69477bac8926 36518:7937850a523d
25 from .request import wsgirequest 25 from .request import wsgirequest
26 26
27 from .. import ( 27 from .. import (
28 encoding, 28 encoding,
29 error, 29 error,
30 formatter,
30 hg, 31 hg,
31 hook, 32 hook,
32 profiling, 33 profiling,
33 pycompat, 34 pycompat,
34 repoview, 35 repoview,
195 196
196 def websubfilter(text): 197 def websubfilter(text):
197 return templatefilters.websub(text, self.websubtable) 198 return templatefilters.websub(text, self.websubtable)
198 199
199 # create the templater 200 # create the templater
200 201 # TODO: export all keywords: defaults = templatekw.keywords.copy()
201 defaults = { 202 defaults = {
202 'url': req.url, 203 'url': req.url,
203 'logourl': logourl, 204 'logourl': logourl,
204 'logoimg': logoimg, 205 'logoimg': logoimg,
205 'staticurl': staticurl, 206 'staticurl': staticurl,
210 'sessionvars': sessionvars, 211 'sessionvars': sessionvars,
211 'pathdef': makebreadcrumb(req.url), 212 'pathdef': makebreadcrumb(req.url),
212 'style': style, 213 'style': style,
213 'nonce': self.nonce, 214 'nonce': self.nonce,
214 } 215 }
216 tres = formatter.templateresources(self.repo.ui, self.repo)
215 tmpl = templater.templater.frommapfile(mapfile, 217 tmpl = templater.templater.frommapfile(mapfile,
216 filters={'websub': websubfilter}, 218 filters={'websub': websubfilter},
217 defaults=defaults) 219 defaults=defaults,
220 resources=tres)
218 return tmpl 221 return tmpl
219 222
220 223
221 class hgweb(object): 224 class hgweb(object):
222 """HTTP server for individual repositories. 225 """HTTP server for individual repositories.