[PATCH 5 of 7] Use {baseurl} instead of {urlbase} in templates

Wesley J. Landaker wjl at icecavern.net
Thu Jul 12 20:48:49 UTC 2007


# HG changeset patch
# User Wesley J. Landaker <wjl at icecavern.net>
# Date 1184271590 21600
# Node ID eea41aa2b6d88d8cc7e60faa9289044eb5c79878
# Parent  91331b1128e2d59e256e4f6bf8aace4a2ef518e8
Use {baseurl} instead of {urlbase} in templates.

Renamed the {urlbase} template variable to {baseurl}, because this
matches the [web]/baseurl setting that currently exists for exactly
this kind of thing.

For backwards compatibility, {urlbase} still works, but it might be
better to just remove it, since the only place it is used in mercurial
is the RSS templates, and these have been updated in this patch as well.
The main concern would be external users with their own templates, so
I tried to err on the safe side, although it's also annoying to introduce
a backwards compatibility feature for something that was undocumented and
might cause future confusion.

diff -r 91331b1128e2 -r eea41aa2b6d8 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Thu Jul 12 14:14:57 2007 -0600
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Jul 12 14:19:50 2007 -0600
@@ -787,8 +787,8 @@ class hgweb(object):
             style = req.form['style'][0]
         mapfile = style_map(self.templatepath, style)
 
-        urlbase = self.ui.config('web', 'baseurl')
-        if not urlbase:
+        baseurl = self.ui.config('web', 'baseurl')
+        if not baseurl:
             proto = req.env.get['wsgi.url_scheme']
             if proto == 'https':
                 default_port = "443"
@@ -797,7 +797,7 @@ class hgweb(object):
 
             port = req.env["SERVER_PORT"]
             port = port != default_port and (":" + port) or ""
-            urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
+            baseurl = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
             
         staticurl = self.config("web", "staticurl") or req.url + 'static/'
         if not staticurl.endswith('/'):
@@ -811,7 +811,8 @@ class hgweb(object):
         self.t = templater.templater(mapfile, templater.common_filters,
                                      defaults={"url": req.url,
                                                "staticurl": staticurl,
-                                               "urlbase": urlbase,
+                                               "urlbase": baseurl,
+                                               "baseurl": baseurl,
                                                "repo": self.reponame,
                                                "header": header,
                                                "footer": footer,
diff -r 91331b1128e2 -r eea41aa2b6d8 templates/rss/changelogentry.tmpl
--- a/templates/rss/changelogentry.tmpl	Thu Jul 12 14:14:57 2007 -0600
+++ b/templates/rss/changelogentry.tmpl	Thu Jul 12 14:19:50 2007 -0600
@@ -1,6 +1,6 @@
 <item>
     <title>#desc|strip|firstline|strip|escape#</title>
-    <link>{urlbase}{url}rev/{node|short}</link>
+    <link>{baseurl}{url}rev/{node|short}</link>
     <description><![CDATA[#desc|strip|escape|addbreaks#]]></description>
     <author>#author|obfuscate#</author>
     <pubDate>#date|rfc822date#</pubDate>
diff -r 91331b1128e2 -r eea41aa2b6d8 templates/rss/filelogentry.tmpl
--- a/templates/rss/filelogentry.tmpl	Thu Jul 12 14:14:57 2007 -0600
+++ b/templates/rss/filelogentry.tmpl	Thu Jul 12 14:19:50 2007 -0600
@@ -1,6 +1,6 @@
 <item>
     <title>#desc|strip|firstline|strip|escape#</title>
-    <link>{urlbase}{url}log{#node|short#}/{file|urlescape}</link>
+    <link>{baseurl}{url}log{#node|short#}/{file|urlescape}</link>
     <description><![CDATA[#desc|strip|escape|addbreaks#]]></description>
     <author>#author|obfuscate#</author>
     <pubDate>#date|rfc822date#</pubDate>
diff -r 91331b1128e2 -r eea41aa2b6d8 templates/rss/header.tmpl
--- a/templates/rss/header.tmpl	Thu Jul 12 14:14:57 2007 -0600
+++ b/templates/rss/header.tmpl	Thu Jul 12 14:19:50 2007 -0600
@@ -3,5 +3,5 @@ Content-type: text/xml; charset={encodin
 <?xml version="1.0" encoding="{encoding}"?>
 <rss version="2.0">
   <channel>
-    <link>{urlbase}{url}</link>
+    <link>{baseurl}{url}</link>
     <language>en-us</language>
diff -r 91331b1128e2 -r eea41aa2b6d8 templates/rss/tagentry.tmpl
--- a/templates/rss/tagentry.tmpl	Thu Jul 12 14:14:57 2007 -0600
+++ b/templates/rss/tagentry.tmpl	Thu Jul 12 14:19:50 2007 -0600
@@ -1,6 +1,6 @@
 <item>
     <title>#tag|escape#</title>
-    <link>{urlbase}{url}rev/{node|short}</link>
+    <link>{baseurl}{url}rev/{node|short}</link>
     <description><![CDATA[#tag|strip|escape|addbreaks#]]></description>
     <pubDate>#date|rfc822date#</pubDate>
 </item>



More information about the Mercurial-devel mailing list