Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgwebdir_mod.py @ 3262:1e322b44b366
Teach hgwebdir about new interface
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Wed, 04 Oct 2006 17:04:40 -0700 |
parents | 53e843840349 |
children | 3207e30bf468 |
comparison
equal
deleted
inserted
replaced
3261:329ac0c0c0e8 | 3262:1e322b44b366 |
---|---|
83 defaults={"header": header, | 83 defaults={"header": header, |
84 "footer": footer}) | 84 "footer": footer}) |
85 | 85 |
86 def archivelist(ui, nodeid, url): | 86 def archivelist(ui, nodeid, url): |
87 allowed = ui.configlist("web", "allow_archive") | 87 allowed = ui.configlist("web", "allow_archive") |
88 for i in ['zip', 'gz', 'bz2']: | 88 for i in [('zip', '.zip'), ('gz', '.tar.gz'), ('bz2', '.tar.bz2')]: |
89 if i in allowed or ui.configbool("web", "allow" + i): | 89 if i[0] in allowed or ui.configbool("web", "allow" + i[0]): |
90 yield {"type" : i, "node": nodeid, "url": url} | 90 yield {"type" : i[0], "extension": i[1], |
91 "node": nodeid, "url": url} | |
91 | 92 |
92 def entries(sortcolumn="", descending=False, **map): | 93 def entries(sortcolumn="", descending=False, **map): |
93 rows = [] | 94 rows = [] |
94 parity = 0 | 95 parity = 0 |
95 for name, path in self.repos: | 96 for name, path in self.repos: |
99 except IOError: | 100 except IOError: |
100 pass | 101 pass |
101 get = u.config | 102 get = u.config |
102 | 103 |
103 url = ('/'.join([req.env["REQUEST_URI"].split('?')[0], name]) | 104 url = ('/'.join([req.env["REQUEST_URI"].split('?')[0], name]) |
104 .replace("//", "/")) | 105 .replace("//", "/")) + '/' |
105 | 106 |
106 # update time with local timezone | 107 # update time with local timezone |
107 try: | 108 try: |
108 d = (get_mtime(path), util.makedate()[1]) | 109 d = (get_mtime(path), util.makedate()[1]) |
109 except OSError: | 110 except OSError: |
141 parity = 1 - parity | 142 parity = 1 - parity |
142 yield row | 143 yield row |
143 | 144 |
144 virtual = req.env.get("PATH_INFO", "").strip('/') | 145 virtual = req.env.get("PATH_INFO", "").strip('/') |
145 if virtual: | 146 if virtual: |
146 real = dict(self.repos).get(virtual) | 147 while virtual: |
148 real = dict(self.repos).get(virtual) | |
149 if real: | |
150 break | |
151 up = virtual.rfind('/') | |
152 if up < 0: | |
153 break | |
154 virtual = virtual[:up] | |
147 if real: | 155 if real: |
156 req.env['REPO_NAME'] = virtual | |
148 try: | 157 try: |
149 hgweb(real).run_wsgi(req) | 158 hgweb(real).run_wsgi(req) |
150 except IOError, inst: | 159 except IOError, inst: |
151 req.write(tmpl("error", error=inst.strerror)) | 160 req.write(tmpl("error", error=inst.strerror)) |
152 except hg.RepoError, inst: | 161 except hg.RepoError, inst: |