##// END OF EJS Templates
hgweb: use registrar to add "motd" template keyword...
Yuya Nishihara -
r38964:4167437a default
parent child Browse files
Show More
@@ -140,11 +140,6 b' class requestcontext(object):'
140 if not staticurl.endswith('/'):
140 if not staticurl.endswith('/'):
141 staticurl += '/'
141 staticurl += '/'
142
142
143 # some functions for the templater
144
145 def motd(**map):
146 yield self.config('web', 'motd')
147
148 # figure out which style to use
143 # figure out which style to use
149
144
150 vars = {}
145 vars = {}
@@ -177,12 +172,16 b' class requestcontext(object):'
177 'urlbase': req.advertisedbaseurl,
172 'urlbase': req.advertisedbaseurl,
178 'repo': self.reponame,
173 'repo': self.reponame,
179 'encoding': encoding.encoding,
174 'encoding': encoding.encoding,
180 'motd': motd,
181 'sessionvars': sessionvars,
175 'sessionvars': sessionvars,
182 'pathdef': makebreadcrumb(req.apppath),
176 'pathdef': makebreadcrumb(req.apppath),
183 'style': style,
177 'style': style,
184 'nonce': self.nonce,
178 'nonce': self.nonce,
185 }
179 }
180 templatekeyword = registrar.templatekeyword(defaults)
181 @templatekeyword('motd', requires=())
182 def motd(context, mapping):
183 yield self.config('web', 'motd')
184
186 tres = formatter.templateresources(self.repo.ui, self.repo)
185 tres = formatter.templateresources(self.repo.ui, self.repo)
187 tmpl = templater.templater.frommapfile(mapfile,
186 tmpl = templater.templater.frommapfile(mapfile,
188 filters=filters,
187 filters=filters,
@@ -33,6 +33,7 b' from .. import ('
33 hg,
33 hg,
34 profiling,
34 profiling,
35 pycompat,
35 pycompat,
36 registrar,
36 scmutil,
37 scmutil,
37 templater,
38 templater,
38 templateutil,
39 templateutil,
@@ -495,12 +496,6 b' class hgwebdir(object):'
495
496
496 def templater(self, req, nonce):
497 def templater(self, req, nonce):
497
498
498 def motd(**map):
499 if self.motd is not None:
500 yield self.motd
501 else:
502 yield config('web', 'motd')
503
504 def config(section, name, default=uimod._unset, untrusted=True):
499 def config(section, name, default=uimod._unset, untrusted=True):
505 return self.ui.config(section, name, default, untrusted)
500 return self.ui.config(section, name, default, untrusted)
506
501
@@ -520,7 +515,6 b' class hgwebdir(object):'
520
515
521 defaults = {
516 defaults = {
522 "encoding": encoding.encoding,
517 "encoding": encoding.encoding,
523 "motd": motd,
524 "url": req.apppath + '/',
518 "url": req.apppath + '/',
525 "logourl": logourl,
519 "logourl": logourl,
526 "logoimg": logoimg,
520 "logoimg": logoimg,
@@ -529,5 +523,13 b' class hgwebdir(object):'
529 "style": style,
523 "style": style,
530 "nonce": nonce,
524 "nonce": nonce,
531 }
525 }
526 templatekeyword = registrar.templatekeyword(defaults)
527 @templatekeyword('motd', requires=())
528 def motd(context, mapping):
529 if self.motd is not None:
530 yield self.motd
531 else:
532 yield config('web', 'motd')
533
532 tmpl = templater.templater.frommapfile(mapfile, defaults=defaults)
534 tmpl = templater.templater.frommapfile(mapfile, defaults=defaults)
533 return tmpl
535 return tmpl
General Comments 0
You need to be logged in to leave comments. Login now