Skip to contentSkip to conversation

gitweb: gravatar support

PATCH Superseded Giuseppe Bilotta 4 participants 46 messages Jun 15, 2016

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v6 cover gitweb: gravatar support

A new iteration for my gitweb gravatar patch series. This one includes a bunch of new patches, some of which make sense regardless of the gravatar support (particularly patches #3 and #7).

Significant changes from the previous iteration are:

* the feature has been renamed to 'avatar', and 'gravatar' is a possible value for it (currently the only sensible value, other than '');
* an 'alt' attribute is added to img tags, to be more friendly towards text-only browser; no special text is put there, only the avatar provider name (i.e. 'gravatar', currently);
* the last patch adds avatars to signoff lines.

I also trimmed the Cc: list for the series, because it was getting very long and I started feeling like I was spamming around by including everybody ever commented on the series. Please don't feel left out ;-)

Giuseppe Bilotta (8):
gitweb: refactor author name insertion
gitweb: uniform author info for commit and commitdiff
gitweb: right-align date cell in shortlog
gitweb: (gr)avatar support
gitweb: gravatar url cache
gitweb: add 'alt' to avatar images
gitweb: recognize 'trivial' acks
gitweb: add avatar in signoff lines

 gitweb/gitweb.css  |   13 ++++-
 gitweb/gitweb.perl |  170 +++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 148 insertions(+), 35 deletions(-)
#1 lore raw

PATCH v6 1/8 gitweb: refactor author name insertion

Collect all author display code in appropriate functions, making it easiser to extend them on the CGI side, and rely on CSS rather than hard-coded HTML formatting for easier customization.

---
 gitweb/gitweb.css  |    5 ++-
 gitweb/gitweb.perl |   80 +++++++++++++++++++++++++++++++---------------------
 2 files changed, 52 insertions(+), 33 deletions(-)
gitweb/gitweb.css +4 -1
index a01eac8..68b22ff 100644
@@ -132,11 +132,14 @@ div.list_head {
 	font-style: italic;
 }
 
+.author_date, .author {
+	font-style: italic;
+}
+
 div.author_date {
 	padding: 8px;
 	border: solid #d9d8d1;
 	border-width: 0px 0px 1px 0px;
-	font-style: italic;
 }
 
 a.list {
gitweb/gitweb.perl +48 -32

151 lines not on this page · raw message

Signature · 1 line
1.6.3.rc1.192.gdbfcb
#2 lore raw

PATCH v6 2/8 gitweb: uniform author info for commit and commitdiff

---
 gitweb/gitweb.perl |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +5 -1
index 9b60418..cdfd1d5 100755
@@ -5595,7 +5595,11 @@ sub git_commitdiff {
 		git_header_html(undef, $expires);
 		git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
 		git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash);
-		git_print_authorship(\%co, 'localtime' => 1);
+		print "<div class=\"title_text\">\n" .
+		      "<table class=\"object_header\">\n";
+		git_print_full_authorship(\%co);
+		print "</table>".
+		      "</div>\n";
 		print "<div class=\"page_body\">\n";
 		if (@{$co{'comment'}} > 1) {
 			print "<div class=\"log\">\n";
Signature · 1 line
1.6.3.rc1.192.gdbfcb
#3 lore raw

PATCH v6 3/8 gitweb: right-align date cell in shortlog

---
 gitweb/gitweb.css |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
gitweb/gitweb.css +4 -0
index 68b22ff..7240ed7 100644
@@ -180,6 +180,10 @@ table {
 	border-spacing: 0;
 }
 
+table.shortlog td:first-child{
+	text-align: right;
+}
+
 table.diff_tree {
 	font-family: monospace;
 }
Signature · 1 line
1.6.3.rc1.192.gdbfcb
#4 lore raw

PATCH v6 4/8 gitweb: (gr)avatar support

Introduce avatar support: the featuer adds the appropriate img tag next to author and committer in commit(diff), history, shortlog and log view. Multiple avatar providers are possible, but only gravatar is implemented at the moment (and not enabled by default).

Gravatar support depends on Digest::MD5, which is a core package since Perl 5.8. If gravatars are activated but Digest::MD5 cannot be found, the feature will be automatically disabled.

---
 gitweb/gitweb.css  |    4 +++
 gitweb/gitweb.perl |   67 ++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 67 insertions(+), 4 deletions(-)
gitweb/gitweb.css +4 -0
index 7240ed7..ad82f86 100644
@@ -28,6 +28,10 @@ img.logo {
 	border-width: 0px;
 }
 
+img.avatar {
+	vertical-align: middle;
+}
+
 div.page_header {
 	height: 25px;
 	padding: 8px;
gitweb/gitweb.perl +63 -4

115 lines not on this page · raw message

Signature · 1 line
1.6.3.rc1.192.gdbfcb
#5 lore raw

PATCH v6 5/8 gitweb: gravatar url cache

Views which contain many occurrences of the same email address (e.g. shortlog view) benefit from not having to recalculate the MD5 of the email address every time.

---
 gitweb/gitweb.perl |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)
gitweb/gitweb.perl +22 -2
index f2e0cfe..d3bc849 100755
@@ -3257,6 +3257,27 @@ sub git_print_header_div {
 	      "\n</div>\n";
 }
 
+# Rather than recomputing the url for an email multiple times, we cache it
+# after the first hit. This gives a visible benefit in views where the avatar
+# for the same email is used repeatedly (e.g. shortlog).
+# The cache is shared by all avatar engines (currently gravatar only), which
+# are free to use it as preferred. Since only one avatar engine is used for any
+# given page, there's no risk for cache conflicts.
+our %avatar_cache = ();
+
+# Compute the gravatar url for a given email, if it's not in the cache already.
+# Gravatar stores only the part of the URL before the size, since that's the
+# one computationally more expensive. This also allows reuse of the cache for
+# different sizes (for this particular engine).
+sub gravatar_url {
+	my $email = lc shift;
+	my $size = shift;
+	$avatar_cache{$email} ||=
+		"http://www.gravatar.com/avatar.php?gravatar_id=" .
+			Digest::MD5::md5_hex($email) . "&amp;size=";
+	return $avatar_cache{$email} . $size;
+}
+
 # Insert an avatar for the given $email at the given $size if the feature
 # is enabled.
 sub git_get_avatar {
@@ -3266,8 +3287,7 @@ sub git_get_avatar {
 	my $size = $avatar_size{$params{'size'}} || $avatar_size{'default'};
 	my $url = "";
 	if ($git_avatar eq 'gravatar') {
-		$url = "http://www.gravatar.com/avatar.php?gravatar_id=" .
-			Digest::MD5::md5_hex(lc $email) . "&amp;size=$size";
+		$url = gravatar_url($email, $size);
 	}
 	# Currently only gravatars are supported, but other forms such as
 	# picons can be added by putting an else up here and defining $url
Signature · 1 line
1.6.3.rc1.192.gdbfcb
#6 lore raw

PATCH v6 6/8 gitweb: add 'alt' to avatar images

Without it, text-only browsers display the URL of the avatar, which can be long and not very informative. We use the avatar provider name for the alt text.

---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +1 -1
index d3bc849..3e6786b 100755
@@ -3294,7 +3294,7 @@ sub git_get_avatar {
 	# as needed. If no variant puts something in $url, we assume avatars
 	# are completely disabled/unavailable.
 	if ($url) {
-		return $pre_white . "<img class=\"avatar\" src=\"$url\" />" . $post_white;
+		return $pre_white . "<img class=\"avatar\" src=\"$url\" alt=\"$git_avatar\" />" . $post_white;
 	} else {
 		return "";
 	}
Signature · 1 line
1.6.3.rc1.192.gdbfcb
#7 lore raw

PATCH v6 7/8 gitweb: recognize 'trivial' acks

Sometimes patches are trivially acked rather than just acked, so extend the signoff regexp to include this case.

---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +1 -1
index 3e6786b..7ca115f 100755
@@ -3403,7 +3403,7 @@ sub git_print_log {
 	my $signoff = 0;
 	my $empty = 0;
 	foreach my $line (@$log) {
-		if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
+		if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|(?:trivially[ \-])?acked[ \-]by[ :]|cc[ :])/i) {
 			$signoff = 1;
 			$empty = 0;
 			if (! $opts{'-remove_signoff'}) {
Signature · 1 line
1.6.3.rc1.192.gdbfcb
#8 lore raw

PATCH v6 8/8 gitweb: add avatar in signoff lines

---

I can't say I'm really satisfied with the layout given by this patch. A significant improvement could be obtained by turning the signoff line block into a table with three/four columns (signoff, name, email/avatar). But we cannot guarantee that signoff lines come all together in a block, so this would be more complex to implement.

 gitweb/gitweb.perl |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +4 -1
index 7ca115f..d385f55 100755
@@ -3407,7 +3407,10 @@ sub git_print_log {
 			$signoff = 1;
 			$empty = 0;
 			if (! $opts{'-remove_signoff'}) {
-				print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
+				my ($email) = $line =~ /<(\S+@\S+)>/;
+				print "<span class=\"signoff\">" . esc_html($line) . "</span>";
+				print git_get_avatar($email, 'pad_before' => 1) if $email;
+				print "<br/>\n";
 				next;
 			} else {
 				# remove signoff lines
Signature · 1 line
1.6.3.rc1.192.gdbfcb
#9 lore raw

[PATCHv6 9/8] gitweb: put signoff lines in a table

This allows us to give better alignments to the components.

---

Better, but still far from perfect.

 gitweb/gitweb.css  |    6 +++++-
 gitweb/gitweb.perl |   47 +++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 46 insertions(+), 7 deletions(-)
gitweb/gitweb.css +5 -1
index ad82f86..21c24fa 100644
@@ -115,10 +115,14 @@ span.age {
 	font-style: italic;
 }
 
-span.signoff {
+.signoff {
 	color: #888888;
 }
 
+table.signoff td:first-child {
+	text-align: right;
+}
+
 div.log_link {
 	padding: 0px 8px;
 	font-size: 70%;
gitweb/gitweb.perl +41 -6

63 lines not on this page · raw message

Signature · 1 line
1.6.3.rc1.192.gdbfcb
#10 lore raw

Re: [PATCHv6 9/8] gitweb: put signoff lines in a table

Quoted 6 lines · Giuseppe Bilotta

This allows us to give better alignments to the components.

---

Better, but still far from perfect.

I don't like it. NAK from me (for this experimental patch).

First it breaks correspondence between gitweb's 'commit'/'commitdiff' view and git-show, and between gitweb's 'log' view and git-log. I'd rather we kept that gitweb output is similar to CLI output, so somebody familiar with one of them would have it easy understanding the other. Consistency in output.

Second, I have checked how it looks like in few examples:
e1d37937 (different types of signoff) and 8dfb17e1 (empty line in signoff block) and I have the following complaints:
* There is extra vertical whitespace between signoff lines
* The ':' character terminating signoffs is lost
* Empty line vanished (which might be considered good thing).

Quoted 10 lines
 gitweb/gitweb.css  |    6 +++++-
 gitweb/gitweb.perl |   47 +++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 46 insertions(+), 7 deletions(-)
gitweb/gitweb.css +0 -0
index ad82f86..21c24fa 100644

gitweb/gitweb.css span.age { · line 120

Quoted 7 lines
gitweb/gitweb.css +1 -1
@@ -115,10 +115,14 @@ span.age {
 	font-style: italic;
 }
 
-span.signoff {
+.signoff {
 	color: #888888;
 }

This change might be good to have nevertheless, for future extendability.

gitweb/gitweb.css span.age { · line 124

Quoted 4 lines
gitweb/gitweb.css +3 -0
+table.signoff td:first-child {
+	text-align: right;
+}

Advanced CSS selector. Not all web browsers support it (although nowadays I suppose most do support ':first-child' pseudo-class).

Quoted 9 lines
gitweb/gitweb.css +1 -0
+
 div.log_link {
 	padding: 0px 8px;
 	font-size: 70%;
gitweb/gitweb.perl +0 -0
index d385f55..53b8817 100755

gitweb/gitweb.perl sub git_print_log { · line 3408

Quoted 9 lines
gitweb/gitweb.perl +3 -2
@@ -3402,15 +3402,31 @@ sub git_print_log {
 	# print log
 	my $signoff = 0;
 	my $empty = 0;
+	my $signoff_table = 0;
 	foreach my $line (@$log) {
-		if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|(?:trivially[ \-])?acked[ \-]by[ :]|cc[ :])/i) {
-			$signoff = 1;
+		if ($line =~ s/^ *(signed[ \-]off[ \-]by|(?:trivially[ \-])?acked[ \-]by|cc|looks[ \-]right[ \-]to[ \-]me[ \-]by)[ :]//i) {
+			$signoff = $1;

Extending regexp for signoff matching is _independent_ change, and IMHO should be put in separate commit (perhaps squashed in 7/8). We really need to do something about it, as this regexp starts to be unwieldingly long... but this issue is already discussed in subthread for patch 7/8 in this series.

You changed "$signoff = 1;" to "$signoff = $1;" and later catch $email... why not do it in the same line, using single (more complicated) regexp?

Also you don't catch terminating ':' in $signoff (see complain above).

Quoted 30 lines
gitweb/gitweb.perl +19 -4
 			$empty = 0;
 			if (! $opts{'-remove_signoff'}) {
-				my ($email) = $line =~ /<(\S+@\S+)>/;
-				print "<span class=\"signoff\">" . esc_html($line) . "</span>";
-				print git_get_avatar($email, 'pad_before' => 1) if $email;
-				print "<br/>\n";
+				if (!$signoff_table) {
+					print "<table class=\"signoff\">\n";
+					$signoff_table = 1;
+				}
+				my $email;
+				if ($line =~ s/\s*<(\S+@\S+)>//) {
+					$email = $1;
+				}
+				print "<tr>";
+				print "<td>$signoff</td>";
+				print "<td>" . esc_html($line) . "</td>";
+				if ($email && $git_avatar) {
+					print "<td>";
+					print git_get_avatar($email);
+					print "</td>";
+				} else {
+					print "<td>" . esc_html("<$email>") . "</td>";
+				}
+				print "</tr>\n";
 				next;
 			} else {
 				# remove signoff lines
@@ -3429,7 +3445,26 @@ sub git_print_log {
 			$empty = 0;

gitweb/gitweb.perl sub git_print_log { · line 3455

Quoted 10 lines
gitweb/gitweb.perl +8 -0
 		}
 
+		# if we're in a signoff block, empty lines
+		# are empty rows, other lines terminate
+		# the block
+		if ($signoff_table) {
+			if ($empty) {
+				print "<tr />\n";
+				next;
+			}

I'd rather use "<tr></tr>\n" here instead.

Quoted 6 lines
gitweb/gitweb.perl +4 -0
+			print "</table>\n";
+			$signoff_table = 0;
+		}
+
 		print format_log_line_html($line) . "<br/>\n";

gitweb/gitweb.perl sub git_print_log { · line 3470

Quoted 10 lines
gitweb/gitweb.perl +7 -0
+
+	}
+
+	# close the signoff table if it's still open
+	if ($signoff_table) {
+		print "</table>\n";
+		$signoff_table = 0;
 	}
 
 	if ($opts{'-final_empty_line'}) {

Much more complicated code, not much gain IMHO. It is not worth it (even if you think that the layout is better; I don't think that).

Signature · 2 lines
Jakub Narebski
Poland
#11 lore raw

Re: [PATCHv6 8/8] gitweb: add avatar in signoff lines

In reply to Giuseppe Bilotta
Quoted 1 line · Giuseppe Bilotta

BTW. if it is an RFC, it should be marked as RFC in subject ("[RFC PATCHv6 8/8] gitweb: add avatar in signoff lines").

And I guess this issue should be left for later.

Quoted 6 lines

---

I can't say I'm really satisfied with the layout given by this patch. A significant improvement could be obtained by turning the signoff line block into a table with three/four columns (signoff, name, email/avatar).

First, I think adding (gr)avatars to signoff lines might be not worth it. Neither GitHub nor Gitorious show gravatars for signoff lines (note that they use larger images, and therefore easier to view).

Second, it is not the only possible layout. Let's use one of existing commits (e1d3793) in git repository as example:

  completion: add --thread=deep/shallow to format-patch
  [1] Signed-off-by: Stephen Boyd <[email protected]> [2]          [3]            [4]|
  [1] Trivially-Acked-By: Shawn O. Pearce <[email protected]> [2] [3]            [4]|
  [1] Signed-off-by: Junio C Hamano <[email protected]> [2]         [3]            [4]|

Even without changing layout of signoff lines (so they look exactly like they look in git-show or git-log output, modulo highlighting and (gr)avatars), there are more possibilities:

1. On the left side of signoff lines
2. Current version: on the right side of signoff lines, just after
3. On the right hand side, aligned; would probably need table
4. On the right hand side, flushed (floated) right

There is also more complicated solution of having (gr)avatars appear only on mouseover, either all avatars on hover over signoff block, or single (and perhaps larger size) avatar on hover over signoff line. This can be done using pure CSS, without JavaScript[1]

[1] http://meyerweb.com/eric/css/edge/popups/demo2.html

Quoted 2 lines

But we cannot guarantee that signoff lines come all together in a block, so this would be more complex to implement.

Actually I think we can assume that signoff lines come all together in single block at the very end of commit message; we should take into account possibility of spurious empty lines between signoff lines, though (it did happen, see e.g. 8dfb17e1).

Quoted 11 lines
 gitweb/gitweb.perl |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +0 -0
index 7ca115f..d385f55 100755
@@ -3407,7 +3407,10 @@ sub git_print_log {
 			$signoff = 1;

gitweb/gitweb.perl sub git_print_log { · line 3416

Quoted 10 lines
gitweb/gitweb.perl +4 -1
 			$empty = 0;
 			if (! $opts{'-remove_signoff'}) {
-				print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
+				my ($email) = $line =~ /<(\S+@\S+)>/;
+				print "<span class=\"signoff\">" . esc_html($line) . "</span>";
+				print git_get_avatar($email, 'pad_before' => 1) if $email;
+				print "<br/>\n";
 				next;
 			} else {
 				# remove signoff lines

And here is version with (gr)avatar on the left side of signoff lines (take a look if it is not better layout):

gitweb/gitweb.perl +2 -0
index 301bdd8..7701bac 100755
@@ -3407,6 +3407,8 @@ sub git_print_log {
 			$signoff = 1;
 			$empty = 0;
 			if (! $opts{'-remove_signoff'}) {
+				my ($email) = $line =~ /<(\S+@\S+)>/;
+				print git_get_avatar($email, 'pad_after' => 1) if $email;
 				print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
 				next;
 			} else {
Signature · 2 lines
Jakub Narebski
Poland
#12 lore raw

Re: [PATCHv6 8/8] gitweb: add avatar in signoff lines

2009/6/27 Jakub Narebski <[email protected]>:

Quoted 8 lines · Giuseppe Bilotta
Quoted 2 lines

BTW. if it is an RFC, it should be marked as RFC in subject ("[RFC PATCHv6 8/8] gitweb: add avatar in signoff lines").

And I guess this issue should be left for later.

You're right. My next patchset will not include this part (I'll send it separately).

Quoted 8 lines
Quoted 4 lines

I can't say I'm really satisfied with the layout given by this patch. A significant improvement could be obtained by turning the signoff line block into a table with three/four columns (signoff, name, email/avatar).

First, I think adding (gr)avatars to signoff lines might be not worth it.  Neither GitHub nor Gitorious show gravatars for signoff lines (note that they use larger images, and therefore easier to view).

Well, just because the others don't do it, it doesn't mean we shouldn't either ;-)

But yes, I have to confess I love toying around like this.

Quoted 9 lines

Second, it is not the only possible layout.  Let's use one of existing commits (e1d3793) in git repository as example:

 completion: add --thread=deep/shallow to format-patch

 [1] Signed-off-by: Stephen Boyd <[email protected]> [2]          [3]            [4]|
 [1] Trivially-Acked-By: Shawn O. Pearce <[email protected]> [2] [3]            [4]|
 [1] Signed-off-by: Junio C Hamano <[email protected]> [2]         [3]            [4]|

Quoted 8 lines

Even without changing layout of signoff lines (so they look exactly like they look in git-show or git-log output, modulo highlighting and (gr)avatars), there are more possibilities:

 1. On the left side of signoff lines
 2. Current version: on the right side of signoff lines, just after
 3. On the right hand side, aligned; would probably need table
 4. On the right hand side, flushed (floated) right

I have a table implementation running @ http://git.oblomov.eu/git/commit/e1d3793

Quoted 6 lines

There is also more complicated solution of having (gr)avatars appear only on mouseover, either all avatars on hover over signoff block, or single (and perhaps larger size) avatar on hover over signoff line. This can be done using pure CSS, without JavaScript[1]

[1] http://meyerweb.com/eric/css/edge/popups/demo2.html

Oh, that'd be an interesting variant. Straightforward to implement in the table case, too.

Quoted 8 lines

And here is version with (gr)avatar on the left side of signoff lines (take a look if it is not better layout):

gitweb/gitweb.perl +0 -0
index 301bdd8..7701bac 100755

gitweb/gitweb.perl sub git_print_log { · line 3414

Quoted 8 lines
gitweb/gitweb.perl +2 -0
@@ -3407,6 +3407,8 @@ sub git_print_log {
                        $signoff = 1;
                        $empty = 0;
                        if (! $opts{'-remove_signoff'}) {
+                               my ($email) = $line =~ /<(\S+@\S+)>/;
+                               print git_get_avatar($email, 'pad_after' => 1) if $email;
                                print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
                                next;
                        } else {

I think that putting them aligned on the right is somewhat better because both in commit(diff) and in log view the author/committer avatar is already on the right.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
Acked-by on v6 7/8
#13 lore raw

Re: [PATCHv6 7/8] gitweb: recognize 'trivial' acks

In reply to Giuseppe Bilotta
Quoted 4 lines · Giuseppe Bilotta

Sometimes patches are trivially acked rather than just acked, so extend the signoff regexp to include this case.

This is straghtforward enough.

Quoted 21 lines
---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +1 -1
index 3e6786b..7ca115f 100755
@@ -3403,7 +3403,7 @@ sub git_print_log {
 	my $signoff = 0;
 	my $empty = 0;
 	foreach my $line (@$log) {
-		if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
+		if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|(?:trivially[ \-])?acked[ \-]by[ :]|cc[ :])/i) {
 			$signoff = 1;
 			$empty = 0;
 			if (! $opts{'-remove_signoff'}) {
Signature · 1 line
1.6.3.rc1.192.gdbfcb
Signature · 2 lines
Jakub Narebski
Poland
#14 lore raw

Re: [PATCHv6 7/8] gitweb: recognize 'trivial' acks

In reply to Giuseppe Bilotta

gitweb/gitweb.perl sub git_print_log { · line 3406

Quoted 3 lines · Giuseppe Bilotta
gitweb/gitweb.perl +1 -1
 	foreach my $line (@$log) {
-		if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
+		if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|(?:trivially[ \-])?acked[ \-]by[ :]|cc[ :])/i) {

Wouldn't it make more sense to do something like:

	if ($line =~ m/^[-a-z]+: (.*)$/i && looks_like_a_name_and_email($1)) {
            	... do the avatar thing ...
	}

and limit this processing only to the last run of no-blank lines?

#15 lore raw

Re: [PATCHv6 7/8] gitweb: recognize 'trivial' acks

Quoted 6 lines · Junio C Hamano
Quoted 3 lines · Giuseppe Bilotta

      foreach my $line (@$log) {
-             if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
+             if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|(?:trivially[ \-])?acked[ \-]by[ :]|cc[ :])/i) {

Quoted 7 lines

Wouldn't it make more sense to do something like:

       if ($line =~ m/^[-a-z]+: (.*)$/i && looks_like_a_name_and_email($1)) { ... do the avatar thing ...
       }

and limit this processing only to the last run of no-blank lines?

I've been thinking about doing something like this, especially since the next iteration this patch also adds 'Looks-fine-to-me-by' (spearce really _loves_ customizing its signoffs lines during reviews 8-D).

The main difference between the two sections of the code is that the original code allows whitespace instead of dashes in the signoff lead-in, and the lead-in itself is OPTIONALLY terminated by a colon.

If we can lose this, then ^\s*[-a-z]+: followed by what looks like a name and email can be a detector. An alternative would be to keep the current signoff detector as-is and ADD the generic one, possibly under the condition that we are already parsing signoffs.

The idea of accepting those lines as signoffs only at the end of the commit log is also a good idea, but has the problem of requiring some form of look-ahead. Two possible logics:

(1) when something that looks like a signoff is met, stash it away, and keep collecting signoff-lookalikes and empty lines until either a non-signoff-lookalike (in which case the previous lines are NOT signoff) or the log end is met (in which case we print them as signoff lines).

(2) same as before, but two or more consecutive signoff-lookalikes are a signoff block regardless of what follows them.

Which one should I go with?

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#16 lore raw

Re: [PATCHv6 6/8] gitweb: add 'alt' to avatar images

In reply to Giuseppe Bilotta
Quoted 2 lines · Giuseppe Bilotta

Without it, text-only browsers display the URL of the avatar, which can be long and not very informative.

Actually different text-only web browsers behave differently (with default settings).

Before this patch:
* lynx show basename of the URL of the avatar, which ain't pretty [avatar.php?gravatar_id=955680802bc3d50476786bb3ca9cfc52&amp;size=16]
* elinks doesn't show by default images at all, which means that only &nbsp; used for padding will be visible (don't use &nbsp;?)
* w3m show basename of avatar URL without extension nor query string:
[avatar]

After this patch:
* lynx show alt text, i.e. 'gravatar' (no [] to mark as image)
* elinks show alt text, i.e. 'gravatar' (no [] to mark as image)
* w3m show alt text, i.e. gravatar, in separate color (also no [])

Lynx Version 2.8.5rel.1
ELinks 0.10.3
w3m version w3m/0.5.1+cvs-1.946

Quoted 1 line

We use the avatar provider name for the alt text.

I am not sure if 'type of avatar' wouldn't be easier to understand than 'avatar provider name'. OTOH the latter is more correct. Perhaps "We use the avatar provider (type of avatar) for the alt text"? But that is just nitpicking...

Quoted 11 lines
---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +0 -0
index d3bc849..3e6786b 100755

gitweb/gitweb.perl sub git_get_avatar { · line 3300

Quoted 8 lines
gitweb/gitweb.perl +1 -1
@@ -3294,7 +3294,7 @@ sub git_get_avatar {
 	# as needed. If no variant puts something in $url, we assume avatars
 	# are completely disabled/unavailable.
 	if ($url) {
-		return $pre_white . "<img class=\"avatar\" src=\"$url\" />" . $post_white;
+		return $pre_white . "<img class=\"avatar\" src=\"$url\" alt=\"$git_avatar\" />" . $post_white;
 	} else {
 		return "";
 	}

Nice, simple improvement.

Quoted 4 lines
Signature · 1 line
1.6.3.rc1.192.gdbfcb
Signature · 2 lines
Jakub Narebski
Poland
#17 lore raw

Re: [PATCHv6 6/8] gitweb: add 'alt' to avatar images

2009/6/27 Jakub Narebski <[email protected]>:

Quoted 7 lines

After this patch:
 * lynx   show alt text, i.e. 'gravatar' (no [] to mark as image)
 * elinks show alt text, i.e. 'gravatar' (no [] to mark as image)
 * w3m show alt text, i.e. gravatar, in separate color (also no [])

Lynx Version 2.8.5rel.1
ELinks 0.10.3

That's an old version of ELinks. ELinks 0.12 I think changed this behaviour to at least try and display ALT tags by default.

-- Thomas Adam

Acked-by on v6 5/8
#18 lore raw

Re: [PATCHv6 5/8] gitweb: gravatar url cache

In reply to Giuseppe Bilotta
Quoted 3 lines · Giuseppe Bilotta

Views which contain many occurrences of the same email address (e.g. shortlog view) benefit from not having to recalculate the MD5 of the email address every time.

It would be nice to have some benchmarks comparing performance before and after this patch.

Quoted 2 lines
Quoted 9 lines
---
 gitweb/gitweb.perl |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)
gitweb/gitweb.perl +0 -0
index f2e0cfe..d3bc849 100755

gitweb/gitweb.perl sub git_print_header_div { · line 3266

Quoted 10 lines
gitweb/gitweb.perl +7 -0
@@ -3257,6 +3257,27 @@ sub git_print_header_div {
 	      "\n</div>\n";
 }
 
+# Rather than recomputing the url for an email multiple times, we cache it
+# after the first hit. This gives a visible benefit in views where the avatar
+# for the same email is used repeatedly (e.g. shortlog).
+# The cache is shared by all avatar engines (currently gravatar only), which
+# are free to use it as preferred. Since only one avatar engine is used for any
+# given page, there's no risk for cache conflicts.
+our %avatar_cache = ();

Nice explanation.

gitweb/gitweb.perl sub git_print_header_div { · line 3279

Quoted 13 lines
gitweb/gitweb.perl +13 -0
+
+# Compute the gravatar url for a given email, if it's not in the cache already.
+# Gravatar stores only the part of the URL before the size, since that's the
+# one computationally more expensive. This also allows reuse of the cache for
+# different sizes (for this particular engine).
+sub gravatar_url {
+	my $email = lc shift;
+	my $size = shift;
+	$avatar_cache{$email} ||=
+		"http://www.gravatar.com/avatar.php?gravatar_id=" .
+			Digest::MD5::md5_hex($email) . "&amp;size=";
+	return $avatar_cache{$email} . $size;
+}

Nice solution. Very good.

I guess it is not worth it to _not_ use cache for few avatars views such as 'commit', 'commitdiff', in the future also 'tag' view, isn't it?

BTW. http://www.gravatar.com/site/implement/url recommends
http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802 rather than
http://www.gravatar.com/avatar.php?gravatar_id=3b3be63a4c2a439b013787725dfce802
you use, following http://www.gravatar.com/site/implement/perl
Hmmm...

Quoted 5 lines
gitweb/gitweb.perl +1 -0
+
 # Insert an avatar for the given $email at the given $size if the feature
 # is enabled.
 sub git_get_avatar {

gitweb/gitweb.perl sub git_get_avatar { · line 3293

Quoted 9 lines
gitweb/gitweb.perl +1 -2
@@ -3266,8 +3287,7 @@ sub git_get_avatar {
 	my $size = $avatar_size{$params{'size'}} || $avatar_size{'default'};
 	my $url = "";
 	if ($git_avatar eq 'gravatar') {
-		$url = "http://www.gravatar.com/avatar.php?gravatar_id=" .
-			Digest::MD5::md5_hex(lc $email) . "&amp;size=$size";
+		$url = gravatar_url($email, $size);
 	}
 	# Currently only gravatars are supported, but other forms such as
 	# picons can be added by putting an else up here and defining $url

Very nice.

Quoted 4 lines
Signature · 1 line
1.6.3.rc1.192.gdbfcb
Signature · 2 lines
Jakub Narebski
Poland
#19 lore raw

Re: [PATCHv6 5/8] gitweb: gravatar url cache

2009/6/27 Jakub Narebski <[email protected]>:

Quoted 8 lines · Giuseppe Bilotta
Quoted 4 lines

Views which contain many occurrences of the same email address (e.g. shortlog view) benefit from not having to recalculate the MD5 of the email address every time.

It would be nice to have some benchmarks comparing performance before and after this patch.

Indeed it would.

Oh, you mean I should provide them? 8-D

(I'll see if I can get around it this weekend)

Quoted 2 lines

I guess it is not worth it to _not_ use cache for few avatars views such as 'commit', 'commitdiff', in the future also 'tag' view, isn't it?

I would say not.

Quoted 4 lines

BTW. http://www.gravatar.com/site/implement/url recommends
http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802 rather than
http://www.gravatar.com/avatar.php?gravatar_id=3b3be63a4c2a439b013787725dfce802
you use, following http://www.gravatar.com/site/implement/perl

I think the perl code there is just obsolete (the /avarar/ thing is more recent). I'll update to the new one because it's more compact.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#20 lore raw

Re: [PATCHv6 5/8] gitweb: gravatar url cache

Quoted 9 lines · Giuseppe Bilotta

2009/6/27 Jakub Narebski <[email protected]>:

Quoted 4 lines

BTW. http://www.gravatar.com/site/implement/url recommends
http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802 rather than
http://www.gravatar.com/avatar.php?gravatar_id=3b3be63a4c2a439b013787725dfce802
you use, following http://www.gravatar.com/site/implement/perl

I think the perl code there is just obsolete (the /avatar/ thing is more recent). I'll update to the new one because it's more compact.

I think that Gravatar::URL module on CPAN[1] (which we cannot use in gitweb because it is extra nonstandard non-core not needed dependency) also uses newer path_info form.

[1] http://p3rl.org/Gravatar::URL

Signature · 2 lines
Jakub Narebski
Poland
#21 lore raw

Re: [PATCHv6 4/8] gitweb: (gr)avatar support

In reply to Giuseppe Bilotta
Quoted 2 lines · Giuseppe Bilotta

Introduce avatar support: the featuer adds the appropriate img tag next to author and committer in commit(diff), history, shortlog and log view.

You forgot about 'tag' view (but I guess it would be done in next version of this patch series).

There is also 'feed' action (Atom and RSS formats), but that is certainly separate issue, for a separate patch.

Quoted 8 lines

Multiple avatar providers are possible, but only gravatar is implemented at the moment (and not enabled by default).

Gravatar support depends on Digest::MD5, which is a core package since Perl 5.8. If gravatars are activated but Digest::MD5 cannot be found, the feature will be automatically disabled.

Quoted 4 lines
---
 gitweb/gitweb.css  |    4 +++
 gitweb/gitweb.perl |   67 ++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 67 insertions(+), 4 deletions(-)

You would _probably_ want to squash the following, just in case:

t/t9500-gitweb-standalone-no-errors.sh +2 -0
index d539619..e8b57c5 100755
@@ -660,6 +660,7 @@ cat >>gitweb_config.perl <<EOF
 
 \$feature{'blame'}{'override'} = 1;
 \$feature{'snapshot'}{'override'} = 1;
+\$feature{'avatar'}{'override'} = 1;
 EOF
 
 test_expect_success \
@@ -678,6 +679,7 @@ test_expect_success \
 	'config override: tree view, features enabled in repo config (1)' \
 	'git config gitweb.blame yes &&
 	 git config gitweb.snapshot "zip,tgz, tbz2" &&
+	 git config gitweb.avatar gravatar &&
 	 gitweb_run "p=.git;a=tree"'
 test_debug 'cat gitweb.log'
 

(this is not yet a proper solution).

But even if you don't squash it, please run t9500 with this patch applied, to catch Perl errors and warnings.

gitweb/gitweb.css img.logo { · line 34

Quoted 13 lines
gitweb/gitweb.css +4 -0
index 7240ed7..ad82f86 100644
@@ -28,6 +28,10 @@ img.logo {
 	border-width: 0px;
 }
 
+img.avatar {
+	vertical-align: middle;
+}
+

Good. All concerns were addressed.

Quoted 9 lines
gitweb/gitweb.css +0 -0
 div.page_header {
 	height: 25px;
 	padding: 8px;
gitweb/gitweb.perl +0 -0
index cdfd1d5..f2e0cfe 100755
@@ -195,6 +195,14 @@ our %known_snapshot_format_aliases = (
 	'x-zip' => undef, '' => undef,

gitweb/gitweb.perl our %known_snapshot_format_aliases = ( · line 205

Quoted 10 lines
gitweb/gitweb.perl +8 -0
 );
 
+# Pixel sizes for icons and avatars. If the default font sizes or lineheights
+# are changed, it may be appropriate to change these values too via
+# $GITWEB_CONFIG.
+our %avatar_size = (
+	'default' => 16,
+	'double'  => 32
+);
+

Nice.

Quoted 4 lines
gitweb/gitweb.perl +0 -0
 # You define site-wide feature defaults here; override them with
 # $GITWEB_CONFIG as necessary.
 our %feature = (

gitweb/gitweb.perl our %feature = ( · line 382

Quoted 10 lines
gitweb/gitweb.perl +7 -0
@@ -365,6 +373,22 @@ our %feature = (
 		'sub' => \&feature_patches,
 		'override' => 0,
 		'default' => [16]},
+
+	# Avatar support. When this feature is enabled, views such as
+	# shortlog or commit will display an avatar associated with
+	# the email of the committer(s) and/or author(s).
+
+	# Currently only the gravatar provider is available, and it
+	# depends on Digest::MD5.

Sidenote: Gravatar API description[1] mentions 'identicon', 'monsterid', 'wavatar'. There are 'picons' (personal icons)[2]. Also avatars doesn't need to be global: they can be some local static image somewhere in web server which serves gitweb script, or they can be stored somewhere in repository following some convention.

Current implementation is flexible enough to leave place for extending this feature, but also doesn't try to plan too far in advance. YAGNI (You Ain't Gonna Need It).

[1] http://www.gravatar.com/site/implement/url
[2] http://www.cs.indiana.edu/picons/ftp/faq.html

gitweb/gitweb.perl our %feature = ( · line 391

Quoted 9 lines
gitweb/gitweb.perl +9 -0
+
+	# To enable system wide have in $GITWEB_CONFIG
+	# $feature{'avatar'}{'default'} = ['gravatar'];
+	# To have project specific config enable override in $GITWEB_CONFIG
+	# $feature{'avatar'}{'override'} = 1;
+	# and in project config gitweb.avatar = gravatar;
+	'avatar' => {
+		'override' => 0,
+		'default' => ['']},

Note that to disable feature with non-boolean 'default' we use empty list [] (which means 'undef' when parsing, which is false); see description of features 'snapshot', 'actions'; 'ctags' what is strange uses [0] here... Using [''] is a bit strange; and does not protect you, I think.

gitweb/gitweb.perl $git_dir = "$projectroot/$project" if $project; · line 842

Quoted 9 lines
gitweb/gitweb.perl +2 -0
 );
 
 sub gitweb_get_feature {
@@ -814,6 +838,13 @@ $git_dir = "$projectroot/$project" if $project;
 our @snapshot_fmts = gitweb_get_feature('snapshot');
 @snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
 
+# check if avatars are enabled and dependencies are satisfied
+our ($git_avatar) = gitweb_get_feature('avatar');

IMPORTANT!!!

Because you now allow possibility that there can be other avatars than those provided by Gravatar, you should explain in comment what this check below does (e.g. something like "load Digest::MD5, required for gravatar support, and disable it if it does not exist"), so people adding (in the future) support for other kind of avatars would know that they should put similar test there, if needed.

gitweb/gitweb.perl $git_dir = "$projectroot/$project" if $project; · line 846

Quoted 4 lines
gitweb/gitweb.perl +4 -0
+if (($git_avatar eq 'gravatar') &&
+   !(eval { require Digest::MD5; 1; })) {
+	$git_avatar = '';
+}

Here you would have to protect against $git_avatar being undefined... but you should do it anyway, as gitweb_get_feature() can return undef / empty list.

So either

  +our ($git_avatar) = gitweb_get_feature('avatar') || '';

or

  +if (defined $git_avatar && $git_avatar eq 'gravatar' &&
  +   !(eval { require Digest::MD5; 1; })) {
  +	$git_avatar = '';
  +}

gitweb/gitweb.perl sub format_author_html { · line 1513

Quoted 13 lines
gitweb/gitweb.perl +4 -1
+
 # dispatch
 if (!defined $action) {
 	if (defined $hash) {
@@ -1476,7 +1507,9 @@ sub format_author_html {
 	my $tag = shift;
 	my $co = shift;
 	my $author = chop_and_escape_str($co->{'author_name'}, @_);
-	return "<$tag class=\"author\">" . $author . "</$tag>\n";
+	return "<$tag class=\"author\">" .
+	       git_get_avatar($co->{'author_email'}, 'pad_after' => 1) .
+	       $author . "</$tag>\n";
 }

Ah, it uses the fact that format_author_html is used in 'history' and 'shortlog' views, to format only author name for 'Author' column.

BTW. wouldn't it be better if git_get_avatar was defined _before_ this use?

This might be good enough starting point, but I wonder if it wouldn't be a better solution to provide additional column with avatar image when avatar support is enabled. You would get a better layout in a very rare case[3] when 'Author' column is too narrow and author is info is wrapped:

[#] Jonathan
H. Random

versus in separate columns case:

[#] | Jonathan
| H. Random

But this is a very minor problem, which can be left for separate patch.

[3] unless you use netbook or phone to browse...

gitweb/gitweb.perl sub git_print_header_div { · line 3266

Quoted 13 lines
gitweb/gitweb.perl +7 -0
 # format git diff header line, i.e. "diff --(git|combined|cc) ..."
@@ -3224,6 +3257,29 @@ sub git_print_header_div {
 	      "\n</div>\n";
 }
 
+# Insert an avatar for the given $email at the given $size if the feature
+# is enabled.
+sub git_get_avatar {
+	my ($email, %params) = @_;
+	my $pre_white  = ($params{'pad_before'} ? "&nbsp;" : "");
+	my $post_white = ($params{'pad_after'}  ? "&nbsp;" : "");
+	my $size = $avatar_size{$params{'size'}} || $avatar_size{'default'};

The same comment as for first patch in series: gitweb uses %opts not %params, and '-size' not 'size' (CGI-like).

gitweb/gitweb.perl sub git_print_header_div { · line 3275

Quoted 9 lines
gitweb/gitweb.perl +9 -0
+	my $url = "";
+	if ($git_avatar eq 'gravatar') {
+		$url = "http://www.gravatar.com/avatar.php?gravatar_id=" .
+			Digest::MD5::md5_hex(lc $email) . "&amp;size=$size";
+	}
+	# Currently only gravatars are supported, but other forms such as
+	# picons can be added by putting an else up here and defining $url
+	# as needed. If no variant puts something in $url, we assume avatars
+	# are completely disabled/unavailable.

Very nice solution to provide support for future alternate avatar sources, like picons or local images (for a gitweb installation).

gitweb/gitweb.perl sub git_print_header_div { · line 3281

Quoted 6 lines
gitweb/gitweb.perl +6 -0
+	if ($url) {
+		return $pre_white . "<img class=\"avatar\" src=\"$url\" />" . $post_white;
+	} else {
+		return "";
+	}
+}

Nice idea.

gitweb/gitweb.perl sub git_print_authorship { · line 3304

Quoted 12 lines
gitweb/gitweb.perl +3 -1
+
 # Outputs the author name and date in long form
 sub git_print_authorship {
 	my $co = shift;
@@ -3243,7 +3299,8 @@ sub git_print_authorship {
 			       $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
 		}
 	}
-	print "]</$tag>\n";
+	print "]" . git_get_avatar($co->{'author_email'}, 'pad_before' => 1)
+		  . "</$tag>\n";
 }

Nice solution for 'log' and perhaps 'commitdiff' views.

gitweb/gitweb.perl sub git_print_full_authorship { · line 3312

Quoted 9 lines
gitweb/gitweb.perl +2 -1
 # Outputs table rows containign the full author and commiter information.
@@ -3251,7 +3308,8 @@ sub git_print_full_authorship {
 	my $co = shift;
 	my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
 	my %cd = parse_date($co->{'committer_epoch'}, $co->{'committer_tz'});
-	print "<tr><td>author</td><td>" . esc_html($co->{'author'}) . "</td></tr>\n".
+	print "<tr><td>author</td><td>" . esc_html($co->{'author'}) . "</td>".
+	      "<td rowspan=\"2\">" .git_get_avatar($co->{'author_email'}, 'size' => 'double') . "</td></tr>\n" .

Nitpick: perhaps it would be better to put git_get_avatar invocation in separate line, to limit line length.

Minor nitpick: use ". git_get_avatar(...", i.e. space between '.' string concatenation operator and 'git_get_avatar'.

gitweb/gitweb.perl sub git_print_full_authorship { · line 3328

Quoted 13 lines
gitweb/gitweb.perl +2 -1
 	      "<tr>" .
 	      "<td></td><td> $ad{'rfc2822'}";
 	if ($ad{'hour_local'} < 6) {
@@ -3263,7 +3321,8 @@ sub git_print_full_authorship {
 	}
 	print "</td>" .
 	      "</tr>\n";
-	print "<tr><td>committer</td><td>" . esc_html($co->{'committer'}) . "</td></tr>\n";
+	print "<tr><td>committer</td><td>" . esc_html($co->{'committer'}) . "</td>".
+	      "<td rowspan=\"2\">" .git_get_avatar($co->{'committer_email'}, 'size' => 'double') . "</td></tr>\n";
 	print "<tr><td></td><td> $cd{'rfc2822'}" .
 	      sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) .
 	      "</td></tr>\n";

Same as above.

BTW. if you refactor printing _single_ authorship info, either into separate subroutine or as code in (short) loop, you wouldn't have this code repetition. OTOH there would be also 'committing by night' warning, like current 'coding by night' (localtime)...

Nice solution for 'commit' and with 2nd patch in series also 'commitdiff' view.

Quoted 4 lines
Signature · 1 line
1.6.3.rc1.192.gdbfcb
Signature · 2 lines
Jakub Narebski
Poland
#22 lore raw

Re: [PATCHv6 4/8] gitweb: (gr)avatar support

2009/6/26 Jakub Narebski <[email protected]>:

Quoted 7 lines · Giuseppe Bilotta
Quoted 3 lines

Introduce avatar support: the featuer adds the appropriate img tag next to author and committer in commit(diff), history, shortlog and log view.

You forgot about 'tag' view (but I guess it would be done in next version of this patch series).

Indeed, it's automatically addressed because patch view follows the refactoring.

Quoted 2 lines

There is also 'feed' action (Atom and RSS formats), but that is certainly separate issue, for a separate patch.

I'm not entirely sure we want avatars there.

Quoted 1 line

You would _probably_ want to squash the following, just in case:

[snip]

Quoted 2 lines

But even if you don't squash it, please run t9500 with this patch applied, to catch Perl errors and warnings.

I'll squash it in.

Quoted 6 lines

Sidenote: Gravatar API description[1] mentions 'identicon', 'monsterid', 'wavatar'.  There are 'picons' (personal icons)[2].  Also avatars doesn't need to be global: they can be some local static image somewhere in web server which serves gitweb script, or they can be stored somewhere in repository following some convention.

Quoted 6 lines

Current implementation is flexible enough to leave place for extending this feature, but also doesn't try to plan too far in advance.  YAGNI (You Ain't Gonna Need It).

[1] http://www.gravatar.com/site/implement/url
[2] http://www.cs.indiana.edu/picons/ftp/faq.html

The forthcoming series has picons provider and gravatar fallback; however, we might want to have some way to make the gravatar fallback configurable.

Quoted 9 lines
Quoted 8 lines

+     # To enable system wide have in $GITWEB_CONFIG
+     # $feature{'avatar'}{'default'} = ['gravatar'];
+     # To have project specific config enable override in $GITWEB_CONFIG
+     # $feature{'avatar'}{'override'} = 1;
+     # and in project config gitweb.avatar = gravatar;
+     'avatar' => {
+             'override' => 0,
+             'default' => ['']},

Quoted 5 lines

Note that to disable feature with non-boolean 'default' we use empty list [] (which means 'undef' when parsing, which is false); see description of features 'snapshot', 'actions'; 'ctags' what is strange uses [0] here...  Using [''] is a bit strange; and does not protect you, I think.

Using an empty string (or 0 like ctags do) is nice because it spares the undef check you mention later on, and since empty strings and 0 evaluate to false in Perl, it's a good way to handle it. Moreover, any string which is not an actual provider would result in no avatars. More about this later.

Quoted 11 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+# check if avatars are enabled and dependencies are satisfied
+our ($git_avatar) = gitweb_get_feature('avatar');

IMPORTANT!!!

Because you now allow possibility that there can be other avatars than those provided by Gravatar, you should explain in comment what this check below does (e.g. something like "load Digest::MD5, required for gravatar support, and disable it if it does not exist"), so people adding (in the future) support for other kind of avatars would know that they should put similar test there, if needed.

I'll make the check and subsequent switch a little cleaner.

Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+if (($git_avatar eq 'gravatar') &&
+   !(eval { require Digest::MD5; 1; })) {
+     $git_avatar = '';
+}

Here you would have to protect against $git_avatar being undefined... but you should do it anyway, as gitweb_get_feature() can return undef / empty list.

Using '' as defalt instead of [] shields me from this problem, and works properly for boolean checks.

Quoted 9 lines

This might be good enough starting point, but I wonder if it wouldn't be a better solution to provide additional column with avatar image when avatar support is enabled.  You would get a better layout in a very rare case[3] when 'Author' column is too narrow and author is info is wrapped:

 [#] Jonathan
 H. Random

Quoted 8 lines

versus in separate columns case:

 [#] | Jonathan
     | H. Random

But this is a very minor problem, which can be left for separate patch.

[3] unless you use netbook or phone to browse...

I had considered going this way, but it made the code somewhat more complex so I went for the simpler solution. I'll look into putting it in separate cells further on.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#23 lore raw

Re: [PATCHv6 4/8] gitweb: (gr)avatar support

Quoted 5 lines · Giuseppe Bilotta

2009/6/26 Jakub Narebski <[email protected]>:

Quoted 4 lines · Giuseppe Bilotta
Quoted 3 lines

Introduce avatar support: the featuer adds the appropriate img tag next to author and committer in commit(diff), history, shortlog and log view.

[...]

Quoted 4 lines
Quoted 2 lines

There is also 'feed' action (Atom and RSS formats), but that is certainly separate issue, for a separate patch.

I'm not entirely sure we want avatars there.

I think you are right. I have thought that Atom/RSS have place for icons for each entry in feed, but it is not the case. Also feed reader can use gravatars by itself. Sorry for the noise, then.

Quoted 10 lines
Quoted 10 lines

Sidenote: Gravatar API description[1] mentions 'identicon', 'monsterid', 'wavatar'.  There are 'picons' (personal icons)[2].  Also avatars doesn't need to be global: they can be some local static image somewhere in web server which serves gitweb script, or they can be stored somewhere in repository following some convention.

Current implementation is flexible enough to leave place for extending this feature, but also doesn't try to plan too far in advance.  YAGNI (You Ain't Gonna Need It).

Quoted 6 lines
Quoted 2 lines

[1] http://www.gravatar.com/site/implement/url
[2] http://www.cs.indiana.edu/picons/ftp/faq.html

The forthcoming series has picons provider and gravatar fallback; however, we might want to have some way to make the gravatar fallback configurable.

Do I understand this correctly that there is additional patch planned in new release of this series providing support for gitweb.avatar = picon?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+     # To enable system wide have in $GITWEB_CONFIG
+     # $feature{'avatar'}{'default'} = ['gravatar'];
+     # To have project specific config enable override in $GITWEB_CONFIG
+     # $feature{'avatar'}{'override'} = 1;
+     # and in project config gitweb.avatar = gravatar;
+     'avatar' => {
+             'override' => 0,
+             'default' => ['']},

NOTE, NOTE, NOTE!

One thing I forgot about (and would be discovered when running t9500 with provided patch... among other errors) is that you need to provide 'sub' subroutine for feature to be overridable.

...And that subroutine would be responsible for returning '' (empty string) when feature is overridable. See other feature_* subroutines.

Quoted 12 lines
Quoted 6 lines

Note that to disable feature with non-boolean 'default' we use empty list [] (which means 'undef' when parsing, which is false); see description of features 'snapshot', 'actions'; 'ctags' what is strange uses [0] here...  Using [''] is a bit strange; and does not protect you, I think.

Using an empty string (or 0 like ctags do) is nice because it spares the undef check you mention later on, and since empty strings and 0 evaluate to false in Perl, it's a good way to handle it. Moreover, any string which is not an actual provider would result in no avatars. More about this later.

[...]

Quoted 11 lines
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+if (($git_avatar eq 'gravatar') &&
+   !(eval { require Digest::MD5; 1; })) {
+     $git_avatar = '';
+}

Here you would have to protect against $git_avatar being undefined... but you should do it anyway, as gitweb_get_feature() can return undef / empty list.

Using '' as defalt instead of [] shields me from this problem, and works properly for boolean checks.

Well, I can understand that. I was wrong: it is up to (currently not defined) 'sub' to ensure that gitweb_get_feature would return '' ('default').

Still,

  +our ($git_avatar) = gitweb_get_feature('avatar') || '';

is quite simple... and can be in future subtly wrong (unless it would be gitweb_check_feature, which always return scalar / single element).

Quoted 14 lines
Quoted 14 lines

This might be good enough starting point, but I wonder if it wouldn't be a better solution to provide additional column with avatar image when avatar support is enabled.  You would get a better layout in a very rare case[3] when 'Author' column is too narrow and author is info is wrapped:

 [#] Jonathan
 H. Random

versus in separate columns case:

 [#] | Jonathan
     | H. Random

Quoted 7 lines
Quoted 3 lines

But this is a very minor problem, which can be left for separate patch.

[3] unless you use netbook or phone to browse...

I had considered going this way, but it made the code somewhat more complex so I went for the simpler solution. I'll look into putting it in separate cells further on.

Well, by "left for later" here I thought about later as in after this patch series about gravatars get accepted :-)

Signature · 2 lines
Jakub Narebski
Poland
#24 lore raw

Re: [PATCHv6 4/8] gitweb: (gr)avatar support

Quoted 2 lines · Jakub Narebski

Do I understand this correctly that there is additional patch planned in new release of this series providing support for gitweb.avatar = picon?

Yes.

And a separate patch makes the picon the fallback for gravatar too, but I'm thinking about having something like a gitweb.gravatar_default (or something like that) to make that configurable.

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+     # To enable system wide have in $GITWEB_CONFIG
+     # $feature{'avatar'}{'default'} = ['gravatar'];
+     # To have project specific config enable override in $GITWEB_CONFIG
+     # $feature{'avatar'}{'override'} = 1;
+     # and in project config gitweb.avatar = gravatar;
+     'avatar' => {
+             'override' => 0,
+             'default' => ['']},

Quoted 5 lines

NOTE, NOTE, NOTE!

One thing I forgot about (and would be discovered when running t9500 with provided patch... among other errors) is that you need to provide 'sub' subroutine for feature to be overridable.

Duh I had forgotten aout that. But I ran the test and didn't see that error ... maybe I'm reading the log incorrectly.

Quoted 2 lines

...And that subroutine would be responsible for returning '' (empty string) when feature is overridable.  See other feature_* subroutines.

I've tried an implementation. Hopefully it's correct 8-/

Quoted 6 lines
Quoted 3 lines

I had considered going this way, but it made the code somewhat more complex so I went for the simpler solution. I'll look into putting it in separate cells further on.

Well, by "left for later" here I thought about later as in after this patch series about gravatars get accepted :-)

Me too 8-D

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#25 lore raw

Re: [PATCHv6 4/8] gitweb: (gr)avatar support

Quoted 10 lines · Giuseppe Bilotta
Quoted 2 lines · Jakub Narebski

Do I understand this correctly that there is additional patch planned in new release of this series providing support for gitweb.avatar = picon?

Yes.

And a separate patch makes the picon the fallback for gravatar too, but I'm thinking about having something like a gitweb.gravatar_default (or something like that) to make that configurable.

I'm not sure if having picons as 'default' for gravatar is a good idea, because the rules for resolving picons are complicated[1]... which I didn't realize when writing this (sketch of) idea.

[1] http://www.cs.indiana.edu/picons/ftp/faq.html

Signature · 2 lines
Jakub Narebski
Poland
#26 lore raw

Re: [PATCHv6 4/8] gitweb: (gr)avatar support

Quoted 5 lines · Jakub Narebski

I'm not sure if having picons as 'default' for gravatar is a good idea, because the rules for resolving picons are complicated[1]... which I didn't realize when writing this (sketch of) idea.

[1] http://www.cs.indiana.edu/picons/ftp/faq.html

Also picons these days look somewhat antiquated with its rather strict limitation to the colormaps (IIRC, you practically have to go grayscale if you want to use a real photo), and it would make sense to try gravatar first and then fall back to picons.

#27 lore raw

Re: [PATCHv6 4/8] gitweb: (gr)avatar support

Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Jakub Narebski

I'm not sure if having picons as 'default' for gravatar is a good idea, because the rules for resolving picons are complicated[1]... which I didn't realize when writing this (sketch of) idea.

Quoted 6 lines
Quoted 1 line

[1] http://www.cs.indiana.edu/picons/ftp/faq.html

Also picons these days look somewhat antiquated with its rather strict limitation to the colormaps (IIRC, you practically have to go grayscale if you want to use a real photo), and it would make sense to try gravatar first and then fall back to picons.

That's what gravatar's default is for: if the image is not set, use whatever is provided as default (with this patch, the picon).

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#28 lore raw

Re: [PATCHv6 3/8] gitweb: right-align date cell in shortlog

In reply to Giuseppe Bilotta

gitweb/gitweb.css table { · line 183

Quoted 9 lines · Giuseppe Bilotta
gitweb/gitweb.css +3 -0
index 68b22ff..7240ed7 100644
@@ -180,6 +180,10 @@ table {
 
+table.shortlog td:first-child{
+	text-align: right;
+}

First, there is no space between ':first-child' pseudo-class selector and opening '{'. It should be "td:first-child {".

Second, I'd rather avoid more advanced CSS constructs; not all web browsers support ':first-child' selector. On the other hand adding class attribute to handle this would make page slightly larger.

Last, and most important: I don't agree with this change. In my opinion it does not improve layout (and you didn't provide support for this change). Right-align justification should be sparingly, as it is not natural in left-to-right languages.

NAK from me for this change.

Signature · 2 lines
Jakub Narebski
Poland
#29 lore raw

Re: [PATCHv6 3/8] gitweb: right-align date cell in shortlog

2009/6/26 Jakub Narebski <[email protected]>:

Quoted 8 lines · Giuseppe Bilotta
Quoted 6 lines
gitweb/gitweb.css +0 -0
index 68b22ff..7240ed7 100644
@@ -180,6 +180,10 @@ table {
Quoted 6 lines

gitweb/gitweb.css table { · line 185

Quoted 3 lines
gitweb/gitweb.css +3 -0
+table.shortlog td:first-child{
+     text-align: right;
+}

First, there is no space between ':first-child' pseudo-class selector and opening '{'.  It should be "td:first-child {".

Right.

Quoted 3 lines

Second, I'd rather avoid more advanced CSS constructs; not all web browsers support ':first-child' selector.  On the other hand adding class attribute to handle this would make page slightly larger.

IIRC :first-child is supported from IE7 onwards. There are hacks to make it work on IE6, but I think they are definitely not worth it.

Quoted 4 lines

Last, and most important: I don't agree with this change.  In my opinion it does not improve layout (and you didn't provide support for this change).  Right-align justification should be sparingly, as it is not natural in left-to-right languages.

Of course, in my opinion it does improve layout.

The effect is to right-laign the first column of shortlog view, i.e. the one holding the date. For dates that are presented as yyyy-mm-dd it makes not difference, but when the phrasing is 'X days ago' it provides the benefit of aligning the 'days ago' part instead of having it ragged. See it live at

http://git.oblomov.eu/git/shortlog

and judge for yourselves.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#30 lore raw

Re: [PATCHv6 3/8] gitweb: right-align date cell in shortlog

Quoted 17 lines · Giuseppe Bilotta

2009/6/26 Jakub Narebski <[email protected]>:

Quoted 8 lines · Giuseppe Bilotta
Quoted 6 lines
gitweb/gitweb.css +0 -0
index 68b22ff..7240ed7 100644
@@ -180,6 +180,10 @@ table {
Quoted 7 lines

gitweb/gitweb.css table { · line 185

Quoted 3 lines
gitweb/gitweb.css +3 -0
+table.shortlog td:first-child{
+     text-align: right;
+}

Second, I'd rather avoid more advanced CSS constructs; not all web browsers support ':first-child' selector.  On the other hand adding class attribute to handle this would make page slightly larger.

Quoted 2 lines

IIRC :first-child is supported from IE7 onwards. There are hacks to make it work on IE6, but I think they are definitely not worth it.

I was thinking here about more exotic web browsers, like Lynx, ELinks, w3m (and w3m in Emacs), Konqueror (KHTML). I think that both Opera and Safari (and other browsers based on WebKit engine) support ':first-child' pseudo-class selector. Also I'd rather not start trend to use more advanced parts of CSS...

On the other hand if we introduce 'age coloring' (as used in projects list view), by using classes age0..age2, then we would be able to use class selector instead of :first-child pseudo-class selector for that.

Quoted 13 lines
Quoted 4 lines

Last, and most important: I don't agree with this change.  In my opinion it does not improve layout (and you didn't provide support for this change).  Right-align justification should be sparingly, as it is not natural in left-to-right languages.

Of course, in my opinion it does improve layout.

The effect is to right-align the first column of shortlog view, i.e. the one holding the date. For dates that are presented as yyyy-mm-dd it makes not difference, but when the phrasing is 'X days ago' it provides the benefit of aligning the 'days ago' part instead of having it ragged. See it live at

Quoted 3 lines

http://git.oblomov.eu/git/shortlog

and judge for yourselves.

First, it would be nice to have

See it live at http://git.oblomov.eu/git/shortlog

in the patch comment (between "---\n" line and diffstat).

And I took a look how it looks like, with:

 $ <mark whole thread>
 $ <save as>
 $ git am -3 <file>
 $ stg uncommit -n <n>
 $ stg pop -a
 $ stg push
 $ gitweb-update.sh
 $ <view http://localhost/cgi-bin/gitweb/gitweb.cgi>
 $ ...

Second, even disregarding using ':first-child' pseudo-class selector (it is not that important issue that it is required to have this supported in all browsers), there is problem that this change is _incomplete_. Take a look at 'summary' view (probably most used project specific action): in 'shortlog' you have date right-aligned, while date column in 'heads' and 'tags' parts below you have date left-aligned.

Third, in my opinion it does not improve layout. You align on least important part of relative date specification: on the word "ago". Unit specifiers in relative date specification are of different length so you don't have align (or rather have align in sort subsequences).

Compare:

15 min ago
6 hours ago
10 hours ago
2 days ago
2 weeks ago
6 months ago
2009-06-12

with

15 min ago
6 hours ago
10 hours ago
2 days ago
2 weeks ago
6 months ago

    2009-06-12

What you probably want to have (and which I am not sure if it is worth complication) is to align on first space/whitespace (align="char" char=" ")

15 min ago
6 hours ago
10 hours ago
2 days ago
2 weeks ago
6 months ago
2009-06-12

or even

  15 min    ago
   6 hours  ago
  10 hours  ago
   2 days   ago
   2 weeks  ago

6 months ago
2009-06-12

Signature · 2 lines
Jakub Narebski
Poland
#31 lore raw

Re: [PATCHv6 3/8] gitweb: right-align date cell in shortlog

Quoted 9 lines · Jakub Narebski
Quoted 8 lines · Giuseppe Bilotta

2009/6/26 Jakub Narebski <[email protected]>:

Quoted 4 lines

Last, and most important: I don't agree with this change.  In my opinion it does not improve layout (and you didn't provide support for this change).  Right-align justification should be sparingly, as it is not natural in left-to-right languages.

Of course, in my opinion it does improve layout.

[..]

Quoted 12 lines

Compare:

15 min ago
6 hours ago
10 hours ago
2 days ago
2 weeks ago
6 months ago
2009-06-12

with

Quoted 7 lines

15 min ago
6 hours ago
10 hours ago
2 days ago
2 weeks ago
6 months ago

    2009-06-12

It looks IMHO even worse if, because of limited screen width, 'date' column needs to be wrapped. See

6 months
ago

versus

6 months
ago

Signature · 2 lines
Jakub Narebski
Poland
#33 lore raw

Re: [PATCHv6 3/8] gitweb: right-align date cell in shortlog

Quoted 4 lines · Junio C Hamano
Quoted 2 lines · Giuseppe Bilotta

See it live at

Quoted 8 lines
Quoted 3 lines

http://git.oblomov.eu/git/shortlog

and judge for yourselves.

Yay, very nice to see these faces!  Thanks ;-)

Regardless of other points that may or may not have to be addressed, I had to say this.

I'm glad you like the faces 8-)

What's your opinion on the alignment for the date column in the shortlog?

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#34 lore raw

Re: [PATCHv6 3/8] gitweb: right-align date cell in shortlog

Quoted 1 line · Giuseppe Bilotta

What's your opinion on the alignment for the date column in the shortlog?

Even though I am very used to seeing the current output style that aligns to the left edge, your output didn't bother me.

Because visual preference typically is influenced very heavily by inertia, I take this as a sign that (1) left or right it does not matter very much, and/or (2) aligning to the right edge is slightly better.

But that is just my impression.

#35 lore raw

Re: [PATCHv6 2/8] gitweb: uniform author info for commit and commitdiff

In reply to Giuseppe Bilotta

On Thu, 25 June 2009, Giuseppe Bilotta wrote:

Here I would write that 'commitdiff' view moves from

Giuseppe Bilotta [Mon, 22 Jun 2009 22:49:58 +0000 (00:49 +0200)]

to

author Giuseppe Bilotta <[email protected]>

              Mon, 22 Jun 2009 22:49:58 +0000 (00:49 +0200)
  committer   Jakub Narebski <[email protected]>
              Tue, 23 Jun 2009 18:02:21 +0000 (20:02 +0200)"

(perhaps with A U Thor and C O Mitter as example names).

Quoted 12 lines
---
 gitweb/gitweb.perl |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +0 -0
index 9b60418..cdfd1d5 100755
@@ -5595,7 +5595,11 @@ sub git_commitdiff {
 		git_header_html(undef, $expires);
 		git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);

gitweb/gitweb.perl sub git_commitdiff { · line 5605

Quoted 10 lines
gitweb/gitweb.perl +5 -1
 		git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash);
-		git_print_authorship(\%co, 'localtime' => 1);
+		print "<div class=\"title_text\">\n" .
+		      "<table class=\"object_header\">\n";
+		git_print_full_authorship(\%co);
+		print "</table>".
+		      "</div>\n";
 		print "<div class=\"page_body\">\n";
 		if (@{$co{'comment'}} > 1) {
 			print "<div class=\"log\">\n";

Nice and short thanks to refactoring you have done in previous patch.

Very good that you put this in separate patch, so it can be evaluated independently, and decided independently whether it is worth having more detailed authorship information in 'commitdiff', making it more like 'commit' view, or be more like 'log' view with similar, but slightly extended authorship information.

I personally am a bit ambivalent about this issue...

Quoted 4 lines
Signature · 1 line
1.6.3.rc1.192.gdbfcb
Signature · 2 lines
Jakub Narebski
Poland
#36 lore raw

Re: [PATCHv6 2/8] gitweb: uniform author info for commit and commitdiff

2009/6/26 Jakub Narebski <[email protected]>:

Quoted 6 lines · Giuseppe Bilotta

Here I would write that 'commitdiff' view moves from

 Giuseppe Bilotta [Mon, 22 Jun 2009 22:49:58 +0000 (00:49 +0200)]

Quoted 8 lines

to

 author      Giuseppe Bilotta <[email protected]> Mon, 22 Jun 2009 22:49:58 +0000 (00:49 +0200) committer   Jakub Narebski <[email protected]> Tue, 23 Jun 2009 18:02:21 +0000 (20:02 +0200)"

(perhaps with A U Thor and C O Mitter as example names).

Done.

Quoted 7 lines

Very good that you put this in separate patch, so it can be evaluated independently, and decided independently whether it is worth having more detailed authorship information in 'commitdiff', making it more like 'commit' view, or be more like 'log' view with similar, but slightly extended authorship information.

I personally am a bit ambivalent about this issue...

I really don't understand why commit and commitdiff are so different, but this is something we went over already. One thing that should be kept in mind is that commitdiff can span multiple commits, but in this case it only display the information about the first one (but this is not something that is changed by my patch). commitdiff view probably needs a complete rethinking.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#37 lore raw

Re: [PATCHv6 1/8] gitweb: refactor author name insertion

In reply to Giuseppe Bilotta
Quoted 3 lines · Giuseppe Bilotta

Collect all author display code in appropriate functions, making it easiser to extend them on the CGI side, and rely on CSS rather than hard-coded HTML formatting for easier customization.

Typo: s/easiser/easier/

This paragraph could have been written better, perhaps by dividing it in two sentences: one talking about collecting/factoring common code, one talking about moving from presentational HTML (<i>, <b> tags) to styling using CSS and class attribute.

Do I understand it correctly that this was meant as pure refactoring, i.e. that none of gitweb output should have changed? Because you made a mistake, and 'log' view is broken (and it doesn't look like it did before). See comments below for cause and (simple) solution.

Quoted 3 lines

---

What are the changes as compared to previous (or just earlier) version?

Quoted 12 lines
 gitweb/gitweb.css  |    5 ++-
 gitweb/gitweb.perl |   80 +++++++++++++++++++++++++++++++---------------------
 2 files changed, 52 insertions(+), 33 deletions(-)
gitweb/gitweb.css +0 -0
index a01eac8..68b22ff 100644
@@ -132,11 +132,14 @@ div.list_head {
 	font-style: italic;
 }
 

gitweb/gitweb.css div.list_head { · line 143

Quoted 10 lines
gitweb/gitweb.css +4 -1
+.author_date, .author {
+	font-style: italic;
+}
+
 div.author_date {
 	padding: 8px;
 	border: solid #d9d8d1;
 	border-width: 0px 0px 1px 0px;
-	font-style: italic;
 }

Nice.

Quoted 9 lines
gitweb/gitweb.css +0 -0
 a.list {
gitweb/gitweb.perl +0 -0
index 1e7e2d8..9b60418 100755
@@ -1469,6 +1469,16 @@ sub format_subject_html {
 	}
 }

gitweb/gitweb.perl sub format_subject_html { · line 1480

Quoted 10 lines
gitweb/gitweb.perl +9 -0
 
+# format the author name of the given commit with the given tag
+# the author name is chopped and escaped according to the other
+# optional parameters (see chop_str).
+sub format_author_html {
+	my $tag = shift;
+	my $co = shift;
+	my $author = chop_and_escape_str($co->{'author_name'}, @_);
+	return "<$tag class=\"author\">" . $author . "</$tag>\n";
+}

Good... although I wonder if we should not get rid of chop_and_escape_str altogether, and for example add title attribute (if needed due to having to do shortening) directly to $tag, and not to inner <span> element.

Should "\n" be in returned string? Just asking.

gitweb/gitweb.perl sub git_print_header_div { · line 3231

Quoted 13 lines
gitweb/gitweb.perl +4 -0
+
 # format git diff header line, i.e. "diff --(git|combined|cc) ..."
 sub format_git_diff_header_line {
 	my $line = shift;
@@ -3214,13 +3224,36 @@ sub git_print_header_div {
 	      "\n</div>\n";
 }
 
+# Outputs the author name and date in long form
 sub git_print_authorship {
 	my $co = shift;
+	my %params = @_;
+	my $tag = $params{'tag'} || 'div';

Nice using of hash to have named optional params.

Usually though we use %opts and not %params for the name of this hash, and we use CGI-like keys prefixed by '-', for example '-z' in parse_ls_tree_line(), '-nbsp' in esc_html, '-nohtml' in quot_cec(), '-remove_title', '-remove_signoff' and '-final_empty_line' in git_print_log(). git_commitdiff() uses %params, but it doesn't have non-optional parameters (still, I guess we should use %opts for consistency), and it uses '-format' and '-single' as names.

href() subroutine uses %params... but those are not extra named optional parameters to subroutine; they are CGI query parameters.

NOTE: Default tag (as used in git_log) should be not generic block element tag: 'div', but rather generic inline element: 'span'. The presentational HTML element '<i>' which we are replacing is inline (layout) element.

It is because it is '<div>' (and probably because some "random" CSS rules in gitweb.css match it) it breaks layout or 'log' view. There two horizontal lines: one for <div> element, and one for unnecessary now <br> element. As div.author_date it has extra 8px padding, from which the top padding is visible as extra unnecessary vertical space.

Quoted 7 lines
gitweb/gitweb.perl +2 -1
 	my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
-	print "<div class=\"author_date\">" .
+	print "<$tag class=\"author_date\">" .
 	      esc_html($co->{'author_name'}) .
 	      " [$ad{'rfc2822'}";
+	if ($params{'localtime'}) {

gitweb/gitweb.perl sub git_print_header_div { · line 3247

Quoted 10 lines
gitweb/gitweb.perl +10 -0
+		if ($ad{'hour_local'} < 6) {
+			printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
+			       $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
+		} else {
+			printf(" (%02d:%02d %s)",
+			       $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
+		}
+	}
+	print "]</$tag>\n";
+}

Gaah, git has chosen to show this diff a bit strangely...

gitweb/gitweb.perl sub git_print_header_div { · line 3249

Quoted 2 lines
gitweb/gitweb.perl +2 -0
+
+# Outputs table rows containign the full author and commiter information.

Typo: s/containign/containing/

You could say that it uses format used to show author and comitter fields (headers) in 'commit' view.

Quoted 12 lines
gitweb/gitweb.perl +7 -0
+sub git_print_full_authorship {
+	my $co = shift;
+	my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
+	my %cd = parse_date($co->{'committer_epoch'}, $co->{'committer_tz'});
+	print "<tr><td>author</td><td>" . esc_html($co->{'author'}) . "</td></tr>\n".
+	      "<tr>" .
+	      "<td></td><td> $ad{'rfc2822'}";
 	if ($ad{'hour_local'} < 6) {
 		printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
 		       $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
@@ -3228,7 +3261,12 @@ sub git_print_authorship {
 		printf(" (%02d:%02d %s)",

gitweb/gitweb.perl sub git_print_authorship { · line 3270

Quoted 10 lines
gitweb/gitweb.perl +6 -1
 		       $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
 	}
-	print "]</div>\n";
+	print "</td>" .
+	      "</tr>\n";
+	print "<tr><td>committer</td><td>" . esc_html($co->{'committer'}) . "</td></tr>\n";
+	print "<tr><td></td><td> $cd{'rfc2822'}" .
+	      sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) .
+	      "</td></tr>\n";
 }

By the way, what about author / tagger info used in 'tag' view? Wouldn't it be better to factor out generating table rows for single author / committer / tagger header (field) info?

Quoted 5 lines
gitweb/gitweb.perl +0 -0
 sub git_print_page_path {
@@ -4142,11 +4180,9 @@ sub git_shortlog_body {
 			print "<tr class=\"light\">\n";
 		}

gitweb/gitweb.perl sub git_shortlog_body { · line 4188

Quoted 10 lines
gitweb/gitweb.perl +1 -3
 		$alternate ^= 1;
-		my $author = chop_and_escape_str($co{'author_name'}, 10);
 		# git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
 		print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
-		      "<td><i>" . $author . "</i></td>\n" .
-		      "<td>";
+		      format_author_html('td', \%co, 10) . "<td>";
 		print format_subject_html($co{'title'}, $co{'title_short'},
 		                          href(action=>"commit", hash=>$commit), $ref);
 		print "</td>\n" .

Nice refactoring and simplification.

Quoted 4 lines
gitweb/gitweb.perl +0 -0
@@ -4193,11 +4229,9 @@ sub git_history_body {
 			print "<tr class=\"light\">\n";
 		}
 		$alternate ^= 1;

gitweb/gitweb.perl sub git_history_body { · line 4237

Quoted 10 lines
gitweb/gitweb.perl +2 -4
-	# shortlog uses      chop_str($co{'author_name'}, 10)
-		my $author = chop_and_escape_str($co{'author_name'}, 15, 3);
 		print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
-		      "<td><i>" . $author . "</i></td>\n" .
-		      "<td>";
+	# shortlog:   format_author_html('td', \%co, 10)
+		      format_author_html('td', \%co, 15, 3) . "<td>";
 		# originally git_history used chop_str($co{'title'}, 50)
 		print format_subject_html($co{'title'}, $co{'title_short'},
 		                          href(action=>"commit", hash=>$commit), $ref);

Nice refactoring and simplification.
Good comment.

gitweb/gitweb.perl sub git_search_grep_body { · line 4391

Quoted 11 lines
gitweb/gitweb.perl +1 -2
@@ -4350,9 +4384,8 @@ sub git_search_grep_body {
 			print "<tr class=\"light\">\n";
 		}
 		$alternate ^= 1;
-		my $author = chop_and_escape_str($co{'author_name'}, 15, 5);
 		print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
-		      "<td><i>" . $author . "</i></td>\n" .
+		      format_author_html('td', \%co, 15, 5) .
 		      "<td>" .
 		      $cgi->a({-href => href(action=>"commit", hash=>$co{'id'}),
 		               -class => "list subject"},

Nice refactoring and simplification.

gitweb/gitweb.perl sub git_log { · line 5135

Quoted 12 lines
gitweb/gitweb.perl +2 -2
@@ -5094,9 +5127,9 @@ sub git_log {
 		      " | " .
 		      $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree") .
 		      "<br/>\n" .
-		      "</div>\n" .
-		      "<i>" . esc_html($co{'author_name'}) .  " [$ad{'rfc2822'}]</i><br/>\n" .
 		      "</div>\n";
+		      git_print_authorship(\%co);
+		      print "<br/>\n</div>\n";
 
 		print "<div class=\"log_body\">\n";
 		git_print_log($co{'comment'}, -final_empty_line=> 1);

Here you replace inline <i> element with <div> _block_ element, destroying layout. Replacing default of 'div' by default of inline <span> element restores old layout.

Quoted 23 lines
gitweb/gitweb.perl +0 -12
@@ -5115,8 +5148,6 @@ sub git_commit {
 	$hash ||= $hash_base || "HEAD";
 	my %co = parse_commit($hash)
 	    or die_error(404, "Unknown commit object");
-	my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
-	my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});
 
 	my $parent  = $co{'parent'};
 	my $parents = $co{'parents'}; # listref
@@ -5183,22 +5214,7 @@ sub git_commit {
 	}
 	print "<div class=\"title_text\">\n" .
 	      "<table class=\"object_header\">\n";
-	print "<tr><td>author</td><td>" . esc_html($co{'author'}) . "</td></tr>\n".
-	      "<tr>" .
-	      "<td></td><td> $ad{'rfc2822'}";
-	if ($ad{'hour_local'} < 6) {
-		printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
-		       $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
-	} else {
-		printf(" (%02d:%02d %s)",
-		       $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
-	}

gitweb/gitweb.perl sub git_commit { · line 5220

Quoted 10 lines
gitweb/gitweb.perl +1 -6
-	print "</td>" .
-	      "</tr>\n";
-	print "<tr><td>committer</td><td>" . esc_html($co{'committer'}) . "</td></tr>\n";
-	print "<tr><td></td><td> $cd{'rfc2822'}" .
-	      sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) .
-	      "</td></tr>\n";
+	git_print_full_authorship(\%co);
 	print "<tr><td>commit</td><td class=\"sha1\">$co{'id'}</td></tr>\n";
 	print "<tr>" .
 	      "<td>tree</td>" .

I'd rather use here (as mentioned in comment about git_print_full_authorship subroutine) something like the following:

+ git_print_authorship_header(\%co, 'author');
+ git_print_authorship_header(\%co, 'committer');

Or something like that. But this might be a matter of taste.

gitweb/gitweb.perl sub git_commitdiff { · line 5601

Quoted 9 lines
gitweb/gitweb.perl +1 -1
@@ -5579,7 +5595,7 @@ sub git_commitdiff {
 		git_header_html(undef, $expires);
 		git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
 		git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash);
-		git_print_authorship(\%co);
+		git_print_authorship(\%co, 'localtime' => 1);
 		print "<div class=\"page_body\">\n";
 		if (@{$co{'comment'}} > 1) {
 			print "<div class=\"log\">\n";

Nice. Although... 'localtime' / '-localtime'? Perhaps '-show_localtime'? But that is just nitpicking (naming is hard), and I am not sure if proposed name is any better.

Quoted 4 lines
Signature · 1 line
1.6.3.rc1.192.gdbfcb

Thank you for diligent work on this patch series!

Signature · 2 lines
Jakub Narebski
Poland
#38 lore raw

Re: [PATCHv6 1/8] gitweb: refactor author name insertion

Quoted 12 lines · Jakub Narebski
Quoted 10 lines · Giuseppe Bilotta
gitweb/gitweb.perl +2 -2
@@ -5094,9 +5127,9 @@ sub git_log {
 		      " | " .
 		      $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree") .
 		      "<br/>\n" .
-		      "</div>\n" .
-		      "<i>" . esc_html($co{'author_name'}) .  " [$ad{'rfc2822'}]</i><br/>\n" .
 		      "</div>\n";
+		      git_print_authorship(\%co);
+		      print "<br/>\n</div>\n";
 
Quoted 6 lines

gitweb/gitweb.perl sub git_log { · line 5135

Quoted 2 lines
gitweb/gitweb.perl +0 -0
 		print "<div class=\"log_body\">\n";
 		git_print_log($co{'comment'}, -final_empty_line=> 1);

Here you replace inline <i> element with <div> _block_ element, destroying layout. Replacing default of 'div' by default of inline <span> element restores old layout.

Note: here we want <span>.

Quoted 9 lines

gitweb/gitweb.perl sub git_commitdiff { · line 5601

Quoted 9 lines
gitweb/gitweb.perl +1 -1
@@ -5579,7 +5595,7 @@ sub git_commitdiff {
 		git_header_html(undef, $expires);
 		git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
 		git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash);
-		git_print_authorship(\%co);
+		git_print_authorship(\%co, 'localtime' => 1);
 		print "<div class=\"page_body\">\n";
 		if (@{$co{'comment'}} > 1) {
 			print "<div class=\"log\">\n";

Note: here we want <div>.

Whether default would be 'span' or 'div', at least one of those has to pass explicit 'tag' / '-tag' parameter. I guess it would be easier to pass 'tag' => 'span' in git_log().

Signature · 2 lines
Jakub Narebski
Poland
#39 lore raw

Re: [PATCHv6 1/8] gitweb: refactor author name insertion

In reply to Jakub Narebski

2009/6/26 Jakub Narebski <[email protected]>:

Quoted 4 lines

Do I understand it correctly that this was meant as pure refactoring, i.e. that none of gitweb output should have changed?  Because you made a mistake, and 'log' view is broken (and it doesn't look like it did before).  See comments below for cause and (simple) solution.

Thanks for noticing. And yes, the problem is indeed that I forgot to specify tag => span in git log view (I'm keeping div the default because that's what was there in the first place in git_print_authorship).

Quoted 5 lines
Quoted 5 lines
gitweb/gitweb.perl +5 -0
+# format the author name of the given commit with the given tag
+# the author name is chopped and escaped according to the other
+# optional parameters (see chop_str).
+sub format_author_html {
+     my $tag = shift;
Quoted 8 lines
Quoted 4 lines

+     my $co = shift;
+     my $author = chop_and_escape_str($co->{'author_name'}, @_);
+     return "<$tag class=\"author\">" . $author . "</$tag>\n"; +}

Good... although I wonder if we should not get rid of chop_and_escape_str altogether, and for example add title attribute (if needed due to having to do shortening) directly to $tag, and not to inner <span> element.

This would require some additional refactoring, and I don't have a clear idea on how to best implement it right now. I'm afraid it'll have to wait for another time.

Quoted 1 line

Should "\n" be in returned string? Just asking.

You're right, we probably don't want to force the newline there. The real question is, do we want the callers to put a newline there? I'm thinking no, because it's mostly used in table cells and a newline is better done at the row level, but I'm not sure either way. I'll just remove it for the time being, it should only have effects at the sourcecode level, not on the layout.

Quoted 10 lines

Usually though we use %opts and not %params for the name of this hash, and we use CGI-like keys prefixed by '-', for example '-z' in parse_ls_tree_line(), '-nbsp' in esc_html, '-nohtml' in quot_cec(),  '-remove_title', '-remove_signoff' and '-final_empty_line' in git_print_log().  git_commitdiff() uses %params, but it doesn't have non-optional parameters (still, I guess we should use %opts for consistency), and it uses '-format' and '-single' as names.

href() subroutine uses %params... but those are not extra named optional parameters to subroutine; they are CGI query parameters.

I'll adjust the code accordingly. BTW the %params in git_commitdiff is my fault too, IIRC.

Quoted 17 lines
Quoted 8 lines

      my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
-     print "<div class=\"author_date\">" .
+     print "<$tag class=\"author_date\">" . esc_html($co->{'author_name'}) .
            " [$ad{'rfc2822'}";
+     if ($params{'localtime'}) {
+             if ($ad{'hour_local'} < 6) {
+                     printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",

Quoted 8 lines

+                            $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
+             } else {
+                     printf(" (%02d:%02d %s)",
+                            $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
+             }
+     }
+     print "]</$tag>\n";
+}

Quoted 1 line

Gaah, git has chosen to show this diff a bit strangely...

Oh, very funny indeed. I hadn't realized it went that way. Wonder if the patience diff would have helped here.

Quoted 1 line

By the way, what about author / tagger info used in 'tag' view?

I totally forgot about that.

Quoted 2 lines

Wouldn't it be better to factor out generating table rows for single author / committer / tagger header (field) info?

Good idea. I'm not sure the tagger field has all the relevant data. I'll check.

Quoted 7 lines

I'd rather use here (as mentioned in comment about git_print_full_authorship subroutine) something like the following:

+       git_print_authorship_header(\%co, 'author');
+       git_print_authorship_header(\%co, 'committer');

Or something like that.  But this might be a matter of taste.

I renamed the sub to git_print_authorship_rows, and I'm making it accept a list of people to print info for. I'll make it default to both author and committer though.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#40 lore raw
In reply to Giuseppe Bilotta
Quoted 4 lines · Giuseppe Bilotta

Significant changes from the previous iteration are:

* the feature has been renamed to 'avatar', and 'gravatar' is a possible value for it (currently the only sensible value, other than '');

By the way, I think it might be better solution to provide picon URL as 'default' attribute for gravatar URL, so it is used if there is no gravatar for given email.

Quoted 1 line

* the last patch adds avatars to signoff lines.

Perhaps it would be better to add gravatars at beginning of line?

I'll try to post my comments today (i.e. within 24 hours)... but it looks good.

Signature · 2 lines
Jakub Narebski
Poland
#41 lore raw
Quoted 2 lines · Jakub Narebski

I'll try to post my comments today (i.e. within 24 hours)... but it looks good.

I'm sorry, I will post comments for the rest of patches in series tomorrow (but I'll try to be within those 24 hours).

Signature · 2 lines
Jakub Narebski
Poland
#42 lore raw
In reply to Jakub Narebski

2009/6/25 Jakub Narebski <[email protected]>:

Quoted 10 lines
Quoted 4 lines · Giuseppe Bilotta

Significant changes from the previous iteration are:

* the feature has been renamed to 'avatar', and 'gravatar' is a possible value for it (currently the only sensible value, other than '');

By the way, I think it might be better solution to provide picon URL as 'default' attribute for gravatar URL, so it is used if there is no gravatar for given email.

I was thinking about some form of fallback like that too, but I haven't the slightest idea how picons work, so I'm afraid I'll leave that enhancement to some later time.

Quoted 3 lines
Quoted 1 line

* the last patch adds avatars to signoff lines.

Perhaps it would be better to add gravatars at beginning of line?

I'm not sure. As I mention in the email for that commit, I'm totally not satisfied with the layout. I'm lookint into turning signoff blocks into tables.

Quoted 2 lines

I'll try to post my comments today (i.e. within 24 hours)... but it looks good.

Thanks a lot.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#43 lore raw
Quoted 3 lines · Giuseppe Bilotta

I was thinking about some form of fallback like that too, but I haven't the slightest idea how picons work, so I'm afraid I'll leave that enhancement to some later time.

Yeah, let's not go overboard with the initial series.

In order to lay a sound groundwork so that later patches can build on more cleanly, it is good to talk about possibilities of adding support for other services _later_ and assess how easy/hard it would be with the proposed code structure. Once it's done, and everybody is happy with the result that it will be easy to work with, then we should leave later later and move forward.

#44 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 3 lines · Giuseppe Bilotta

I was thinking about some form of fallback like that too, but I haven't the slightest idea how picons work, so I'm afraid I'll leave that enhancement to some later time.

Yeah, let's not go overboard with the initial series.

Well, I'll confess that I've been on a coding frenzy all day, so expect a new release with preliminary picon support as soon as the review for the last patchset is done 8-D

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#45 lore raw
Quoted 7 lines · Giuseppe Bilotta
Quoted 6 lines · Junio C Hamano
Quoted 3 lines · Giuseppe Bilotta

I was thinking about some form of fallback like that too, but I haven't the slightest idea how picons work, so I'm afraid I'll leave that enhancement to some later time.

Quoted 5 lines
Quoted 1 line

Yeah, let's not go overboard with the initial series.

Well, I'll confess that I've been on a coding frenzy all day, so expect a new release with preliminary picon support as soon as the review for the last patchset is done 8-D

Ok, I saved v6 in my to-queue box planning to queue it in 'pu', but I'll discard them and wait until the dust settles in v$n ($n >= 7).

Thanks.