Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgwebdir_mod.py @ 4080:ef14fdb675da
hgwebdir: try to get web.style and web.motd from the ui.config system
This finishes fixing issue253. As a bonus, web.style and web.motd
settings from ~/.hgrc will be used for the hgwebdir index page.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Tue, 13 Feb 2007 10:02:07 -0200 |
parents | 40c9710e8182 |
children | e6d26e71f049 a80502f47552 |
comparison
equal
deleted
inserted
replaced
4079:40c9710e8182 | 4080:ef14fdb675da |
---|---|
19 def __init__(self, config, parentui=None): | 19 def __init__(self, config, parentui=None): |
20 def cleannames(items): | 20 def cleannames(items): |
21 return [(name.strip(os.sep), path) for name, path in items] | 21 return [(name.strip(os.sep), path) for name, path in items] |
22 | 22 |
23 self.parentui = parentui | 23 self.parentui = parentui |
24 self.motd = "" | 24 self.motd = None |
25 self.style = "" | 25 self.style = None |
26 self.repos_sorted = ('name', False) | 26 self.repos_sorted = ('name', False) |
27 if isinstance(config, (list, tuple)): | 27 if isinstance(config, (list, tuple)): |
28 self.repos = cleannames(config) | 28 self.repos = cleannames(config) |
29 self.repos_sorted = ('', False) | 29 self.repos_sorted = ('', False) |
30 elif isinstance(config, dict): | 30 elif isinstance(config, dict): |
70 | 70 |
71 def footer(**map): | 71 def footer(**map): |
72 yield tmpl("footer", **map) | 72 yield tmpl("footer", **map) |
73 | 73 |
74 def motd(**map): | 74 def motd(**map): |
75 yield self.motd | 75 if self.motd is not None: |
76 yield self.motd | |
77 else: | |
78 yield config('web', 'motd', '') | |
76 | 79 |
77 parentui = self.parentui or ui.ui(report_untrusted=False) | 80 parentui = self.parentui or ui.ui(report_untrusted=False) |
81 | |
82 def config(section, name, default=None, untrusted=True): | |
83 return parentui.config(section, name, default, untrusted) | |
78 | 84 |
79 url = req.env['REQUEST_URI'].split('?')[0] | 85 url = req.env['REQUEST_URI'].split('?')[0] |
80 if not url.endswith('/'): | 86 if not url.endswith('/'): |
81 url += '/' | 87 url += '/' |
82 | 88 |
83 style = self.style | 89 style = self.style |
90 if style is None: | |
91 style = config('web', 'style', '') | |
84 if req.form.has_key('style'): | 92 if req.form.has_key('style'): |
85 style = req.form['style'][0] | 93 style = req.form['style'][0] |
86 mapfile = style_map(templater.templatepath(), style) | 94 mapfile = style_map(templater.templatepath(), style) |
87 tmpl = templater.templater(mapfile, templater.common_filters, | 95 tmpl = templater.templater(mapfile, templater.common_filters, |
88 defaults={"header": header, | 96 defaults={"header": header, |