Merge branch 'sb/gitweb-link-author'

* sb/gitweb-link-author:
  gitweb: linkify author/committer names with search
This commit is contained in:
Junio C Hamano
2009-10-25 18:40:21 -07:00
2 changed files with 39 additions and 5 deletions

View File

@ -32,6 +32,10 @@ img.avatar {
vertical-align: middle; vertical-align: middle;
} }
a.list img.avatar {
border-style: none;
}
div.page_header { div.page_header {
height: 25px; height: 25px;
padding: 8px; padding: 8px;

View File

@ -1607,6 +1607,29 @@ sub git_get_avatar {
} }
} }
sub format_search_author {
my ($author, $searchtype, $displaytext) = @_;
my $have_search = gitweb_check_feature('search');
if ($have_search) {
my $performed = "";
if ($searchtype eq 'author') {
$performed = "authored";
} elsif ($searchtype eq 'committer') {
$performed = "committed";
}
return $cgi->a({-href => href(action=>"search", hash=>$hash,
searchtext=>$author,
searchtype=>$searchtype), class=>"list",
title=>"Search for commits $performed by $author"},
$displaytext);
} else {
return $displaytext;
}
}
# format the author name of the given commit with the given tag # format the author name of the given commit with the given tag
# the author name is chopped and escaped according to the other # the author name is chopped and escaped according to the other
# optional parameters (see chop_str). # optional parameters (see chop_str).
@ -1615,8 +1638,10 @@ sub format_author_html {
my $co = shift; my $co = shift;
my $author = chop_and_escape_str($co->{'author_name'}, @_); my $author = chop_and_escape_str($co->{'author_name'}, @_);
return "<$tag class=\"author\">" . return "<$tag class=\"author\">" .
git_get_avatar($co->{'author_email'}, -pad_after => 1) . format_search_author($co->{'author_name'}, "author",
$author . "</$tag>"; git_get_avatar($co->{'author_email'}, -pad_after => 1) .
$author) .
"</$tag>";
} }
# format git diff header line, i.e. "diff --(git|combined|cc) ..." # format git diff header line, i.e. "diff --(git|combined|cc) ..."
@ -3400,10 +3425,11 @@ sub git_print_authorship {
my $co = shift; my $co = shift;
my %opts = @_; my %opts = @_;
my $tag = $opts{-tag} || 'div'; my $tag = $opts{-tag} || 'div';
my $author = $co->{'author_name'};
my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'}); my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
print "<$tag class=\"author_date\">" . print "<$tag class=\"author_date\">" .
esc_html($co->{'author_name'}) . format_search_author($author, "author", esc_html($author)) .
" [$ad{'rfc2822'}"; " [$ad{'rfc2822'}";
print_local_time(%ad) if ($opts{-localtime}); print_local_time(%ad) if ($opts{-localtime});
print "]" . git_get_avatar($co->{'author_email'}, -pad_before => 1) print "]" . git_get_avatar($co->{'author_email'}, -pad_before => 1)
@ -3422,8 +3448,12 @@ sub git_print_authorship_rows {
@people = ('author', 'committer') unless @people; @people = ('author', 'committer') unless @people;
foreach my $who (@people) { foreach my $who (@people) {
my %wd = parse_date($co->{"${who}_epoch"}, $co->{"${who}_tz"}); my %wd = parse_date($co->{"${who}_epoch"}, $co->{"${who}_tz"});
print "<tr><td>$who</td><td>" . esc_html($co->{$who}) . "</td>" . print "<tr><td>$who</td><td>" .
"<td rowspan=\"2\">" . format_search_author($co->{"${who}_name"}, $who,
esc_html($co->{"${who}_name"})) . " " .
format_search_author($co->{"${who}_email"}, $who,
esc_html("<" . $co->{"${who}_email"} . ">")) .
"</td><td rowspan=\"2\">" .
git_get_avatar($co->{"${who}_email"}, -size => 'double') . git_get_avatar($co->{"${who}_email"}, -size => 'double') .
"</td></tr>\n" . "</td></tr>\n" .
"<tr>" . "<tr>" .