changeset 4867:8be7ba425621

Make {urlbase} work in templates when https is used.
author Wesley J. Landaker <wjl@icecavern.net>
date Tue, 10 Jul 2007 10:54:54 -0600
parents 1f3742217a76
children 192cd95c2ba8
files mercurial/hgweb/hgweb_mod.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Wed Jul 11 00:53:44 2007 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Tue Jul 10 10:54:54 2007 -0600
@@ -787,9 +787,16 @@
             style = req.form['style'][0]
         mapfile = style_map(self.templatepath, style)
 
+        if req.env.get('HTTPS'):
+            proto = 'https'
+            default_port = "443"
+        else:
+            proto = 'http'
+            default_port = "80"
+
         port = req.env["SERVER_PORT"]
-        port = port != "80" and (":" + port) or ""
-        urlbase = 'http://%s%s' % (req.env['SERVER_NAME'], port)
+        port = port != default_port and (":" + port) or ""
+        urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
         staticurl = self.config("web", "staticurl") or req.url + 'static/'
         if not staticurl.endswith('/'):
             staticurl += '/'