@@ -1469,6 +1469,16 @@ sub format_subject_html {
1469
1469
}
1470
1470
}
1471
1471
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
+
1472
1482
# format git diff header line, i.e. "diff --(git|combined|cc) ..."
1473
1483
sub format_git_diff_header_line {
1474
1484
my $line = shift ;
@@ -3214,21 +3224,50 @@ sub git_print_header_div {
3214
3224
" \n </div>\n " ;
3215
3225
}
3216
3226
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
3217
3239
sub git_print_authorship {
3218
3240
my $co = shift ;
3241
+ my %opts = @_ ;
3242
+ my $tag = $opts {-tag} || ' div' ;
3219
3243
3220
3244
my %ad = parse_date($co -> {' author_epoch' }, $co -> {' author_tz' });
3221
- print " <div class=\" author_date\" >" .
3245
+ print " <$tag class=\" author_date\" >" .
3222
3246
esc_html($co -> {' author_name' }) .
3223
3247
" [$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 " ;
3230
3270
}
3231
- print " ]</div>\n " ;
3232
3271
}
3233
3272
3234
3273
sub git_print_page_path {
@@ -4142,11 +4181,9 @@ sub git_shortlog_body {
4142
4181
print " <tr class=\" light\" >\n " ;
4143
4182
}
4144
4183
$alternate ^= 1;
4145
- my $author = chop_and_escape_str($co {' author_name' }, 10);
4146
4184
# git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
4147
4185
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>" ;
4150
4187
print format_subject_html($co {' title' }, $co {' title_short' },
4151
4188
href(action => " commit" , hash => $commit ), $ref );
4152
4189
print " </td>\n " .
@@ -4193,11 +4230,9 @@ sub git_history_body {
4193
4230
print " <tr class=\" light\" >\n " ;
4194
4231
}
4195
4232
$alternate ^= 1;
4196
- # shortlog uses chop_str($co{'author_name'}, 10)
4197
- my $author = chop_and_escape_str($co {' author_name' }, 15, 3);
4198
4233
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>" ;
4201
4236
# originally git_history used chop_str($co{'title'}, 50)
4202
4237
print format_subject_html($co {' title' }, $co {' title_short' },
4203
4238
href(action => " commit" , hash => $commit ), $ref );
@@ -4350,9 +4385,8 @@ sub git_search_grep_body {
4350
4385
print " <tr class=\" light\" >\n " ;
4351
4386
}
4352
4387
$alternate ^= 1;
4353
- my $author = chop_and_escape_str($co {' author_name' }, 15, 5);
4354
4388
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) .
4356
4390
" <td>" .
4357
4391
$cgi -> a({-href => href(action => " commit" , hash => $co {' id' }),
4358
4392
-class => " list subject" },
@@ -5094,9 +5128,9 @@ sub git_log {
5094
5128
" | " .
5095
5129
$cgi -> a({-href => href(action => " tree" , hash => $commit , hash_base => $commit )}, " tree" ) .
5096
5130
" <br/>\n " .
5097
- " </div>\n " .
5098
- " <i>" . esc_html($co {' author_name' }) . " [$ad {'rfc2822'}]</i><br/>\n " .
5099
5131
" </div>\n " ;
5132
+ git_print_authorship(\%co , -tag => ' span' );
5133
+ print " <br/>\n </div>\n " ;
5100
5134
5101
5135
print " <div class=\" log_body\" >\n " ;
5102
5136
git_print_log($co {' comment' }, -final_empty_line => 1);
@@ -5115,8 +5149,6 @@ sub git_commit {
5115
5149
$hash ||= $hash_base || " HEAD" ;
5116
5150
my %co = parse_commit($hash )
5117
5151
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' });
5120
5152
5121
5153
my $parent = $co {' parent' };
5122
5154
my $parents = $co {' parents' }; # listref
@@ -5183,22 +5215,7 @@ sub git_commit {
5183
5215
}
5184
5216
print " <div class=\" title_text\" >\n " .
5185
5217
" <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 );
5202
5219
print " <tr><td>commit</td><td class=\" sha1\" >$co {'id'}</td></tr>\n " ;
5203
5220
print " <tr>" .
5204
5221
" <td>tree</td>" .
@@ -5579,7 +5596,7 @@ sub git_commitdiff {
5579
5596
git_header_html(undef , $expires );
5580
5597
git_print_page_nav(' commitdiff' ,' ' , $hash ,$co {' tree' },$hash , $formats_nav );
5581
5598
git_print_header_div(' commit' , esc_html($co {' title' }) . $ref , $hash );
5582
- git_print_authorship(\%co );
5599
+ git_print_authorship(\%co , - localtime => 1 );
5583
5600
print " <div class=\" page_body\" >\n " ;
5584
5601
if (@{$co {' comment' }} > 1) {
5585
5602
print " <div class=\" log\" >\n " ;
0 commit comments