[PATCH] Making the gitweb annotate page look more like git's
Govind Salinas
blix at sophiasuchtig.com
Tue Jan 22 05:10:40 UTC 2008
# HG changeset patch
# User Govind Salinas <blix at sophiasuchtig.com>
# Date 1200978440 21600
# Branch gitweb2
# Node ID 971b68d4f0dc6e916bde09b22dfe7fafcb74d77a
# Parent d0576d065993c59f0e84b6e71e2690531e825574
Making the gitweb annotate page look more like git's
Changed the style of the table to match gitweb's
Using short nodeids instead of revisions numbers and authors
Show/hide colums with author and date
Only show nodeid when it changes.
Add a line number column.
diff -r d0576d065993 -r 971b68d4f0dc 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 Mon Jan 21 23:07:20 2008 -0600
@@ -624,19 +624,33 @@ class hgweb(object):
def annotate(**map):
last = None
+ lineno = 1
+ revparity = 0
+ revonce = ""
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
+ revonce = hex(f.node())
+ else: revonce = ""
yield {"parity": parity.next(),
"node": hex(f.node()),
"rev": f.rev(),
"author": name,
"file": f.path(),
- "line": l}
+ "line": l,
+ "lineno":lineno,
+ "revparity":revparity,
+ "revonce":revonce,
+ "revdate":f.date()}
+ lineno = lineno + 1
return tmpl("fileannotate",
file=f,
diff -r d0576d065993 -r 971b68d4f0dc templates/gitweb/fileannotate.tmpl
--- a/templates/gitweb/fileannotate.tmpl Sun Jan 20 14:39:25 2008 +0100
+++ b/templates/gitweb/fileannotate.tmpl Mon Jan 21 23:07:20 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>Commit <a id="change_columns" href="#"
onClick="javascript:toggle_extra_columns();">[+]</a></td><td
class="extracolumn">Author</td><td class="extracolumn"</td><td>Line
No</td><td>Data</td>
+<tr>
#annotate%annotateline#
</table>
</div>
diff -r d0576d065993 -r 971b68d4f0dc templates/gitweb/map
--- a/templates/gitweb/map Sun Jan 20 14:39:25 2008 +0100
+++ b/templates/gitweb/map Mon Jan 21 23:07:20 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}">#revonce|short#</a></td><td
class="extracolumn">#author|obfuscate#</td><td
class="extracolumn">#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 971b68d4f0dc 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 Mon Jan 21 23:07:20 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,4 @@ span.logtags span.branchtag {
background-color: #aaffaa;
border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
}
+td.extracolumn { display:none; }
More information about the Mercurial-devel
mailing list