Add download links to hgwebdir index page for allowed archive types.
authorThomas Arendsen Hein <thomas@intevation.de>
Mon, 01 May 2006 10:02:17 +0200
changeset 2171 290534ee163c
parent 2170 29eeb2717915
child 2172 eba364839c67
Add download links to hgwebdir index page for allowed archive types. Based on a patch by Colin McMillen <mcmillen@cs.cmu.edu>
mercurial/hgweb.py
templates/map
templates/static/style.css
--- a/mercurial/hgweb.py	Mon May 01 09:01:59 2006 +0200
+++ b/mercurial/hgweb.py	Mon May 01 10:02:17 2006 +0200
@@ -125,7 +125,7 @@
     def archivelist(self, nodeid):
         for i in self.archives:
             if self.repo.ui.configbool("web", "allow" + i, False):
-                yield {"type" : i, "node" : nodeid}
+                yield {"type" : i, "node" : nodeid, "url": ""}
 
     def listfiles(self, files, mf):
         for f in files[:self.maxfiles]:
@@ -1045,6 +1045,11 @@
                                    defaults={"header": header,
                                              "footer": footer})
 
+        def archivelist(ui, nodeid, url):
+            for i in ['zip', 'gz', 'bz2']:
+                if ui.configbool("web", "allow" + i, False):
+                    yield {"type" : i, "node": nodeid, "url": url}
+
         def entries(**map):
             parity = 0
             for name, path in self.repos:
@@ -1071,7 +1076,8 @@
                            url=url,
                            parity=parity,
                            shortdesc=get("web", "description", "unknown"),
-                           lastupdate=d)
+                           lastupdate=d,
+                           archives=archivelist(u, "tip", url))
 
                 parity = 1 - parity
 
--- a/templates/map	Mon May 01 09:01:59 2006 +0200
+++ b/templates/map	Mon May 01 10:02:17 2006 +0200
@@ -43,8 +43,8 @@
 filelogparent = '<tr><th>parent #rev#:</th><td><a href="?f=#node|short#;file=#file|urlescape#">#node|short#</a></td></tr>'
 filediffchild = '<tr><th class="child">child #rev#:</th><td class="child"><a href="?cs=#node|short#">#node|short#</a></td></tr>'
 filelogchild = '<tr><th>child #rev#:</th><td><a href="?f=#node|short#;file=#file|urlescape#">#node|short#</a></td></tr>'
-indexentry = '<tr class="parity#parity#"><td><a href="#url#">#name|escape#</a></td><td>#shortdesc#</td><td>#contact|obfuscate#</td><td class="age">#lastupdate|age# ago</td><td><a href="#url#?cl=tip;style=rss">RSS</a></td></tr>'
+indexentry = '<tr class="parity#parity#"><td><a href="#url#">#name|escape#</a></td><td>#shortdesc#</td><td>#contact|obfuscate#</td><td class="age">#lastupdate|age# ago</td><td class="indexlinks"><a href="#url#?cl=tip;style=rss">RSS</a> #archives%archiveentry#</td></tr>'
 index = index.tmpl
-archiveentry = '<a href="?ca=#node|short#;type=#type|urlescape#">#type|escape#</a> '
+archiveentry = '<a href="#url#?ca=#node|short#;type=#type|urlescape#">#type|escape#</a> '
 notfound = notfound.tmpl
 error = error.tmpl
--- a/templates/static/style.css	Mon May 01 09:01:59 2006 +0200
+++ b/templates/static/style.css	Mon May 01 10:02:17 2006 +0200
@@ -1,5 +1,6 @@
 a { text-decoration:none; }
 .age { white-space:nowrap; }
+.indexlinks { white-space:nowrap; }
 .parity0 { background-color: #dddddd; }
 .parity1 { background-color: #eeeeee; }
 .lineno { width: 60px; color: #aaaaaa; font-size: smaller;