mercurial/hgweb/hgweb_mod.py
changeset 7966 aa983c3d94a9
parent 7948 de377b1a9a84
child 8136 6b5522cb2ad2
equal deleted inserted replaced
7965:8503adbd9d49 7966:aa983c3d94a9
     7 # of the GNU General Public License, incorporated herein by reference.
     7 # of the GNU General Public License, incorporated herein by reference.
     8 
     8 
     9 import os
     9 import os
    10 from mercurial import ui, hg, util, hook, error, encoding
    10 from mercurial import ui, hg, util, hook, error, encoding
    11 from mercurial import templater, templatefilters
    11 from mercurial import templater, templatefilters
    12 from common import get_mtime, style_map, ErrorResponse
    12 from common import get_mtime, ErrorResponse
    13 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
    13 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
    14 from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED
    14 from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED
    15 from request import wsgirequest
    15 from request import wsgirequest
    16 import webcommands, protocol, webutil
    16 import webcommands, protocol, webutil
    17 
    17 
    35         self.reponame = name
    35         self.reponame = name
    36         self.archives = 'zip', 'gz', 'bz2'
    36         self.archives = 'zip', 'gz', 'bz2'
    37         self.stripecount = 1
    37         self.stripecount = 1
    38         # a repo owner may set web.templates in .hg/hgrc to get any file
    38         # a repo owner may set web.templates in .hg/hgrc to get any file
    39         # readable by the user running the CGI script
    39         # readable by the user running the CGI script
    40         self.templatepath = self.config("web", "templates",
    40         self.templatepath = self.config('web', 'templates')
    41                                         templater.templatepath(),
       
    42                                         untrusted=False)
       
    43 
    41 
    44     # The CGI scripts are often run by a user different from the repo owner.
    42     # The CGI scripts are often run by a user different from the repo owner.
    45     # Trust the settings from the .hg/hgrc files by default.
    43     # Trust the settings from the .hg/hgrc files by default.
    46     def config(self, section, name, default=None, untrusted=True):
    44     def config(self, section, name, default=None, untrusted=True):
    47         return self.repo.ui.config(section, name, default,
    45         return self.repo.ui.config(section, name, default,
   235             style = req.form['style'][0]
   233             style = req.form['style'][0]
   236             vars['style'] = style
   234             vars['style'] = style
   237 
   235 
   238         start = req.url[-1] == '?' and '&' or '?'
   236         start = req.url[-1] == '?' and '&' or '?'
   239         sessionvars = webutil.sessionvars(vars, start)
   237         sessionvars = webutil.sessionvars(vars, start)
   240         mapfile = style_map(self.templatepath, style)
   238         mapfile = templater.stylemap(style, self.templatepath)
   241 
   239 
   242         if not self.reponame:
   240         if not self.reponame:
   243             self.reponame = (self.config("web", "name")
   241             self.reponame = (self.config("web", "name")
   244                              or req.env.get('REPO_NAME')
   242                              or req.env.get('REPO_NAME')
   245                              or req.url.strip('/') or self.repo.root)
   243                              or req.url.strip('/') or self.repo.root)