changeset 3221:d7d53e3d9590

Add style support to hgwebdir
author Edouard Gomez <ed.gomez@free.fr>
date Thu, 21 Sep 2006 21:24:26 +0200
parents 325278542ea8
children a5603ad915c5
files mercurial/hgweb/hgwebdir_mod.py
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py	Sat Sep 30 21:32:29 2006 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Thu Sep 21 21:24:26 2006 +0200
@@ -21,6 +21,7 @@
             return [(name.strip(os.sep), path) for name, path in items]
 
         self.motd = ""
+        self.style = ""
         self.repos_sorted = ('name', False)
         if isinstance(config, (list, tuple)):
             self.repos = cleannames(config)
@@ -32,8 +33,11 @@
             cp = ConfigParser.SafeConfigParser()
             cp.read(config)
             self.repos = []
-            if cp.has_section('web') and cp.has_option('web', 'motd'):
-                self.motd = cp.get('web', 'motd')
+            if cp.has_section('web'):
+                if cp.has_option('web', 'motd'):
+                    self.motd = cp.get('web', 'motd')
+                if cp.has_option('web', 'style'):
+		    self.style = cp.get('web', 'style')
             if cp.has_section('paths'):
                 self.repos.extend(cleannames(cp.items('paths')))
             if cp.has_section('collections'):
@@ -66,6 +70,15 @@
             yield tmpl("footer", motd=self.motd, **map)
 
         m = os.path.join(templater.templatepath(), "map")
+        style = self.style
+        if req.form.has_key('style'):
+            style = req.form['style'][0]
+        if style != "":
+            b = os.path.basename("map-" + style)
+            p = os.path.join(templater.templatepath(), b)
+            if os.path.isfile(p):
+                m = p
+
         tmpl = templater.templater(m, templater.common_filters,
                                    defaults={"header": header,
                                              "footer": footer})