Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgwebdir_mod.py @ 28954:f97a0bcfd7a1
templater: separate function to create templater from map file (API)
New frommapfile() function will make it clear when template aliases will be
loaded. They should be applied to command arguments and templates in hgrc,
but not to map files. Otherwise, our stock styles and web templates
(i.e map-file templates) could be modified unintentionally.
Future patches will add "aliases" argument to __init__(), but not to
frommapfile().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 03 Apr 2016 23:26:48 +0900 |
parents | 37fcfe52c68c |
children | c4fc33c477da |
comparison
equal
deleted
inserted
replaced
28953:7f6b8ec691e3 | 28954:f97a0bcfd7a1 |
---|---|
489 logoimg = config('web', 'logoimg', 'hglogo.png') | 489 logoimg = config('web', 'logoimg', 'hglogo.png') |
490 staticurl = config('web', 'staticurl') or url + 'static/' | 490 staticurl = config('web', 'staticurl') or url + 'static/' |
491 if not staticurl.endswith('/'): | 491 if not staticurl.endswith('/'): |
492 staticurl += '/' | 492 staticurl += '/' |
493 | 493 |
494 tmpl = templater.templater(mapfile, | 494 defaults = { |
495 defaults={"encoding": encoding.encoding, | 495 "encoding": encoding.encoding, |
496 "motd": motd, | 496 "motd": motd, |
497 "url": url, | 497 "url": url, |
498 "logourl": logourl, | 498 "logourl": logourl, |
499 "logoimg": logoimg, | 499 "logoimg": logoimg, |
500 "staticurl": staticurl, | 500 "staticurl": staticurl, |
501 "sessionvars": sessionvars, | 501 "sessionvars": sessionvars, |
502 "style": style, | 502 "style": style, |
503 }) | 503 } |
504 tmpl = templater.templater.frommapfile(mapfile, defaults=defaults) | |
504 return tmpl | 505 return tmpl |
505 | 506 |
506 def updatereqenv(self, env): | 507 def updatereqenv(self, env): |
507 if self._baseurl is not None: | 508 if self._baseurl is not None: |
508 name, port, path = geturlcgivars(self._baseurl, env['SERVER_PORT']) | 509 name, port, path = geturlcgivars(self._baseurl, env['SERVER_PORT']) |