932 yield tmpl("header", **map) |
932 yield tmpl("header", **map) |
933 |
933 |
934 def footer(**map): |
934 def footer(**map): |
935 yield tmpl("footer", **map) |
935 yield tmpl("footer", **map) |
936 |
936 |
937 templates = templatepath() |
937 m = os.path.join(templatepath(), "map") |
938 m = os.path.join(templates, "map") |
|
939 tmpl = templater(m, common_filters, |
938 tmpl = templater(m, common_filters, |
940 {"header": header, "footer": footer}) |
939 {"header": header, "footer": footer}) |
941 |
940 |
942 def entries(**map): |
941 def entries(**map): |
943 parity = 0 |
942 parity = 0 |
944 for name, path in self.repos: |
943 for name, path in self.repos: |
945 u = ui() |
944 u = ui() |
946 u.readconfig(file(os.path.join(path, '.hg', 'hgrc'))) |
945 u.readconfig(file(os.path.join(path, '.hg', 'hgrc'))) |
947 get = u.config |
946 get = u.config |
948 |
947 |
949 url = os.environ["REQUEST_URI"] + "/" + name |
948 url = ('/'.join([os.environ["REQUEST_URI"], name]) |
950 url = url.replace("//", "/") |
949 .replace("//", "/")) |
951 |
950 |
952 yield dict(contact=get("web", "contact") or |
951 yield dict(contact=get("web", "contact") or |
953 get("web", "author", "unknown"), |
952 get("web", "author", "unknown"), |
954 name=get("web", "name", name), |
953 name=get("web", "name", name), |
955 url=url, |
954 url=url, |
956 parity=parity, |
955 parity=parity, |
957 shortdesc=get("web", "description", "unknown"), |
956 shortdesc=get("web", "description", "unknown"), |
958 lastupdate=os.stat(os.path.join(path, ".hg", |
957 lastupdate=os.stat(os.path.join(path, ".hg", |
959 "00changelog.d")).st_mtime) |
958 "00changelog.d")).st_mtime) |
960 |
959 |
961 parity = 1 - parity |
960 parity = 1 - parity |
962 |
961 |
963 try: |
962 virtual = os.environ.get("PATH_INFO", "").strip('/') |
964 virtual = os.environ["PATH_INFO"] |
963 if virtual: |
965 except: |
|
966 virtual = "" |
|
967 |
|
968 virtual = virtual.strip('/') |
|
969 |
|
970 if len(virtual): |
|
971 real = dict(self.repos).get(virtual) |
964 real = dict(self.repos).get(virtual) |
972 if real: |
965 if real: |
973 h = hgweb(real) |
966 hgweb(real).run() |
974 h.run() |
|
975 return |
|
976 else: |
967 else: |
977 write(tmpl("notfound", repo = virtual)) |
968 write(tmpl("notfound", repo=virtual)) |
978 return |
969 else: |
979 |
970 write(tmpl("index", entries=entries)) |
980 write(tmpl("index", entries=entries)) |
|