hgwebdir_mod.py
466 lines
| 17.7 KiB
| text/x-python
|
PythonLexer
Eric Hopper
|
r2391 | # hgweb/hgwebdir_mod.py - Web interface for a directory of repositories. | ||
Eric Hopper
|
r2356 | # | ||
# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> | ||||
Vadim Gelfer
|
r2859 | # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> | ||
Eric Hopper
|
r2356 | # | ||
Martin Geisler
|
r8225 | # This software may be used and distributed according to the terms of the | ||
Matt Mackall
|
r10263 | # GNU General Public License version 2 or any later version. | ||
Eric Hopper
|
r2356 | |||
Brodie Rao
|
r13821 | import os, re, time | ||
Martin Geisler
|
r7225 | from mercurial.i18n import _ | ||
Adrian Buehlmann
|
r13975 | from mercurial import ui, hg, scmutil, util, templater | ||
Brodie Rao
|
r14076 | from mercurial import error, encoding | ||
Wagner Bruna
|
r19032 | from common import ErrorResponse, get_mtime, staticfile, paritygen, ismember, \ | ||
Dirkjan Ochtman
|
r5993 | get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR | ||
Angel Ezquerra <angel.ezquerra at gmail.com>
|
r18258 | from hgweb_mod import hgweb, makebreadcrumb | ||
Dirkjan Ochtman
|
r5566 | from request import wsgirequest | ||
Dirkjan Ochtman
|
r8216 | import webutil | ||
Eric Hopper
|
r2356 | |||
Dirkjan Ochtman
|
r8215 | def cleannames(items): | ||
return [(util.pconvert(name).strip('/'), path) for name, path in items] | ||||
Eric Hopper
|
r2356 | |||
Jeremy Whitlock
|
r8529 | def findrepos(paths): | ||
Dirkjan Ochtman
|
r9723 | repos = [] | ||
Jeremy Whitlock
|
r8529 | for prefix, root in cleannames(paths): | ||
roothead, roottail = os.path.split(root) | ||||
Mads Kiilerich
|
r17104 | # "foo = /bar/*" or "foo = /bar/**" lets every repo /bar/N in or below | ||
# /bar/ be served as as foo/N . | ||||
# '*' will not search inside dirs with .hg (except .hg/patches), | ||||
# '**' will search inside dirs with .hg (and thus also find subrepos). | ||||
Jeremy Whitlock
|
r8529 | try: | ||
recurse = {'*': False, '**': True}[roottail] | ||||
except KeyError: | ||||
Dirkjan Ochtman
|
r9723 | repos.append((prefix, root)) | ||
Jeremy Whitlock
|
r8529 | continue | ||
Mads Kiilerich
|
r11677 | roothead = os.path.normpath(os.path.abspath(roothead)) | ||
Adrian Buehlmann
|
r13975 | paths = scmutil.walkrepos(roothead, followsym=True, recurse=recurse) | ||
Mads Kiilerich
|
r13402 | repos.extend(urlrepos(prefix, roothead, paths)) | ||
Dirkjan Ochtman
|
r9723 | return repos | ||
Jeremy Whitlock
|
r8529 | |||
Mads Kiilerich
|
r13402 | def urlrepos(prefix, roothead, paths): | ||
"""yield url paths and filesystem paths from a list of repo paths | ||||
Patrick Mezard
|
r13538 | >>> conv = lambda seq: [(v, util.pconvert(p)) for v,p in seq] | ||
>>> conv(urlrepos('hg', '/opt', ['/opt/r', '/opt/r/r', '/opt'])) | ||||
Mads Kiilerich
|
r13403 | [('hg/r', '/opt/r'), ('hg/r/r', '/opt/r/r'), ('hg', '/opt')] | ||
Patrick Mezard
|
r13538 | >>> conv(urlrepos('', '/opt', ['/opt/r', '/opt/r/r', '/opt'])) | ||
Mads Kiilerich
|
r13402 | [('r', '/opt/r'), ('r/r', '/opt/r/r'), ('', '/opt')] | ||
""" | ||||
for path in paths: | ||||
path = os.path.normpath(path) | ||||
Mads Kiilerich
|
r13403 | yield (prefix + '/' + | ||
util.pconvert(path[len(roothead):]).lstrip('/')).strip('/'), path | ||||
Mads Kiilerich
|
r13402 | |||
Matt Mackall
|
r15003 | def geturlcgivars(baseurl, port): | ||
""" | ||||
Extract CGI variables from baseurl | ||||
>>> geturlcgivars("http://host.org/base", "80") | ||||
('host.org', '80', '/base') | ||||
>>> geturlcgivars("http://host.org:8000/base", "80") | ||||
('host.org', '8000', '/base') | ||||
>>> geturlcgivars('/base', 8000) | ||||
('', '8000', '/base') | ||||
>>> geturlcgivars("base", '8000') | ||||
('', '8000', '/base') | ||||
>>> geturlcgivars("http://host", '8000') | ||||
('host', '8000', '/') | ||||
>>> geturlcgivars("http://host/", '8000') | ||||
('host', '8000', '/') | ||||
""" | ||||
u = util.url(baseurl) | ||||
name = u.host or '' | ||||
if u.port: | ||||
port = u.port | ||||
path = u.path or "" | ||||
if not path.startswith('/'): | ||||
path = '/' + path | ||||
return name, str(port), path | ||||
Eric Hopper
|
r2356 | class hgwebdir(object): | ||
Bryan O'Sullivan
|
r8371 | refreshinterval = 20 | ||
Dirkjan Ochtman
|
r8215 | |||
Matt Mackall
|
r8191 | def __init__(self, conf, baseui=None): | ||
Bryan O'Sullivan
|
r8371 | self.conf = conf | ||
self.baseui = baseui | ||||
self.lastrefresh = 0 | ||||
Thomas Arendsen Hein
|
r9903 | self.motd = None | ||
Bryan O'Sullivan
|
r8371 | self.refresh() | ||
Eric Hopper
|
r2356 | |||
Bryan O'Sullivan
|
r8371 | def refresh(self): | ||
if self.lastrefresh + self.refreshinterval > time.time(): | ||||
return | ||||
if self.baseui: | ||||
Matt Mackall
|
r11239 | u = self.baseui.copy() | ||
Eric Hopper
|
r2356 | else: | ||
Matt Mackall
|
r12696 | u = ui.ui() | ||
Matt Mackall
|
r11239 | u.setconfig('ui', 'report_untrusted', 'off') | ||
Matt Mackall
|
r16754 | u.setconfig('ui', 'nontty', 'true') | ||
Matt Mackall
|
r8136 | |||
Jeremy Whitlock
|
r8529 | if not isinstance(self.conf, (dict, list, tuple)): | ||
map = {'paths': 'hgweb-paths'} | ||||
Matt Mackall
|
r13214 | if not os.path.exists(self.conf): | ||
raise util.Abort(_('config file %s not found!') % self.conf) | ||||
Matt Mackall
|
r11239 | u.readconfig(self.conf, remap=map, trust=True) | ||
timeless
|
r13667 | paths = [] | ||
for name, ignored in u.configitems('hgweb-paths'): | ||||
for path in u.configlist('hgweb-paths', name): | ||||
paths.append((name, path)) | ||||
Jeremy Whitlock
|
r8529 | elif isinstance(self.conf, (list, tuple)): | ||
paths = self.conf | ||||
elif isinstance(self.conf, dict): | ||||
paths = self.conf.items() | ||||
Alexander Solovyov
|
r8345 | |||
Matt Mackall
|
r11239 | repos = findrepos(paths) | ||
for prefix, root in u.configitems('collections'): | ||||
prefix = util.pconvert(prefix) | ||||
Adrian Buehlmann
|
r13975 | for path in scmutil.walkrepos(root, followsym=True): | ||
Matt Mackall
|
r11239 | repo = os.path.normpath(path) | ||
name = util.pconvert(repo) | ||||
if name.startswith(prefix): | ||||
name = name[len(prefix):] | ||||
repos.append((name.lstrip('/'), repo)) | ||||
self.repos = repos | ||||
self.ui = u | ||||
Matt Mackall
|
r8859 | encoding.encoding = self.ui.config('web', 'encoding', | ||
encoding.encoding) | ||||
Dirkjan Ochtman
|
r8621 | self.style = self.ui.config('web', 'style', 'paper') | ||
Christian Fischer
|
r11649 | self.templatepath = self.ui.config('web', 'templates', None) | ||
Dirkjan Ochtman
|
r8621 | self.stripecount = self.ui.config('web', 'stripes', 1) | ||
if self.stripecount: | ||||
self.stripecount = int(self.stripecount) | ||||
self._baseurl = self.ui.config('web', 'baseurl') | ||||
Angel Ezquerra
|
r18515 | prefix = self.ui.config('web', 'prefix', '') | ||
if prefix.startswith('/'): | ||||
prefix = prefix[1:] | ||||
if prefix.endswith('/'): | ||||
prefix = prefix[:-1] | ||||
self.prefix = prefix | ||||
Bryan O'Sullivan
|
r8371 | self.lastrefresh = time.time() | ||
Eric Hopper
|
r2356 | |||
Eric Hopper
|
r2535 | def run(self): | ||
Eric Hopper
|
r2538 | if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): | ||
Martin Geisler
|
r8663 | raise RuntimeError("This function is only intended to be " | ||
"called while running as a CGI script.") | ||||
Eric Hopper
|
r2535 | import mercurial.hgweb.wsgicgi as wsgicgi | ||
Dirkjan Ochtman
|
r5566 | wsgicgi.launch(self) | ||
def __call__(self, env, respond): | ||||
req = wsgirequest(env, respond) | ||||
Dirkjan Ochtman
|
r6797 | return self.run_wsgi(req) | ||
Eric Hopper
|
r2535 | |||
Mark Edgington
|
r7336 | def read_allowed(self, ui, req): | ||
"""Check allow_read and deny_read config options of a repo's ui object | ||||
to determine user permissions. By default, with neither option set (or | ||||
both empty), allow all users to read the repo. There are two ways a | ||||
user can be denied read access: (1) deny_read is not empty, and the | ||||
user is unauthenticated or deny_read contains user (or *), and (2) | ||||
allow_read is not empty and the user is not in allow_read. Return True | ||||
if user is allowed to read the repo, else return False.""" | ||||
user = req.env.get('REMOTE_USER') | ||||
Dirkjan Ochtman
|
r7575 | deny_read = ui.configlist('web', 'deny_read', untrusted=True) | ||
Wagner Bruna
|
r19032 | if deny_read and (not user or ismember(ui, user, deny_read)): | ||
Mark Edgington
|
r7336 | return False | ||
Dirkjan Ochtman
|
r7575 | allow_read = ui.configlist('web', 'allow_read', untrusted=True) | ||
Mark Edgington
|
r7336 | # by default, allow reading if no allow_read option has been set | ||
Wagner Bruna
|
r19032 | if (not allow_read) or ismember(ui, user, allow_read): | ||
Mark Edgington
|
r7336 | return True | ||
return False | ||||
Eric Hopper
|
r2535 | def run_wsgi(self, req): | ||
Dirkjan Ochtman
|
r5601 | try: | ||
try: | ||||
Bryan O'Sullivan
|
r8371 | self.refresh() | ||
Dirkjan Ochtman
|
r5603 | |||
Dirkjan Ochtman
|
r5601 | virtual = req.env.get("PATH_INFO", "").strip('/') | ||
Dirkjan Ochtman
|
r5993 | tmpl = self.templater(req) | ||
Matt Mackall
|
r7948 | ctype = tmpl('mimetype', encoding=encoding.encoding) | ||
Dirkjan Ochtman
|
r6391 | ctype = templater.stringify(ctype) | ||
Thomas Arendsen Hein
|
r5760 | |||
Dirkjan Ochtman
|
r5603 | # a static file | ||
if virtual.startswith('static/') or 'static' in req.form: | ||||
if virtual.startswith('static/'): | ||||
fname = virtual[7:] | ||||
else: | ||||
fname = req.form['static'][0] | ||||
Matt Mackall
|
r18191 | static = self.ui.config("web", "static", None, | ||
untrusted=False) | ||||
if not static: | ||||
tp = self.templatepath or templater.templatepath() | ||||
if isinstance(tp, str): | ||||
tp = [tp] | ||||
static = [os.path.join(p, 'static') for p in tp] | ||||
Mads Kiilerich
|
r18645 | staticfile(static, fname, req) | ||
return [] | ||||
Dirkjan Ochtman
|
r5603 | |||
# top-level index | ||||
elif not virtual: | ||||
Dirkjan Ochtman
|
r5993 | req.respond(HTTP_OK, ctype) | ||
Brendan Cully
|
r7396 | return self.makeindex(req, tmpl) | ||
Dirkjan Ochtman
|
r5601 | |||
Dirkjan Ochtman
|
r5603 | # nested indexes and hgwebs | ||
Thomas Arendsen Hein
|
r6210 | |||
Dirkjan Ochtman
|
r5603 | repos = dict(self.repos) | ||
Wagner Bruna
|
r13066 | virtualrepo = virtual | ||
while virtualrepo: | ||||
real = repos.get(virtualrepo) | ||||
Dirkjan Ochtman
|
r5603 | if real: | ||
Wagner Bruna
|
r13066 | req.env['REPO_NAME'] = virtualrepo | ||
Dirkjan Ochtman
|
r5603 | try: | ||
Matt Mackall
|
r8191 | repo = hg.repository(self.ui, real) | ||
Dirkjan Ochtman
|
r6797 | return hgweb(repo).run_wsgi(req) | ||
Dirkjan Ochtman
|
r5603 | except IOError, inst: | ||
Dirkjan Ochtman
|
r5993 | msg = inst.strerror | ||
raise ErrorResponse(HTTP_SERVER_ERROR, msg) | ||||
Matt Mackall
|
r7637 | except error.RepoError, inst: | ||
Dirkjan Ochtman
|
r5993 | raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) | ||
Dirkjan Ochtman
|
r5601 | |||
Wagner Bruna
|
r13066 | up = virtualrepo.rfind('/') | ||
Dirkjan Ochtman
|
r5603 | if up < 0: | ||
break | ||||
Wagner Bruna
|
r13066 | virtualrepo = virtualrepo[:up] | ||
# browse subdirectories | ||||
subdir = virtual + '/' | ||||
if [r for r in repos if r.startswith(subdir)]: | ||||
req.respond(HTTP_OK, ctype) | ||||
return self.makeindex(req, tmpl, subdir) | ||||
Dirkjan Ochtman
|
r5603 | |||
# prefixes not found | ||||
Dirkjan Ochtman
|
r5993 | req.respond(HTTP_NOT_FOUND, ctype) | ||
Brendan Cully
|
r7396 | return tmpl("notfound", repo=virtual) | ||
Thomas Arendsen Hein
|
r5760 | |||
Dirkjan Ochtman
|
r5601 | except ErrorResponse, err: | ||
Dirkjan Ochtman
|
r7740 | req.respond(err, ctype) | ||
Brendan Cully
|
r7396 | return tmpl('error', error=err.message or '') | ||
Dirkjan Ochtman
|
r5601 | finally: | ||
tmpl = None | ||||
def makeindex(self, req, tmpl, subdir=""): | ||||
Eric Hopper
|
r2356 | def archivelist(ui, nodeid, url): | ||
Alexis S. L. Carvalho
|
r3556 | allowed = ui.configlist("web", "allow_archive", untrusted=True) | ||
Wagner Bruna
|
r13436 | archives = [] | ||
Brendan Cully
|
r3262 | for i in [('zip', '.zip'), ('gz', '.tar.gz'), ('bz2', '.tar.bz2')]: | ||
Alexis S. L. Carvalho
|
r3556 | if i[0] in allowed or ui.configbool("web", "allow" + i[0], | ||
untrusted=True): | ||||
Wagner Bruna
|
r13436 | archives.append({"type" : i[0], "extension": i[1], | ||
"node": nodeid, "url": url}) | ||||
return archives | ||||
Eric Hopper
|
r2356 | |||
Benoit Boissinot
|
r10600 | def rawentries(subdir="", **map): | ||
Dirkjan Ochtman
|
r9363 | |||
descend = self.ui.configbool('web', 'descend', True) | ||||
Paul Boddie
|
r16239 | collapse = self.ui.configbool('web', 'collapse', False) | ||
seenrepos = set() | ||||
seendirs = set() | ||||
Eric Hopper
|
r2356 | for name, path in self.repos: | ||
Dirkjan Ochtman
|
r9363 | |||
Brendan Cully
|
r4841 | if not name.startswith(subdir): | ||
continue | ||||
Brendan Cully
|
r4843 | name = name[len(subdir):] | ||
Paul Boddie
|
r16239 | directory = False | ||
if '/' in name: | ||||
if not descend: | ||||
continue | ||||
nameparts = name.split('/') | ||||
rootname = nameparts[0] | ||||
if not collapse: | ||||
pass | ||||
elif rootname in seendirs: | ||||
continue | ||||
elif rootname in seenrepos: | ||||
pass | ||||
else: | ||||
directory = True | ||||
name = rootname | ||||
# redefine the path to refer to the directory | ||||
discarded = '/'.join(nameparts[1:]) | ||||
# remove name parts plus accompanying slash | ||||
path = path[:-len(discarded) - 1] | ||||
parts = [name] | ||||
if 'PATH_INFO' in req.env: | ||||
parts.insert(0, req.env['PATH_INFO'].rstrip('/')) | ||||
if req.env['SCRIPT_NAME']: | ||||
parts.insert(0, req.env['SCRIPT_NAME']) | ||||
url = re.sub(r'/+', '/', '/'.join(parts) + '/') | ||||
# show either a directory entry or a repository | ||||
if directory: | ||||
# get the directory's time information | ||||
try: | ||||
d = (get_mtime(path), util.makedate()[1]) | ||||
except OSError: | ||||
continue | ||||
Angel Ezquerra
|
r17838 | # add '/' to the name to make it obvious that | ||
# the entry is a directory, not a regular repository | ||||
Paul Boddie
|
r16239 | row = dict(contact="", | ||
contact_sort="", | ||||
Angel Ezquerra
|
r17838 | name=name + '/', | ||
Paul Boddie
|
r16239 | name_sort=name, | ||
url=url, | ||||
description="", | ||||
description_sort="", | ||||
lastchange=d, | ||||
lastchange_sort=d[1]-d[0], | ||||
Angel Ezquerra
|
r18046 | archives=[], | ||
isdirectory=True) | ||||
Paul Boddie
|
r16239 | |||
seendirs.add(name) | ||||
yield row | ||||
Dirkjan Ochtman
|
r9363 | continue | ||
Brendan Cully
|
r4841 | |||
Matt Mackall
|
r8191 | u = self.ui.copy() | ||
Eric Hopper
|
r2356 | try: | ||
u.readconfig(os.path.join(path, '.hg', 'hgrc')) | ||||
Alexis S. L. Carvalho
|
r5332 | except Exception, e: | ||
Martin Geisler
|
r6913 | u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e)) | ||
Alexis S. L. Carvalho
|
r5332 | continue | ||
Alexis S. L. Carvalho
|
r3556 | def get(section, name, default=None): | ||
return u.config(section, name, default, untrusted=True) | ||||
Eric Hopper
|
r2356 | |||
Markus F.X.J. Oberhumer
|
r4709 | if u.configbool("web", "hidden", untrusted=True): | ||
continue | ||||
Mark Edgington
|
r7336 | if not self.read_allowed(u, req): | ||
continue | ||||
Eric Hopper
|
r2356 | # update time with local timezone | ||
try: | ||||
Brendan Cully
|
r10078 | r = hg.repository(self.ui, path) | ||
timeless@gmail.com
|
r13796 | except IOError: | ||
u.warn(_('error accessing repository at %s\n') % path) | ||||
continue | ||||
Yuya Nishihara
|
r12038 | except error.RepoError: | ||
u.warn(_('error accessing repository at %s\n') % path) | ||||
continue | ||||
try: | ||||
Brendan Cully
|
r10078 | d = (get_mtime(r.spath), util.makedate()[1]) | ||
Eric Hopper
|
r2356 | except OSError: | ||
continue | ||||
Thomas Arendsen Hein
|
r5779 | contact = get_contact(get) | ||
Eric Hopper
|
r2356 | description = get("web", "description", "") | ||
name = get("web", "name", name) | ||||
row = dict(contact=contact or "unknown", | ||||
contact_sort=contact.upper() or "unknown", | ||||
name=name, | ||||
name_sort=name, | ||||
url=url, | ||||
description=description or "unknown", | ||||
description_sort=description.upper() or "unknown", | ||||
lastchange=d, | ||||
lastchange_sort=d[1]-d[0], | ||||
archives=archivelist(u, "tip", url)) | ||||
Paul Boddie
|
r16239 | |||
seenrepos.add(name) | ||||
Benoit Boissinot
|
r10600 | yield row | ||
sortdefault = None, False | ||||
def entries(sortcolumn="", descending=False, subdir="", **map): | ||||
rows = rawentries(subdir=subdir, **map) | ||||
if sortcolumn and sortdefault != (sortcolumn, descending): | ||||
sortkey = '%s_sort' % sortcolumn | ||||
rows = sorted(rows, key=lambda x: x[sortkey], | ||||
reverse=descending) | ||||
for row, parity in zip(rows, paritygen(self.stripecount)): | ||||
row['parity'] = parity | ||||
yield row | ||||
Eric Hopper
|
r2356 | |||
Bryan O'Sullivan
|
r8371 | self.refresh() | ||
Dirkjan Ochtman
|
r5601 | sortable = ["name", "description", "contact", "lastchange"] | ||
Dirkjan Ochtman
|
r8346 | sortcolumn, descending = sortdefault | ||
Christian Ebert
|
r5915 | if 'sort' in req.form: | ||
Dirkjan Ochtman
|
r5601 | sortcolumn = req.form['sort'][0] | ||
descending = sortcolumn.startswith('-') | ||||
if descending: | ||||
sortcolumn = sortcolumn[1:] | ||||
if sortcolumn not in sortable: | ||||
sortcolumn = "" | ||||
Brendan Cully
|
r4841 | |||
Dirkjan Ochtman
|
r5601 | sort = [("sort_%s" % column, | ||
"%s%s" % ((not descending and column == sortcolumn) | ||||
and "-" or "", column)) | ||||
for column in sortable] | ||||
Dirkjan Ochtman
|
r5928 | |||
Bryan O'Sullivan
|
r8371 | self.refresh() | ||
Yuya Nishihara
|
r10673 | self.updatereqenv(req.env) | ||
Brendan Cully
|
r6221 | |||
Dirkjan Ochtman
|
r5965 | return tmpl("index", entries=entries, subdir=subdir, | ||
Angel Ezquerra
|
r18515 | pathdef=makebreadcrumb('/' + subdir, self.prefix), | ||
Dirkjan Ochtman
|
r5965 | sortcolumn=sortcolumn, descending=descending, | ||
**dict(sort)) | ||||
Dirkjan Ochtman
|
r5602 | |||
def templater(self, req): | ||||
def header(**map): | ||||
Matt Mackall
|
r7948 | yield tmpl('header', encoding=encoding.encoding, **map) | ||
Dirkjan Ochtman
|
r5602 | |||
def footer(**map): | ||||
yield tmpl("footer", **map) | ||||
def motd(**map): | ||||
if self.motd is not None: | ||||
yield self.motd | ||||
else: | ||||
yield config('web', 'motd', '') | ||||
def config(section, name, default=None, untrusted=True): | ||||
Matt Mackall
|
r8191 | return self.ui.config(section, name, default, untrusted) | ||
Dirkjan Ochtman
|
r5602 | |||
Yuya Nishihara
|
r10673 | self.updatereqenv(req.env) | ||
Brendan Cully
|
r6221 | |||
Dirkjan Ochtman
|
r5602 | url = req.env.get('SCRIPT_NAME', '') | ||
if not url.endswith('/'): | ||||
url += '/' | ||||
Dirkjan Ochtman
|
r8216 | vars = {} | ||
Dirkjan Ochtman
|
r9842 | styles = ( | ||
req.form.get('style', [None])[0], | ||||
config('web', 'style'), | ||||
'paper' | ||||
) | ||||
Christian Fischer
|
r11649 | style, mapfile = templater.stylemap(styles, self.templatepath) | ||
Dirkjan Ochtman
|
r9842 | if style == styles[0]: | ||
vars['style'] = style | ||||
Matt Mackall
|
r10282 | |||
Dirkjan Ochtman
|
r8216 | start = url[-1] == '?' and '&' or '?' | ||
sessionvars = webutil.sessionvars(vars, start) | ||||
Steven Stallion
|
r13964 | logourl = config('web', 'logourl', 'http://mercurial.selenic.com/') | ||
Angel Ezquerra
|
r14913 | logoimg = config('web', 'logoimg', 'hglogo.png') | ||
Dirkjan Ochtman
|
r5602 | staticurl = config('web', 'staticurl') or url + 'static/' | ||
if not staticurl.endswith('/'): | ||||
staticurl += '/' | ||||
Dirkjan Ochtman
|
r8360 | tmpl = templater.templater(mapfile, | ||
Dirkjan Ochtman
|
r5602 | defaults={"header": header, | ||
"footer": footer, | ||||
"motd": motd, | ||||
"url": url, | ||||
Steven Stallion
|
r13964 | "logourl": logourl, | ||
Angel Ezquerra
|
r14913 | "logoimg": logoimg, | ||
Dirkjan Ochtman
|
r8216 | "staticurl": staticurl, | ||
"sessionvars": sessionvars}) | ||||
Dirkjan Ochtman
|
r5602 | return tmpl | ||
Yuya Nishihara
|
r10673 | |||
def updatereqenv(self, env): | ||||
if self._baseurl is not None: | ||||
Matt Mackall
|
r15003 | name, port, path = geturlcgivars(self._baseurl, env['SERVER_PORT']) | ||
env['SERVER_NAME'] = name | ||||
env['SERVER_PORT'] = port | ||||
wujek
|
r15001 | env['SCRIPT_NAME'] = path | ||