mercurial/hgweb/hgwebdir_mod.py
changeset 36912 6a0e4efbc61e
parent 36911 93717f082af9
child 36913 c1de7efca574
equal deleted inserted replaced
36911:93717f082af9 36912:6a0e4efbc61e
   367             if csp:
   367             if csp:
   368                 res.headers['Content-Security-Policy'] = csp
   368                 res.headers['Content-Security-Policy'] = csp
   369                 wsgireq.headers.append(('Content-Security-Policy', csp))
   369                 wsgireq.headers.append(('Content-Security-Policy', csp))
   370 
   370 
   371             virtual = req.dispatchpath.strip('/')
   371             virtual = req.dispatchpath.strip('/')
   372             tmpl = self.templater(wsgireq, nonce)
   372             tmpl = self.templater(req, nonce)
   373             ctype = tmpl('mimetype', encoding=encoding.encoding)
   373             ctype = tmpl('mimetype', encoding=encoding.encoding)
   374             ctype = templater.stringify(ctype)
   374             ctype = templater.stringify(ctype)
   375 
   375 
   376             # Global defaults. These can be overridden by any handler.
   376             # Global defaults. These can be overridden by any handler.
   377             res.status = '200 Script output follows'
   377             res.status = '200 Script output follows'
   483             descending=descending,
   483             descending=descending,
   484             **dict(sort)))
   484             **dict(sort)))
   485 
   485 
   486         return res.sendresponse()
   486         return res.sendresponse()
   487 
   487 
   488     def templater(self, wsgireq, nonce):
   488     def templater(self, req, nonce):
   489 
   489 
   490         def motd(**map):
   490         def motd(**map):
   491             if self.motd is not None:
   491             if self.motd is not None:
   492                 yield self.motd
   492                 yield self.motd
   493             else:
   493             else:
   495 
   495 
   496         def config(section, name, default=uimod._unset, untrusted=True):
   496         def config(section, name, default=uimod._unset, untrusted=True):
   497             return self.ui.config(section, name, default, untrusted)
   497             return self.ui.config(section, name, default, untrusted)
   498 
   498 
   499         vars = {}
   499         vars = {}
   500         styles, (style, mapfile) = hgweb_mod.getstyle(wsgireq.req, config,
   500         styles, (style, mapfile) = hgweb_mod.getstyle(req, config,
   501                                                       self.templatepath)
   501                                                       self.templatepath)
   502         if style == styles[0]:
   502         if style == styles[0]:
   503             vars['style'] = style
   503             vars['style'] = style
   504 
   504 
   505         sessionvars = webutil.sessionvars(vars, r'?')
   505         sessionvars = webutil.sessionvars(vars, r'?')
   506         logourl = config('web', 'logourl')
   506         logourl = config('web', 'logourl')
   507         logoimg = config('web', 'logoimg')
   507         logoimg = config('web', 'logoimg')
   508         staticurl = (config('web', 'staticurl')
   508         staticurl = (config('web', 'staticurl')
   509                      or wsgireq.req.apppath + '/static/')
   509                      or req.apppath + '/static/')
   510         if not staticurl.endswith('/'):
   510         if not staticurl.endswith('/'):
   511             staticurl += '/'
   511             staticurl += '/'
   512 
   512 
   513         defaults = {
   513         defaults = {
   514             "encoding": encoding.encoding,
   514             "encoding": encoding.encoding,
   515             "motd": motd,
   515             "motd": motd,
   516             "url": wsgireq.req.apppath + '/',
   516             "url": req.apppath + '/',
   517             "logourl": logourl,
   517             "logourl": logourl,
   518             "logoimg": logoimg,
   518             "logoimg": logoimg,
   519             "staticurl": staticurl,
   519             "staticurl": staticurl,
   520             "sessionvars": sessionvars,
   520             "sessionvars": sessionvars,
   521             "style": style,
   521             "style": style,