Add style support to hgwebdir
authorEdouard Gomez <ed.gomez@free.fr>
Thu, 21 Sep 2006 21:24:26 +0200
changeset 3221 d7d53e3d9590
parent 3220 325278542ea8
child 3222 a5603ad915c5
Add style support to hgwebdir
mercurial/hgweb/hgwebdir_mod.py
--- 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})