[PATCH] alternate implementation of adding archives to hgwebdir index page

Colin McMillen mcmillen at cs.cmu.edu
Fri Apr 28 01:02:08 UTC 2006


This patch is an alternate implementation of the one sent earlier. It
also adds archive links to the main hgwebdir page. It has the
advantage of looking at each repo's .hgrc to see which archive types
should be enabled (so the behavior is consistent with the archive
links provided by hgweb). It has the (minor) disadvantage of needing
to create hgweb objects for each of the repos. Choose whichever one
you like... :)

- Colin


# HG changeset patch
# User Colin McMillen <mcmillen at cs.cmu.edu>
# Node ID e07e8d59e046c83b421b67968e3c59c219a164b2
# Parent  4334be196f8db44effc59167fb57cb4bbbc1d065
Add .tar and .zip download links to hgwebdir index page.

This patch looks at each repo's .hgrc to see what types of archives
should be enabled. (The downside is that an hgweb object needs to be
instantiated for each repo.)

diff -r 4334be196f8db44effc59167fb57cb4bbbc1d065 -r e07e8d59e046c83b421b67968e3c59c219a164b2 mercurial/hgweb.py
--- a/mercurial/hgweb.py        Wed Apr 26 16:54:07 2006 +0200
+++ b/mercurial/hgweb.py        Thu Apr 27 20:59:13 2006 -0400
@@ -293,7 +293,8 @@ class hgweb(object):
         yield self.t('changelog',
                      changenav=changenav,
                      manifest=hex(mf),
-                     rev=pos, changesets=count, entries=changelist)
+                     rev=pos, changesets=count, entries=changelist,
+                     archives=self.archivelist("tip"))

     def search(self, query):

@@ -1057,7 +1058,7 @@ class hgwebdir(object):
                     d = (get_mtime(path), util.makedate()[1])
                 except OSError:
                     continue
-
+                hgwebobj = hgweb(path)
                 yield dict(contact=(get("ui", "username") or # preferred
                                     get("web", "contact") or # deprecated
                                     get("web", "author", "unknown")), # also
@@ -1065,7 +1066,8 @@ class hgwebdir(object):
                            url=url,
                            parity=parity,
                            shortdesc=get("web", "description", "unknown"),
-                           lastupdate=d)
+                           lastupdate=d,
+                           archives=hgwebobj.archivelist("tip"))

                 parity = 1 - parity

diff -r 4334be196f8db44effc59167fb57cb4bbbc1d065 -r e07e8d59e046c83b421b67968e3c59c219a164b2 templates/index.tmpl
--- a/templates/index.tmpl      Wed Apr 26 16:54:07 2006 +0200
+++ b/templates/index.tmpl      Thu Apr 27 20:59:13 2006 -0400
@@ -11,6 +11,7 @@
         <td>Description</td>
         <td>Contact</td>
         <td>Last change</td>
+        <td>Download</td>
         <td> </td>
     <tr>
     #entries%indexentry#
diff -r 4334be196f8db44effc59167fb57cb4bbbc1d065 -r e07e8d59e046c83b421b67968e3c59c219a164b2 templates/map
--- a/templates/map     Wed Apr 26 16:54:07 2006 +0200
+++ b/templates/map     Thu Apr 27 20:59:13 2006 -0400
@@ -43,8 +43,9 @@ filelogparent = '<tr><th>parent #rev#:</
 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>#archives%indexarchiveentry#</td><td><a href="#url#?cl=tip;style=rss">RSS</a></td></tr>'
 index = index.tmpl
 archiveentry = '<a href="?ca=#node|short#;type=#type|urlescape#">#type|escape#</a> '
+indexarchiveentry = '<a href="#url#?ca=#node|short#;type=#type|urlescape#">#type|escape#</a> '
 notfound = notfound.tmpl
 error = error.tmpl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20060427/91c91f6c/attachment-0001.asc>


More information about the Mercurial mailing list