changeset 6221:2eb18c780287

Support web.baseurl in hgwebdir, overriding SCRIPT_NAME
author Brendan Cully <brendan@kublai.com>
date Sat, 08 Mar 2008 17:19:18 -0800
parents 1939e29151ca
children d2353ed8b153
files mercurial/hgweb/hgwebdir_mod.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py	Sat Mar 08 12:40:33 2008 +0100
+++ b/mercurial/hgweb/hgwebdir_mod.py	Sat Mar 08 17:19:18 2008 -0800
@@ -28,6 +28,7 @@
         self.style = None
         self.stripecount = None
         self.repos_sorted = ('name', False)
+        self._baseurl = None
         if isinstance(config, (list, tuple)):
             self.repos = cleannames(config)
             self.repos_sorted = ('', False)
@@ -48,6 +49,8 @@
                     self.style = cp.get('web', 'style')
                 if cp.has_option('web', 'stripes'):
                     self.stripecount = int(cp.get('web', 'stripes'))
+                if cp.has_option('web', 'baseurl'):
+                    self._baseurl = cp.get('web', 'baseurl')
             if cp.has_section('paths'):
                 self.repos.extend(cleannames(cp.items('paths')))
             if cp.has_section('collections'):
@@ -233,6 +236,9 @@
                             and "-" or "", column))
                 for column in sortable]
 
+        if self._baseurl is not None:
+            req.env['SCRIPT_NAME'] = self._baseurl
+
         return tmpl("index", entries=entries, subdir=subdir,
                     sortcolumn=sortcolumn, descending=descending,
                     **dict(sort))
@@ -254,6 +260,9 @@
         def config(section, name, default=None, untrusted=True):
             return self.parentui.config(section, name, default, untrusted)
 
+        if self._baseurl is not None:
+            req.env['SCRIPT_NAME'] = self._baseurl
+
         url = req.env.get('SCRIPT_NAME', '')
         if not url.endswith('/'):
             url += '/'