[PATCH take 2] Making the gitweb annotate page look more like git's

Govind Salinas blix at sophiasuchtig.com
Tue Jan 22 22:26:14 CST 2008


# HG changeset patch
# User Govind Salinas <blix at sophiasuchtig.com>
# Date 1201062132 21600
# Branch gitweb3
# Node ID e223145828cc696925d67e7beb4aea03788fb3ab
# Parent  d0576d065993c59f0e84b6e71e2690531e825574
Making the gitweb annotate page look more like git's

Changed the style of the table to match gitweb's
Removed the author from the first column
Added hidden columns for nodeid, author and revision date
Show/hide link for hidden columns
Only show commit data when the commit info changes for that line.
Add a line number column.

diff -r d0576d065993 -r e223145828cc mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Sun Jan 20 14:39:25 2008 +0100
+++ b/mercurial/hgweb/hgweb_mod.py	Tue Jan 22 22:22:12 2008 -0600
@@ -624,19 +624,35 @@ class hgweb(object):

         def annotate(**map):
             last = None
+            lineno = 1
+            revparity = 0
+            samerev = 0
+
             for f, l in fctx.annotate(follow=True):
                 fnode = f.filenode()
                 name = self.repo.ui.shortuser(f.user())

                 if last != fnode:
                     last = fnode
+                    if revparity:
+                       revparity = 0
+                    else:
+                       revparity = 1
+                    samerev = 0
+                else:
+                    samerev = 1

                 yield {"parity": parity.next(),
                        "node": hex(f.node()),
                        "rev": f.rev(),
                        "author": name,
                        "file": f.path(),
-                       "line": l}
+                       "line": l,
+                       "lineno":lineno,
+                       "revparity":revparity,
+                       "samerev":samerev,
+                       "revdate":f.date()}
+                lineno = lineno + 1

         return tmpl("fileannotate",
                     file=f,
diff -r d0576d065993 -r e223145828cc templates/gitweb/fileannotate.tmpl
--- a/templates/gitweb/fileannotate.tmpl	Sun Jan 20 14:39:25 2008 +0100
+++ b/templates/gitweb/fileannotate.tmpl	Tue Jan 22 22:22:12 2008 -0600
@@ -5,6 +5,33 @@
 <link rel="alternate" type="application/rss+xml"
    href="{url}rss-log" title="RSS feed for #repo|escape#"/>
 </head>
+<script type="text/javascript">
+function toggle_extra_columns()
+{
+   var sheets = document.styleSheets;
+   for (i = 0; i < sheets.length; ++i)
+   {
+      var cssRules = sheets[i].cssRules ? sheets[i].cssRules : sheets[i].rules;
+      for (j = 0; j < cssRules.length; ++j)
+      {
+         var rule = cssRules[j];
+         if (rule.selectorText == "td.extracolumn")
+         {
+            if (rule.style.display == "inline")
+            {
+               rule.style.display = "none";
+               document.getElementById("change_columns").innerHTML = "[+]";
+            }
+            else
+            {
+               rule.style.display = "inline";
+               document.getElementById("change_columns").innerHTML = "[-]";
+            }
+         }
+      }
+   }
+}
+</script>
 <body>

 <div class="page_header">
@@ -50,7 +77,10 @@ annotate |
 {desc|strip|escape|addbreaks}
 </div>
 <div class="page_body">
-<table>
+<table style="border-spacing:0;">
+<tr>
+<td>Revision<a id="change_columns" href="#"
onClick="javascript:toggle_extra_columns();">[+]</a></td><td
class="extracolumn">Nodeid</td><td class="extracolumn">Author</td><td
class="extracolumn">Date</td><td>Line No</td><td>Data</td>
+<tr>
 #annotate%annotateline#
 </table>
 </div>
diff -r d0576d065993 -r e223145828cc templates/gitweb/map
--- a/templates/gitweb/map	Sun Jan 20 14:39:25 2008 +0100
+++ b/templates/gitweb/map	Tue Jan 22 22:22:12 2008 -0600
@@ -22,8 +22,8 @@ fileannotate = fileannotate.tmpl
 fileannotate = fileannotate.tmpl
 filediff = filediff.tmpl
 filelog = filelog.tmpl
-fileline = '<div style="font-family:monospace"
class="parity#parity#"><pre><span class="linenr">
#linenumber#</span> #line|escape#</pre></div>'
-annotateline = '<tr style="font-family:monospace"
class="parity#parity#"><td class="linenr" style="text-align:
right;"><a href="#url#annotate/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a></td><td><pre>#line|escape#</pre></td></tr>'
+fileline = '<div style="font-family:monospace"
class="parity#parity#"><pre><span class="linenr">#linenumber#</span>
#line|escape#</pre></div>'
+annotateline = '<tr style="font-family:monospace"
class="parity#revparity#"><td class="linenr" style="text-align:
right;"><a href="#url#rev/#node#/#file|urlescape#{sessionvars%urlparameter}"
hidetd="{samerev}">#rev#</a></td><td class="extracolumn"
hidetd="{samerev}">#node|short#</td><td class="extracolumn"
hidetd="{samerev}">#author|obfuscate#</td><td class="extracolumn"
hidetd="{samerev}">#revdate|isodate#</td><td
class="lineno">#lineno#</td><td><pre>#line|escape#</pre></td></tr>'
 difflineplus = '<span style="color:#008800;">#line|escape#</span>'
 difflineminus = '<span style="color:#cc0000;">#line|escape#</span>'
 difflineat = '<span style="color:#990099;">#line|escape#</span>'
diff -r d0576d065993 -r e223145828cc templates/static/style-gitweb.css
--- a/templates/static/style-gitweb.css	Sun Jan 20 14:39:25 2008 +0100
+++ b/templates/static/style-gitweb.css	Tue Jan 22 22:22:12 2008 -0600
@@ -47,6 +47,7 @@ a.rss_logo {
 	text-align:center; text-decoration:none;
 }
 a.rss_logo:hover { background-color:#ee5500; }
+td.lineno { color: #999999; }
 pre { margin: 0; }
 span.logtags span {
 	padding: 0px 4px;
@@ -64,3 +65,8 @@ span.logtags span.branchtag {
 	background-color: #aaffaa;
 	border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
 }
+td.extracolumn { display:none; }
+[hidetd="1"]
+{
+visibility:hidden;
+}


More information about the Mercurial-devel mailing list