hgweb: add bookmarks listing to summary page of gitweb/monoblue styles
authorYuya Nishihara <yuya@tcha.org>
Sun, 10 Apr 2011 10:01:42 +0900
changeset 13924 ea726c97c1b6
parent 13923 2176c5babd53
child 13925 c315ffc13a25
hgweb: add bookmarks listing to summary page of gitweb/monoblue styles
mercurial/hgweb/webcommands.py
mercurial/templates/gitweb/summary.tmpl
mercurial/templates/monoblue/summary.tmpl
tests/test-hgweb-commands.t
--- a/mercurial/hgweb/webcommands.py	Sun Apr 10 10:01:39 2011 +0900
+++ b/mercurial/hgweb/webcommands.py	Sun Apr 10 10:01:42 2011 +0900
@@ -460,6 +460,15 @@
                        node=hex(n),
                        date=web.repo[n].date())
 
+    def bookmarks(**map):
+        parity = paritygen(web.stripecount)
+        b = web.repo._bookmarks.items()
+        for k, n in sorted(b)[:10]:  # limit to 10 bookmarks
+            yield {'parity': parity.next(),
+                   'bookmark': k,
+                   'date': web.repo[n].date(),
+                   'node': hex(n)}
+
     def branches(**map):
         parity = paritygen(web.stripecount)
 
@@ -504,6 +513,7 @@
                 owner=get_contact(web.config) or "unknown",
                 lastchange=tip.date(),
                 tags=tagentries,
+                bookmarks=bookmarks,
                 branches=branches,
                 shortlog=changelist,
                 node=tip.hex(),
--- a/mercurial/templates/gitweb/summary.tmpl	Sun Apr 10 10:01:39 2011 +0900
+++ b/mercurial/templates/gitweb/summary.tmpl	Sun Apr 10 10:01:42 2011 +0900
@@ -50,6 +50,12 @@
 <tr class="light"><td colspan="3"><a class="list" href="{url}tags{sessionvars%urlparameter}">...</a></td></tr>
 </table>
 
+<div><a class="title" href="{url}bookmarks{sessionvars%urlparameter}">bookmarks</a></div>
+<table cellspacing="0">
+{bookmarks%bookmarkentry}
+<tr class="light"><td colspan="3"><a class="list" href="{url}bookmarks{sessionvars%urlparameter}">...</a></td></tr>
+</table>
+
 <div><a class="title" href="#">branches</a></div>
 <table cellspacing="0">
 {branches%branchentry}
--- a/mercurial/templates/monoblue/summary.tmpl	Sun Apr 10 10:01:39 2011 +0900
+++ b/mercurial/templates/monoblue/summary.tmpl	Sun Apr 10 10:01:42 2011 +0900
@@ -58,6 +58,14 @@
         </tr>
     </table>
 
+    <h2><a href="{url}bookmarks{sessionvars%urlparameter}">Bookmarks</a></h2>
+    <table>
+    {bookmarks%bookmarkentry}
+        <tr class="light">
+            <td colspan="3"><a class="list" href="{url}bookmarks{sessionvars%urlparameter}">...</a></td>
+        </tr>
+    </table>
+
     <h2 class="no-link">Branches</h2>
     <table>
     {branches%branchentry}
--- a/tests/test-hgweb-commands.t	Sun Apr 10 10:01:39 2011 +0900
+++ b/tests/test-hgweb-commands.t	Sun Apr 10 10:01:42 2011 +0900
@@ -723,6 +723,30 @@
   <tr class="light"><td colspan="3"><a class="list" href="/tags?style=gitweb">...</a></td></tr>
   </table>
   
+  <div><a class="title" href="/bookmarks?style=gitweb">bookmarks</a></div>
+  <table cellspacing="0">
+  
+  <tr class="parity0">
+  <td class="age"><i>1970-01-01</i></td>
+  <td><a class="list" href="/rev/2ef0ac749a14?style=gitweb"><b>anotherthing</b></a></td>
+  <td class="link">
+  <a href="/rev/2ef0ac749a14?style=gitweb">changeset</a> |
+  <a href="/log/2ef0ac749a14?style=gitweb">changelog</a> |
+  <a href="/file/2ef0ac749a14?style=gitweb">files</a>
+  </td>
+  </tr>
+  <tr class="parity1">
+  <td class="age"><i>1970-01-01</i></td>
+  <td><a class="list" href="/rev/1d22e65f027e?style=gitweb"><b>something</b></a></td>
+  <td class="link">
+  <a href="/rev/1d22e65f027e?style=gitweb">changeset</a> |
+  <a href="/log/1d22e65f027e?style=gitweb">changelog</a> |
+  <a href="/file/1d22e65f027e?style=gitweb">files</a>
+  </td>
+  </tr>
+  <tr class="light"><td colspan="3"><a class="list" href="/bookmarks?style=gitweb">...</a></td></tr>
+  </table>
+  
   <div><a class="title" href="#">branches</a></div>
   <table cellspacing="0">