From: Petr Baudis <pasky@suse.cz>
To: Junio C Hamano <junkio@cox.net>
Cc: <git@vger.kernel.org>, Petr Baudis <pasky@suse.cz>
Subject: [PATCH 2/3] gitweb: Extra columns in blame
Date: Sat, 19 May 2007 01:02:33 +0200 [thread overview]
Message-ID: <20070518230232.17359.84754.stgit@rover> (raw)
In-Reply-To: <20070518230227.17359.16402.stgit@rover>
This patch adds extra columns to blame output, containing
line author and creation date. These columns are by default hidden by
display: none but by clicking on the expansion "button" you can display
them (and hide again). I think seeing this information without tooltips
fishing can give much better overview of the content evolution.
This patch depends on the interactive blame patch (but can be factored out;
the common required parts are just the blame.js infrastructure).
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
This version is updated for the new version of incremental blame and
features updated javascript code based on a friend's suggestions that
should improve MSIE compatibility and performance.
---
gitweb/blame.js | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
gitweb/gitweb.css | 5 +++++
gitweb/gitweb.perl | 17 +++++++++++++----
3 files changed, 65 insertions(+), 5 deletions(-)
diff --git a/gitweb/blame.js b/gitweb/blame.js
index bd51275..f6d661a 100644
--- a/gitweb/blame.js
+++ b/gitweb/blame.js
@@ -1,4 +1,44 @@
// Copyright (C) 2007, Fredrik Kuivinen <frekui@gmail.com>
+// Copyright (C) 2007, Petr Baudis <pasky@suse.cz>
+
+
+// blame extra columns
+
+// I would like to note here that JavaScript is utterly stupid.
+function findStyleRule(styleName) {
+ for (i = 0; i < document.styleSheets.length; i++) {
+ // MSIE has .rules, Mozilla has .cssRules
+ var cssRules = document.styleSheets[i].cssRules ? document.styleSheets[i].cssRules : document.styleSheets[i].rules;
+ for (j = 0; j < cssRules.length; j++) {
+ var rule = cssRules[j];
+ if (rule.selectorText.toLowerCase() == styleName) {
+ return rule;
+ }
+ }
+ }
+}
+
+var isIE = (navigator.appName.toLowerCase().indexOf("microsoft") != -1);
+var extra_columns = 0;
+var extra_column_rule = null;
+function extra_blame_columns() {
+ if (!extra_column_rule)
+ extra_column_rule = findStyleRule(".extra_column");
+
+ if (!extra_columns) {
+ document.getElementById("columns_expander").innerHTML = "[-]";
+ extra_column_rule.style.display = isIE ? "inline" : "table-cell";
+ extra_columns = 1;
+ } else {
+ document.getElementById("columns_expander").innerHTML = "[+]";
+ extra_column_rule.style.display = "none";
+ extra_columns = 0;
+ }
+}
+
+
+// blame_interactive
+
var DEBUG = 0;
function debug(str)
@@ -72,14 +112,20 @@ function handleLine(commit)
+ zeroPad(date.getUTCSeconds());
tr.firstChild.title = commit.author + ', ' + dateStr + ' ' + timeStr;
var shaAnchor = tr.firstChild.firstChild;
+ var authorField = tr.firstChild.nextSibling;
+ var dateField = tr.firstChild.nextSibling.nextSibling;
if (i == 0) {
shaAnchor.href = baseUrl + ';a=commit;h=' + commit.sha1;
shaAnchor.innerHTML = commit.sha1.substr(0, 8);
+ authorField.innerHTML = commit.author;
+ dateField.innerHTML = dateStr + ' ' + timeStr;
} else {
shaAnchor.innerHTML = '';
+ authorField.innerHTML = '';
+ dateField.innerHTML = '';
}
- var lineAnchor = tr.firstChild.nextSibling.firstChild;
+ var lineAnchor = tr.firstChild.nextSibling.nextSibling.nextSibling.firstChild;
lineAnchor.href = baseUrl + ';a=blame;hb=' + commit.sha1
+ ';f=' + commit.filename + '#l' + commit.srcline;
resline++;
diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 9f0822f..48b50b0 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -488,3 +488,8 @@ span.match {
div.binary {
font-style: italic;
}
+
+/* This selector is hardcoded in gitweb.perl */
+.extra_column {
+ display: none;
+}
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index dae35de..f301718 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3677,11 +3677,16 @@ sub git_blame_common {
my $num_colors = scalar(@rev_color);
my $current_color = 0;
my $last_rev;
- print "<script type=\"text/javascript\" src=\"$blamejs\"></script>\n" if $type eq 'incremental';
+ print "<script type=\"text/javascript\" src=\"$blamejs\"></script>\n";
print <<HTML;
+
<div class="page_body">
<table class="blame">
-<tr><th>Commit</th><th>Line</th><th>Data</th></tr>
+<tr><th>Commit <a href="javascript:extra_blame_columns()" id="columns_expander">[+]</a></th>
+<th class="extra_column">Author</th>
+<th class="extra_column">Date</th>
+<th>Line</th>
+<th>Data</th></tr>
HTML
my %metainfo = ();
my $linenr = 0;
@@ -3692,6 +3697,8 @@ HTML
$linenr += 1;
print "<tr id=\"l$linenr\" class=\"light2\">";
print '<td class="sha1"><a href=""></a></td>';
+ print "<td class=\"extra_column\"></td>";
+ print "<td class=\"extra_column\"></td>";
print "<td class=\"linenr\"><a class=\"linenr\" href=\"\">$linenr</a></td><td class=\"pre\">" . esc_html($_) . "</td>\n";
print "</tr>\n";
next;
@@ -3721,15 +3728,17 @@ HTML
}
print "<tr class=\"$rev_color[$current_color]\">\n";
if ($group_size) {
+ my $rowspan = $group_size > 1 ? " rowspan=\"$group_size\"" : "";
print "<td class=\"sha1\"";
print " title=\"". esc_html($author) . ", $date\"";
- print " rowspan=\"$group_size\"" if ($group_size > 1);
- print ">";
+ print "$rowspan>";
print $cgi->a({-href => href(action=>"commit",
hash=>$full_rev,
file_name=>$file_name)},
esc_html($rev));
print "</td>\n";
+ print "<td class=\"extra_column\" $rowspan>". esc_html($author) . "</td>";
+ print "<td class=\"extra_column\" $rowspan>". $date . "</td>";
}
open (my $dd, "-|", git_cmd(), "rev-parse", "$full_rev^")
or die_error(undef, "Open git-rev-parse failed");
next prev parent reply other threads:[~2007-05-18 23:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-18 23:02 [PATCH 1/3] gitweb: Incremental blame Petr Baudis
2007-05-18 23:02 ` Petr Baudis [this message]
2007-05-18 23:02 ` [PATCH 3/3] gitweb: Remove git_blame (superseded by git_blame2) Petr Baudis
-- strict thread matches above, loose matches on Subject: below --
2007-08-25 22:24 [PATCH 1/3] gitweb: Incremental blame Petr Baudis
2007-08-25 22:24 ` [PATCH 2/3] gitweb: Extra columns in blame Petr Baudis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070518230232.17359.84754.stgit@rover \
--to=pasky@suse.cz \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.