changeset 8215:227707c90548

hgweb: some cleanups in hgwebdir, remove double defaults Removed obsolete command, expose useful cleannames function.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 27 Apr 2009 11:37:08 +0200
parents a2af1d92b913
children 25266fe996b0
files mercurial/hgweb/hgwebdir_mod.py
diffstat 1 files changed, 9 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py	Sun Apr 26 20:19:40 2009 +0200
+++ b/mercurial/hgweb/hgwebdir_mod.py	Mon Apr 27 11:37:08 2009 +0200
@@ -15,15 +15,15 @@
 from hgweb_mod import hgweb
 from request import wsgirequest
 
-# This is a stopgap
+def cleannames(items):
+    return [(util.pconvert(name).strip('/'), path) for name, path in items]
+
 class hgwebdir(object):
+
     def __init__(self, conf, baseui=None):
-        def cleannames(items):
-            return [(util.pconvert(name).strip('/'), path)
-                    for name, path in items]
 
         if baseui:
-           self.ui = baseui.copy()
+            self.ui = baseui.copy()
         else:
             self.ui = ui.ui()
             self.ui.setconfig('ui', 'report_untrusted', 'off')
@@ -31,9 +31,10 @@
 
         self.motd = None
         self.style = 'paper'
-        self.stripecount = None
+        self.stripecount = 1
         self.repos_sorted = ('name', False)
         self._baseurl = None
+
         if isinstance(conf, (list, tuple)):
             self.repos = cleannames(conf)
             self.repos_sorted = ('', False)
@@ -48,7 +49,7 @@
             self.repos = []
             self.motd = cp.get('web', 'motd')
             self.style = cp.get('web', 'style', 'paper')
-            self.stripecount = cp.get('web', 'stripes')
+            self.stripecount = cp.get('web', 'stripes', 1)
             self._baseurl = cp.get('web', 'baseurl')
             if 'paths' in cp:
                 paths = cleannames(cp.items('paths'))
@@ -310,12 +311,7 @@
         if not staticurl.endswith('/'):
             staticurl += '/'
 
-        style = self.style
-        if style is None:
-            style = config('web', 'style', '')
-        if 'style' in req.form:
-            style = req.form['style'][0]
-        self.stripecount = int(self.stripecount or config('web', 'stripes', 1))
+        style = 'style' in req.form and req.form['style'][0] or self.style
         mapfile = templater.stylemap(style)
         tmpl = templater.templater(mapfile, templatefilters.filters,
                                    defaults={"header": header,