@@ -1469,6 +1469,16 @@ sub format_subject_html {
14691469 }
14701470}
14711471
1472+ # format the author name of the given commit with the given tag
1473+ # the author name is chopped and escaped according to the other
1474+ # optional parameters (see chop_str).
1475+ sub format_author_html {
1476+ my $tag = shift ;
1477+ my $co = shift ;
1478+ my $author = chop_and_escape_str($co -> {' author_name' }, @_ );
1479+ return " <$tag class=\" author\" >" . $author . " </$tag >" ;
1480+ }
1481+
14721482# format git diff header line, i.e. "diff --(git|combined|cc) ..."
14731483sub format_git_diff_header_line {
14741484 my $line = shift ;
@@ -3214,21 +3224,50 @@ sub git_print_header_div {
32143224 " \n </div>\n " ;
32153225}
32163226
3227+ sub print_local_time {
3228+ my %date = @_ ;
3229+ if ($date {' hour_local' } < 6) {
3230+ printf (" (<span class=\" atnight\" >%02d:%02d</span> %s )" ,
3231+ $date {' hour_local' }, $date {' minute_local' }, $date {' tz_local' });
3232+ } else {
3233+ printf (" (%02d:%02d %s )" ,
3234+ $date {' hour_local' }, $date {' minute_local' }, $date {' tz_local' });
3235+ }
3236+ }
3237+
3238+ # Outputs the author name and date in long form
32173239sub git_print_authorship {
32183240 my $co = shift ;
3241+ my %opts = @_ ;
3242+ my $tag = $opts {-tag} || ' div' ;
32193243
32203244 my %ad = parse_date($co -> {' author_epoch' }, $co -> {' author_tz' });
3221- print " <div class=\" author_date\" >" .
3245+ print " <$tag class=\" author_date\" >" .
32223246 esc_html($co -> {' author_name' }) .
32233247 " [$ad {'rfc2822'}" ;
3224- if ($ad {' hour_local' } < 6) {
3225- printf (" (<span class=\" atnight\" >%02d:%02d</span> %s )" ,
3226- $ad {' hour_local' }, $ad {' minute_local' }, $ad {' tz_local' });
3227- } else {
3228- printf (" (%02d:%02d %s )" ,
3229- $ad {' hour_local' }, $ad {' minute_local' }, $ad {' tz_local' });
3248+ print_local_time(%ad ) if ($opts {-localtime });
3249+ print " ]</$tag >\n " ;
3250+ }
3251+
3252+ # Outputs table rows containing the full author or committer information,
3253+ # in the format expected for 'commit' view (& similia).
3254+ # Parameters are a commit hash reference, followed by the list of people
3255+ # to output information for. If the list is empty it defalts to both
3256+ # author and committer.
3257+ sub git_print_authorship_rows {
3258+ my $co = shift ;
3259+ # too bad we can't use @people = @_ || ('author', 'committer')
3260+ my @people = @_ ;
3261+ @people = (' author' , ' committer' ) unless @people ;
3262+ foreach my $who (@people ) {
3263+ my %wd = parse_date($co -> {" ${who} _epoch" }, $co -> {" ${who} _tz" });
3264+ print " <tr><td>$who </td><td>" . esc_html($co -> {$who }) . " </td></tr>\n " .
3265+ " <tr>" .
3266+ " <td></td><td> $wd {'rfc2822'}" ;
3267+ print_local_time(%wd );
3268+ print " </td>" .
3269+ " </tr>\n " ;
32303270 }
3231- print " ]</div>\n " ;
32323271}
32333272
32343273sub git_print_page_path {
@@ -4142,11 +4181,9 @@ sub git_shortlog_body {
41424181 print " <tr class=\" light\" >\n " ;
41434182 }
41444183 $alternate ^= 1;
4145- my $author = chop_and_escape_str($co {' author_name' }, 10);
41464184 # git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
41474185 print " <td title=\" $co {'age_string_age'}\" ><i>$co {'age_string_date'}</i></td>\n " .
4148- " <td><i>" . $author . " </i></td>\n " .
4149- " <td>" ;
4186+ format_author_html(' td' , \%co , 10) . " <td>" ;
41504187 print format_subject_html($co {' title' }, $co {' title_short' },
41514188 href(action => " commit" , hash => $commit ), $ref );
41524189 print " </td>\n " .
@@ -4193,11 +4230,9 @@ sub git_history_body {
41934230 print " <tr class=\" light\" >\n " ;
41944231 }
41954232 $alternate ^= 1;
4196- # shortlog uses chop_str($co{'author_name'}, 10)
4197- my $author = chop_and_escape_str($co {' author_name' }, 15, 3);
41984233 print " <td title=\" $co {'age_string_age'}\" ><i>$co {'age_string_date'}</i></td>\n " .
4199- " <td><i> " . $author . " </i></td> \n " .
4200- " <td>" ;
4234+ # shortlog: format_author_html('td', \%co, 10)
4235+ format_author_html( ' td ' , \ %co , 15, 3) . " <td>" ;
42014236 # originally git_history used chop_str($co{'title'}, 50)
42024237 print format_subject_html($co {' title' }, $co {' title_short' },
42034238 href(action => " commit" , hash => $commit ), $ref );
@@ -4350,9 +4385,8 @@ sub git_search_grep_body {
43504385 print " <tr class=\" light\" >\n " ;
43514386 }
43524387 $alternate ^= 1;
4353- my $author = chop_and_escape_str($co {' author_name' }, 15, 5);
43544388 print " <td title=\" $co {'age_string_age'}\" ><i>$co {'age_string_date'}</i></td>\n " .
4355- " <td><i> " . $author . " </i></td> \n " .
4389+ format_author_html( ' td ' , \ %co , 15, 5) .
43564390 " <td>" .
43574391 $cgi -> a({-href => href(action => " commit" , hash => $co {' id' }),
43584392 -class => " list subject" },
@@ -5094,9 +5128,9 @@ sub git_log {
50945128 " | " .
50955129 $cgi -> a({-href => href(action => " tree" , hash => $commit , hash_base => $commit )}, " tree" ) .
50965130 " <br/>\n " .
5097- " </div>\n " .
5098- " <i>" . esc_html($co {' author_name' }) . " [$ad {'rfc2822'}]</i><br/>\n " .
50995131 " </div>\n " ;
5132+ git_print_authorship(\%co , -tag => ' span' );
5133+ print " <br/>\n </div>\n " ;
51005134
51015135 print " <div class=\" log_body\" >\n " ;
51025136 git_print_log($co {' comment' }, -final_empty_line => 1);
@@ -5115,8 +5149,6 @@ sub git_commit {
51155149 $hash ||= $hash_base || " HEAD" ;
51165150 my %co = parse_commit($hash )
51175151 or die_error(404, " Unknown commit object" );
5118- my %ad = parse_date($co {' author_epoch' }, $co {' author_tz' });
5119- my %cd = parse_date($co {' committer_epoch' }, $co {' committer_tz' });
51205152
51215153 my $parent = $co {' parent' };
51225154 my $parents = $co {' parents' }; # listref
@@ -5183,22 +5215,7 @@ sub git_commit {
51835215 }
51845216 print " <div class=\" title_text\" >\n " .
51855217 " <table class=\" object_header\" >\n " ;
5186- print " <tr><td>author</td><td>" . esc_html($co {' author' }) . " </td></tr>\n " .
5187- " <tr>" .
5188- " <td></td><td> $ad {'rfc2822'}" ;
5189- if ($ad {' hour_local' } < 6) {
5190- printf (" (<span class=\" atnight\" >%02d:%02d</span> %s )" ,
5191- $ad {' hour_local' }, $ad {' minute_local' }, $ad {' tz_local' });
5192- } else {
5193- printf (" (%02d:%02d %s )" ,
5194- $ad {' hour_local' }, $ad {' minute_local' }, $ad {' tz_local' });
5195- }
5196- print " </td>" .
5197- " </tr>\n " ;
5198- print " <tr><td>committer</td><td>" . esc_html($co {' committer' }) . " </td></tr>\n " ;
5199- print " <tr><td></td><td> $cd {'rfc2822'}" .
5200- sprintf (" (%02d:%02d %s )" , $cd {' hour_local' }, $cd {' minute_local' }, $cd {' tz_local' }) .
5201- " </td></tr>\n " ;
5218+ git_print_authorship_rows(\%co );
52025219 print " <tr><td>commit</td><td class=\" sha1\" >$co {'id'}</td></tr>\n " ;
52035220 print " <tr>" .
52045221 " <td>tree</td>" .
@@ -5579,7 +5596,7 @@ sub git_commitdiff {
55795596 git_header_html(undef , $expires );
55805597 git_print_page_nav(' commitdiff' ,' ' , $hash ,$co {' tree' },$hash , $formats_nav );
55815598 git_print_header_div(' commit' , esc_html($co {' title' }) . $ref , $hash );
5582- git_print_authorship(\%co );
5599+ git_print_authorship(\%co , - localtime => 1 );
55835600 print " <div class=\" page_body\" >\n " ;
55845601 if (@{$co {' comment' }} > 1) {
55855602 print " <div class=\" log\" >\n " ;
0 commit comments