mercurial/hgweb/hgwebdir_mod.py
changeset 3213 d7d53e3d9590
parent 2858 345bac2bc4ec
child 3215 53e843840349
equal deleted inserted replaced
3212:325278542ea8 3213:d7d53e3d9590
    19     def __init__(self, config):
    19     def __init__(self, config):
    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.motd = ""
    23         self.motd = ""
       
    24         self.style = ""
    24         self.repos_sorted = ('name', False)
    25         self.repos_sorted = ('name', False)
    25         if isinstance(config, (list, tuple)):
    26         if isinstance(config, (list, tuple)):
    26             self.repos = cleannames(config)
    27             self.repos = cleannames(config)
    27             self.repos_sorted = ('', False)
    28             self.repos_sorted = ('', False)
    28         elif isinstance(config, dict):
    29         elif isinstance(config, dict):
    30             self.repos.sort()
    31             self.repos.sort()
    31         else:
    32         else:
    32             cp = ConfigParser.SafeConfigParser()
    33             cp = ConfigParser.SafeConfigParser()
    33             cp.read(config)
    34             cp.read(config)
    34             self.repos = []
    35             self.repos = []
    35             if cp.has_section('web') and cp.has_option('web', 'motd'):
    36             if cp.has_section('web'):
    36                 self.motd = cp.get('web', 'motd')
    37                 if cp.has_option('web', 'motd'):
       
    38                     self.motd = cp.get('web', 'motd')
       
    39                 if cp.has_option('web', 'style'):
       
    40 		    self.style = cp.get('web', 'style')
    37             if cp.has_section('paths'):
    41             if cp.has_section('paths'):
    38                 self.repos.extend(cleannames(cp.items('paths')))
    42                 self.repos.extend(cleannames(cp.items('paths')))
    39             if cp.has_section('collections'):
    43             if cp.has_section('collections'):
    40                 for prefix, root in cp.items('collections'):
    44                 for prefix, root in cp.items('collections'):
    41                     for path in util.walkrepos(root):
    45                     for path in util.walkrepos(root):
    64 
    68 
    65         def footer(**map):
    69         def footer(**map):
    66             yield tmpl("footer", motd=self.motd, **map)
    70             yield tmpl("footer", motd=self.motd, **map)
    67 
    71 
    68         m = os.path.join(templater.templatepath(), "map")
    72         m = os.path.join(templater.templatepath(), "map")
       
    73         style = self.style
       
    74         if req.form.has_key('style'):
       
    75             style = req.form['style'][0]
       
    76         if style != "":
       
    77             b = os.path.basename("map-" + style)
       
    78             p = os.path.join(templater.templatepath(), b)
       
    79             if os.path.isfile(p):
       
    80                 m = p
       
    81 
    69         tmpl = templater.templater(m, templater.common_filters,
    82         tmpl = templater.templater(m, templater.common_filters,
    70                                    defaults={"header": header,
    83                                    defaults={"header": header,
    71                                              "footer": footer})
    84                                              "footer": footer})
    72 
    85 
    73         def archivelist(ui, nodeid, url):
    86         def archivelist(ui, nodeid, url):