Re: [PATCH] gitweb: linkify author/committer names with search
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 14, 2009, 09:13 UTC
- Message-ID
- <7v7huyfidb.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1255486344-11891-1-git-send-email-bebarino@gmail.com>
Stephen Boyd <bebarino@gmail.com> writes:
Show 28 quoted lines
> 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.
>
> Linkify the avatar icon in log/shortlog view because the icon is directly
> adjacent to the name and thus more related. The same is not true
> when in commit/tag view where the icon is farther away.
>
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
> ---
>
> This is on top of Giuseppe's fix esc_param patch.
>
> gitweb/gitweb.css | 1 +
> gitweb/gitweb.perl | 21 ++++++++++++++++-----
> 2 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
> index 8f68fe3..e2cd9d7 100644
> --- a/gitweb/gitweb.css
> +++ b/gitweb/gitweb.css
> @@ -30,6 +30,7 @@ img.logo {
>
> img.avatar {
> vertical-align: middle;
> + border-width: 0px;
> }Even though it _might_ be a good thing to do, this looks an unrelated change,
Show 52 quoted lines
> div.page_header {
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 4b21ad2..bdf1037 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1602,8 +1602,12 @@ sub format_author_html {
> my $co = shift;
> 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"},
> + git_get_avatar($co->{'author_email'}, -pad_after => 1) .
> + $author) .
> + "</$tag>";
> }
>
> # format git diff header line, i.e. "diff --(git|combined|cc) ..."
> @@ -3372,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)
> @@ -3394,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.g75846.dirty