Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb.py @ 2171:290534ee163c
Add download links to hgwebdir index page for allowed archive types.
Based on a patch by Colin McMillen <mcmillen@cs.cmu.edu>
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Mon, 01 May 2006 10:02:17 +0200 |
parents | 29eeb2717915 |
children | d1943df604c4 |
comparison
equal
deleted
inserted
replaced
2170:29eeb2717915 | 2171:290534ee163c |
---|---|
123 self.allowpull = self.repo.ui.configbool("web", "allowpull", True) | 123 self.allowpull = self.repo.ui.configbool("web", "allowpull", True) |
124 | 124 |
125 def archivelist(self, nodeid): | 125 def archivelist(self, nodeid): |
126 for i in self.archives: | 126 for i in self.archives: |
127 if self.repo.ui.configbool("web", "allow" + i, False): | 127 if self.repo.ui.configbool("web", "allow" + i, False): |
128 yield {"type" : i, "node" : nodeid} | 128 yield {"type" : i, "node" : nodeid, "url": ""} |
129 | 129 |
130 def listfiles(self, files, mf): | 130 def listfiles(self, files, mf): |
131 for f in files[:self.maxfiles]: | 131 for f in files[:self.maxfiles]: |
132 yield self.t("filenodelink", node=hex(mf[f]), file=f) | 132 yield self.t("filenodelink", node=hex(mf[f]), file=f) |
133 if len(files) > self.maxfiles: | 133 if len(files) > self.maxfiles: |
1043 m = os.path.join(templater.templatepath(), "map") | 1043 m = os.path.join(templater.templatepath(), "map") |
1044 tmpl = templater.templater(m, templater.common_filters, | 1044 tmpl = templater.templater(m, templater.common_filters, |
1045 defaults={"header": header, | 1045 defaults={"header": header, |
1046 "footer": footer}) | 1046 "footer": footer}) |
1047 | 1047 |
1048 def archivelist(ui, nodeid, url): | |
1049 for i in ['zip', 'gz', 'bz2']: | |
1050 if ui.configbool("web", "allow" + i, False): | |
1051 yield {"type" : i, "node": nodeid, "url": url} | |
1052 | |
1048 def entries(**map): | 1053 def entries(**map): |
1049 parity = 0 | 1054 parity = 0 |
1050 for name, path in self.repos: | 1055 for name, path in self.repos: |
1051 u = ui.ui() | 1056 u = ui.ui() |
1052 try: | 1057 try: |
1069 get("web", "author", "unknown")), # also | 1074 get("web", "author", "unknown")), # also |
1070 name=get("web", "name", name), | 1075 name=get("web", "name", name), |
1071 url=url, | 1076 url=url, |
1072 parity=parity, | 1077 parity=parity, |
1073 shortdesc=get("web", "description", "unknown"), | 1078 shortdesc=get("web", "description", "unknown"), |
1074 lastupdate=d) | 1079 lastupdate=d, |
1080 archives=archivelist(u, "tip", url)) | |
1075 | 1081 |
1076 parity = 1 - parity | 1082 parity = 1 - parity |
1077 | 1083 |
1078 virtual = req.env.get("PATH_INFO", "").strip('/') | 1084 virtual = req.env.get("PATH_INFO", "").strip('/') |
1079 if virtual: | 1085 if virtual: |