# [RFC/PATCH] gitweb: linkify author/committer names with search

7 messages from 2009-10-12 to 2009-10-13. Participants: Stephen Boyd, Junio C Hamano, Giuseppe Bilotta.
Thread: https://gitlist.dev/t/21205

## Stephen Boyd, 2009-10-12 06:19

Subject: [RFC/PATCH] gitweb: linkify author/committer names with search
Message-ID: <1255328340-28449-1-git-send-email-bebarino@gmail.com>
URL: https://gitlist.dev/e/1255328340-28449-1-git-send-email-bebarino%40gmail.com

```
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

```

## Junio C Hamano, 2009-10-12 23:42

Subject: Re: [RFC/PATCH] gitweb: linkify author/committer names with search
Message-ID: <7vy6ng5gdr.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy6ng5gdr.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1255328340-28449-1-git-send-email-bebarino@gmail.com>

```
Stephen Boyd <bebarino@gmail.com> writes:

> 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.

The intent makes sense to me, although I somehow suspect that with avatar
support the user might be tempted to click on the icon not necessarily on
the name string.

> 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

```

## Stephen Boyd, 2009-10-13 00:31

Subject: Re: [RFC/PATCH] gitweb: linkify author/committer names with search
Message-ID: <4AD3CA78.6090209@gmail.com>
URL: https://gitlist.dev/e/4AD3CA78.6090209%40gmail.com
In-Reply-To: <7vy6ng5gdr.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano wrote:
>
> The intent makes sense to me, although I somehow suspect that with avatar
> support the user might be tempted to click on the icon not necessarily on
> the name string.

Ok if the utf8 thing can be solved I'll make sure to linkify the icon too.

```

## Giuseppe Bilotta, 2009-10-13 10:26

Subject: Re: [RFC/PATCH] gitweb: linkify author/committer names with search
Message-ID: <1255429615-4402-1-git-send-email-giuseppe.bilotta@gmail.com>
URL: https://gitlist.dev/e/1255429615-4402-1-git-send-email-giuseppe.bilotta%40gmail.com
In-Reply-To: <1255328340-28449-1-git-send-email-bebarino@gmail.com>

```
On Monday 12 October 2009 08:19, Stephen Boyd wrote:

> 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.

Does it work if you use CGI::escape() on the author names when filling
the searchtext?

-- 
Giuseppe "Oblomov" Bilotta

```

## Stephen Boyd, 2009-10-13 18:39

Subject: Re: [RFC/PATCH] gitweb: linkify author/committer names with search
Message-ID: <4AD4C94A.9010909@gmail.com>
URL: https://gitlist.dev/e/4AD4C94A.9010909%40gmail.com
In-Reply-To: <1255429615-4402-1-git-send-email-giuseppe.bilotta@gmail.com>

```
Giuseppe Bilotta wrote:
> On Monday 12 October 2009 08:19, Stephen Boyd wrote:
>> 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.
>
> Does it work if you use CGI::escape() on the author names when filling
> the searchtext?

This doesn't seem to work. Now I get %25 in front of the escaped
characters. For example, a space is now %25%20.

Can you reproduce my problem locally?

```

## Giuseppe Bilotta, 2009-10-13 19:41

Subject: Re: [RFC/PATCH] gitweb: linkify author/committer names with search
Message-ID: <cb7bb73a0910131241t7220a3c2q16e99a8fc62dd29a@mail.gmail.com>
URL: https://gitlist.dev/e/cb7bb73a0910131241t7220a3c2q16e99a8fc62dd29a%40mail.gmail.com
In-Reply-To: <4AD4C94A.9010909@gmail.com>

```
On Tue, Oct 13, 2009 at 8:39 PM, Stephen Boyd <bebarino@gmail.com> wrote:
> Giuseppe Bilotta wrote:
>> On Monday 12 October 2009 08:19, Stephen Boyd wrote:
>>> 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.
>>
>> Does it work if you use CGI::escape() on the author names when filling
>> the searchtext?
>
> This doesn't seem to work. Now I get %25 in front of the escaped
> characters. For example, a space is now %25%20.
>
> Can you reproduce my problem locally?

Reproduced, debugged, patch incoming (the problem is not in your patch
but in esc_param).


-- 
Giuseppe "Oblomov" Bilotta

```

## Stephen Boyd, 2009-10-13 20:16

Subject: Re: [RFC/PATCH] gitweb: linkify author/committer names with search
Message-ID: <780e0a6b0910131316j58703de4l80da2eca547ae337@mail.gmail.com>
URL: https://gitlist.dev/e/780e0a6b0910131316j58703de4l80da2eca547ae337%40mail.gmail.com
In-Reply-To: <cb7bb73a0910131241t7220a3c2q16e99a8fc62dd29a@mail.gmail.com>

```
On Tue, Oct 13, 2009 at 12:41 PM, Giuseppe Bilotta
<giuseppe.bilotta@gmail.com> wrote:
>
> Reproduced, debugged, patch incoming (the problem is not in your patch
> but in esc_param).
>

Thanks. I will test later today. I think a similar problem affects the
branch name labels (the colored boxes with ref names in them) when the
name has utf8 characters.

```
