mercurial/hgweb.py
changeset 1181 4f5001f5b4c3
parent 1180 fe3eb1628c40
child 1182 24d553b598e8
equal deleted inserted replaced
1180:fe3eb1628c40 1181:4f5001f5b4c3
   925     httpd.serve_forever()
   925     httpd.serve_forever()
   926 
   926 
   927 # This is a stopgap
   927 # This is a stopgap
   928 class hgwebdir:
   928 class hgwebdir:
   929     def __init__(self, config):
   929     def __init__(self, config):
       
   930         def cleannames(items):
       
   931             return [(name.strip('/'), path) for name, path in items]
       
   932 
   930         if type(config) == type([]):
   933         if type(config) == type([]):
   931             self.repos = config
   934             self.repos = cleannames(config)
   932         elif type(config) == type({}):
   935         elif type(config) == type({}):
   933             self.repos = config.items()
   936             self.repos = cleannames(config.items())
   934             self.repos.sort()
   937             self.repos.sort()
   935         else:
   938         else:
   936             cp = ConfigParser.SafeConfigParser()
   939             cp = ConfigParser.SafeConfigParser()
   937             cp.read(config)
   940             cp.read(config)
   938             self.repos = cp.items("paths")
   941             self.repos = cleannames(cp.items("paths"))
   939             self.repos.sort()
   942             self.repos.sort()
   940 
   943 
   941     def run(self, req=hgrequest()):
   944     def run(self, req=hgrequest()):
   942         def header(**map):
   945         def header(**map):
   943             yield tmpl("header", **map)
   946             yield tmpl("header", **map)
   954             for name, path in self.repos:
   957             for name, path in self.repos:
   955                 u = ui()
   958                 u = ui()
   956                 u.readconfig(file(os.path.join(path, '.hg', 'hgrc')))
   959                 u.readconfig(file(os.path.join(path, '.hg', 'hgrc')))
   957                 get = u.config
   960                 get = u.config
   958 
   961 
   959                 url = ('/'.join([req.env["REQUEST_URI"], name])
   962                 url = ('/'.join([req.env["REQUEST_URI"].split('?')[0], name])
   960                        .replace("//", "/"))
   963                        .replace("//", "/"))
   961 
   964 
   962                 yield dict(contact=get("web", "contact") or
   965                 yield dict(contact=get("web", "contact") or
   963                                    get("web", "author", "unknown"),
   966                                    get("web", "author", "unknown"),
   964                            name=get("web", "name", name),
   967                            name=get("web", "name", name),