git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <bebarino@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>
Subject: [RFC/PATCH] gitweb: linkify author/committer names with search
Date: Sun, 11 Oct 2009 23:19:00 -0700	[thread overview]
Message-ID: <1255328340-28449-1-git-send-email-bebarino@gmail.com> (raw)

It's nice to search for an author by merely clicking on their name in
gitweb. This is usually faster than selecting the name, copying the
selection, pasting it into the search box, selecting between
author/committer and then hitting enter.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

Cc'ed Jakub as he seems to be resident gitweb expert. 

I thought this might be a nice addition.

The problem is I can't get it to work with UTF-8 characters. I'm not sure
if it's my system or not, so I'm just posting here to see if others
experience the same problem and if there's interest.

 gitweb/gitweb.perl |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 24b2193..349e734 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1604,7 +1604,10 @@ sub format_author_html {
 	my $author = chop_and_escape_str($co->{'author_name'}, @_);
 	return "<$tag class=\"author\">" .
 	       git_get_avatar($co->{'author_email'}, -pad_after => 1) .
-	       $author . "</$tag>";
+	       $cgi->a({-href => href(action=>"search", hash=>$hash,
+			searchtext=>$co->{'author_name'},
+			searchtype=>"author"), class=>"list"}, $author) .
+	       "</$tag>";
 }
 
 # format git diff header line, i.e. "diff --(git|combined|cc) ..."
@@ -3373,10 +3376,13 @@ sub git_print_authorship {
 	my $co = shift;
 	my %opts = @_;
 	my $tag = $opts{-tag} || 'div';
+	my $author = $co->{'author_name'};
 
 	my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
 	print "<$tag class=\"author_date\">" .
-	      esc_html($co->{'author_name'}) .
+	      $cgi->a({-href => href(action=>"search", searchtext=>$author,
+		      searchtype=>"author"), class=>"list"},
+		      esc_html($author)) .
 	      " [$ad{'rfc2822'}";
 	print_local_time(%ad) if ($opts{-localtime});
 	print "]" . git_get_avatar($co->{'author_email'}, -pad_before => 1)
@@ -3395,8 +3401,12 @@ sub git_print_authorship_rows {
 	@people = ('author', 'committer') unless @people;
 	foreach my $who (@people) {
 		my %wd = parse_date($co->{"${who}_epoch"}, $co->{"${who}_tz"});
-		print "<tr><td>$who</td><td>" . esc_html($co->{$who}) . "</td>" .
-		      "<td rowspan=\"2\">" .
+		print "<tr><td>$who</td><td>" .
+		      $cgi->a({-href => href(action=>"search",
+			       searchtext=>$co->{"${who}_name"},
+			       searchtype=>$who), class=>"list"},
+			       esc_html($co->{$who})) .
+		      "</td><td rowspan=\"2\">" .
 		      git_get_avatar($co->{"${who}_email"}, -size => 'double') .
 		      "</td></tr>\n" .
 		      "<tr>" .
-- 
1.6.5.1.g53fd

             reply	other threads:[~2009-10-12  6:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-12  6:19 Stephen Boyd [this message]
2009-10-12 23:42 ` [RFC/PATCH] gitweb: linkify author/committer names with search Junio C Hamano
2009-10-13  0:31   ` Stephen Boyd
2009-10-13 10:26 ` Giuseppe Bilotta
2009-10-13 18:39   ` Stephen Boyd
2009-10-13 19:41     ` Giuseppe Bilotta
2009-10-13 20:16       ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255328340-28449-1-git-send-email-bebarino@gmail.com \
    --to=bebarino@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).