Skip to contentSkip to conversation

gitweb: Add title attribute with unshortened value for table cells

PATCH/RFC Jakub Narebski 4 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

This allows to see full, unshortened value on mouseover using 'title' attribute for <td> element. For now it means only author name and project owner name.

Ugly solution using $cgi->start_td({-title => VALUE})

Doesn't work well with values outside us-ascii, but that might be considered web browser bug (misfeature), not a bug in gitweb.

---
The idea is to have full value available on mouseover, be it commit title, author of the commit, project owner, tag name/title or project description. For now only author name and project owner name are implemented, and implementation is ugly and results is not perfect.

 gitweb/gitweb.cgi |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

b72280ac4649d54375732de771f7d92c7d350258

gitweb/gitweb.cgi +6 -6
index 1b254df..9a09b20 100755
@@ -887,7 +887,7 @@ sub git_project_list {
 		$alternate ^= 1;
 		print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=summary"), -class => "list"}, esc_html($pr->{'path'})) . "</td>\n" .
 		      "<td>$pr->{'descr'}</td>\n" .
-		      "<td><i>" . chop_str($pr->{'owner'}, 15) . "</i></td>\n";
+		      $cgi->start_td({-title => $pr->{'owner'}}) . chop_str($pr->{'owner'}, 15) . "</i></td>\n";
 		my $colored_age;
 		if ($pr->{'commit'}{'age'} < 60*60*2) {
 			$colored_age = "<span style =\"color: #009900;\"><b><i>$pr->{'commit'}{'age_string'}</i></b></span>";
@@ -1057,7 +1057,7 @@ sub git_summary {
 				$ref = " <span class=\"tag\">" . esc_html($refs->{$commit}) . "</span>";
 			}
 			print "<td><i>$co{'age_string'}</i></td>\n" .
-			      "<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
+			      $cgi->start_td({-title => $co{'author_name'}}) . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
 			      "<td>";
 			if (length($co{'title_short'}) < length($co{'title'})) {
 				print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
@@ -2306,7 +2306,7 @@ sub git_history {
 			}
 			$alternate ^= 1;
 			print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
-			      "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" .
+			      $cgi->start_td({-title => $co{'author_name'}}) . esc_html(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" .
 			      "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" .
 			      esc_html(chop_str($co{'title'}, 50)) . "$ref</b>") . "</td>\n" .
 			      "<td class=\"link\">" .
@@ -2396,7 +2396,7 @@ sub git_search {
 			}
 			$alternate ^= 1;
 			print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
-			      "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
+			      $cgi->start_td({-title => $co{'author_name'}}) . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
 			      "<td>" .
 			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b><br/>");
 			my $comment = $co{'comment'};
@@ -2449,7 +2449,7 @@ sub git_search {
 					}
 					$alternate ^= 1;
 					print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
-					      "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
+					      $cgi->start_td({-title => $co{'author_name'}}) . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
 					      "<td>" .
 					      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" .
 					      esc_html(chop_str($co{'title'}, 50)) . "</b><br/>");
@@ -2537,7 +2537,7 @@ sub git_shortlog {
 		}
 		$alternate ^= 1;
 		print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
-		      "<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
+		      $cgi->start_td({-title => $co{'author_name'}}) . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
 		      "<td>";
 		if (length($co{'title_short'}) < length($co{'title'})) {
 			print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
Signature · 1 line
1.3.0
#1 lore raw
Quoted 2 lines · Jakub Narebski

Doesn't work well with values outside us-ascii, but that might be considered web browser bug (misfeature), not a bug in gitweb.

That's sad.

Are you sure about it?

What does start_td({-title=>"blah"}) produce? <td title="blah">? If so, is http://members.cox.net/junkio/t.html close to what you are trying to achieve here?

gitweb/gitweb.cgi sub git_project_list { · line 890

Quoted 3 lines
gitweb/gitweb.cgi +1 -1
 		      "<td>$pr->{'descr'}</td>\n" .
-		      "<td><i>" . chop_str($pr->{'owner'}, 15) . "</i></td>\n";
+		      $cgi->start_td({-title => $pr->{'owner'}}) . chop_str($pr->{'owner'}, 15) . "</i></td>\n";

Where did the opening <i> go? Not that I care about italics, since I think this should all be done with stylesheet, but I do care about unbalanced pairs.

BTW, I haven't nailed down the procedure to update the kernel.org gitweb installations (I suspect the burden is on me since Kay orphaned gitweb onto me).

I wonder if there is somebody who is willing to run gitweb from the "next" branch on some public site, so that I can be reasonably confident before breaking one of the most important infrastructure of the kernel development? Volunteers?

#2 lore raw
Quoted 4 lines · Junio C Hamano

I wonder if there is somebody who is willing to run gitweb from the "next" branch on some public site, so that I can be reasonably confident before breaking one of the most important infrastructure of the kernel development? Volunteers?

Yeah, we can do it on git.infradead.org if you promise to respond quickly when you break it. Or I can set up a virtual host on
http://git2.infradead.org/ to use the testing version if you'd prefer.

Mail me a SSH public key, I'll give you an account.

Signature · 1 line
dwmw2
#3 lore raw
In reply to Junio C Hamano
Quoted 4 lines · Junio C Hamano

I wonder if there is somebody who is willing to run gitweb from the "next" branch on some public site, so that I can be reasonably confident before breaking one of the most important infrastructure of the kernel development? Volunteers?

I can help.

http://onion.dynserv.net/git/gitweb.cgi

Note: http://onion.dynserv.net/git/ (index.cgi) is an old version.

Global symbol "$path" requires explicit package name at /var/www/localhost/htdocs/git/gitweb.cgi line 1521. Execution of /var/www/localhost/htdocs/git/gitweb.cgi aborted due to compilation errors.

The line is:

$file =~ m#^/# or $file = "$projectroot/$path/$file";

$path seems to be undefined. I don't understand perl very well so I can't fix it.

Signature · 1 line
http://onion.dynserv.net/~timo/
#4 lore raw
Quoted 7 lines · Timo Hirvonen

http://onion.dynserv.net/git/gitweb.cgi

Global symbol "$path" requires explicit package name at /var/www/localhost/htdocs/git/gitweb.cgi line 1521. Execution of /var/www/localhost/htdocs/git/gitweb.cgi aborted due to compilation errors.

Quoted 6 lines

The line is:

$file =~ m#^/# or $file = "$projectroot/$path/$file";

$path seems to be undefined. I don't understand perl very well so I can't fix it.

Temporary fix is in:

"[PATCH] Fix: Support for the standard mime.types map in gitweb" (Message-Id: <[email protected]>)

    http://permalink.gmane.org/gmane.comp.version-control.git/22172

BTW. I have _my_ version at
http://front.fuw.edu.pl/cgi-bin/jnareb/gitweb.cgi

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#5 lore raw
Quoted 13 lines · Jakub Narebski
Quoted 11 lines · Timo Hirvonen

http://onion.dynserv.net/git/gitweb.cgi

Global symbol "$path" requires explicit package name at /var/www/localhost/htdocs/git/gitweb.cgi line 1521. Execution of /var/www/localhost/htdocs/git/gitweb.cgi aborted due to compilation errors.

The line is:

$file =~ m#^/# or $file = "$projectroot/$path/$file";

Quoted 8 lines
Quoted 2 lines

$path seems to be undefined. I don't understand perl very well so I can't fix it.

Temporary fix is in:

"[PATCH] Fix: Support for the standard mime.types map in gitweb" (Message-Id: <[email protected]>)

    http://permalink.gmane.org/gmane.comp.version-control.git/22172

Seems to work now. I also enabled blame and it works too. But I noticed that the search is sometimes broken. If you click a "blob" link and then try to search something gitweb will complain:

403 Forbidden - Unknown commit object.

"h" parameter is blob, not commit. Shouldn't the h parameter be set to HEAD always when searching? Searching starts at h so the search results vary:

http://onion.dynserv.net/git/gitweb.cgi?p=cmus.git&a=search&h=HEAD&s=pickaxe%3Atheme

http://onion.dynserv.net/git/gitweb.cgi?p=cmus.git&a=search&h=fd2d983d51858e25cc71b14b59c787e1683ba7c5&s=pickaxe%3Atheme

Signature · 1 line
http://onion.dynserv.net/~timo/
#6 lore raw
In reply to Junio C Hamano
Quoted 8 lines · Junio C Hamano
Quoted 2 lines · Jakub Narebski

Doesn't work well with values outside us-ascii, but that might be considered web browser bug (misfeature), not a bug in gitweb.

That's sad.

Are you sure about it?

Now I see I was wrong.

Quoted 3 lines

What does start_td({-title=>"blah"}) produce? <td title="blah">? If so, is http://members.cox.net/junkio/t.html close to what you are trying to achieve here?

Yes, that is what I tried to achieve. Using CGI to set attributes was to quote characters which cannot be in double quited attribute values, i.e. change '"' to '&#34;' or '&quot;'. I don't know what start_td did with \"o character (Perl v5.8.6, CGI::VERSION=3.05).

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git