1199
# -full => 0|1 - use absolute/full URL ($my_uri/$my_url as base)
1200
# -replay => 1 - start from a current view (replay with modifications)
1201
# -path_info => 0|1 - don't use/use path_info URL (if possible)
1202
+# -anchor => ANCHOR - add #ANCHOR to end of URL, implies -replay if used alone
1203
sub href {
1204
my %params = @_;
1205
# default is to use -absolute url() i.e. $my_uri
1206
my $href = $params{-full} ? $my_url : $my_uri;
1207
1208
+ # implicit -replay, must be first of implicit params
1209
+ $params{-replay} = 1 if (keys %params == 1 && $params{-anchor});
1210
+
1211
$params{'project'} = $project unless exists $params{'project'};
1212
1213
if ($params{-replay}) {
1318
# final transformation: trailing spaces must be escaped (URI-encoded)
1319
$href =~ s/(\s+)$/CGI::escape($1)/e;
1320
1321
+ if ($params{-anchor}) {
1322
+ $href .= "#".esc_param($params{-anchor});
1323
+ }
1324
+
1325
return $href;
1326
}
1327
4343
# link to patch
4344
$patchno++;
4345
print "<td class=\"link\">" .
4338
- $cgi->a({-href => "#patch$patchno"}, "patch") .
4346
+ $cgi->a({-href => href(-anchor=>"patch$patchno")},
4347
+ "patch") .
4348
" | " .
4349
"</td>\n";
4350
}
4441
if ($action eq 'commitdiff') {
4442
# link to patch
4443
$patchno++;
4435
- print $cgi->a({-href => "#patch$patchno"}, "patch");
4436
- print " | ";
4444
+ print $cgi->a({-href => href(-anchor=>"patch$patchno")},
4445
+ "patch") .
4446
+ " | ";
4447
}
4448
print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'to_id'},
4449
hash_base=>$hash, file_name=>$diff->{'file'})},
4462
if ($action eq 'commitdiff') {
4463
# link to patch
4464
$patchno++;
4455
- print $cgi->a({-href => "#patch$patchno"}, "patch");
4456
- print " | ";
4465
+ print $cgi->a({-href => href(-anchor=>"patch$patchno")},
4466
+ "patch") .
4467
+ " | ";
4468
}
4469
print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'from_id'},
4470
hash_base=>$parent, file_name=>$diff->{'file'})},
4505
if ($action eq 'commitdiff') {
4506
# link to patch
4507
$patchno++;
4497
- print $cgi->a({-href => "#patch$patchno"}, "patch") .
4508
+ print $cgi->a({-href => href(-anchor=>"patch$patchno")},
4509
+ "patch") .
4510
" | ";
4511
} elsif ($diff->{'to_id'} ne $diff->{'from_id'}) {
4512
# "commit" view and modified file (not onlu mode changed)
4551
if ($action eq 'commitdiff') {
4552
# link to patch
4553
$patchno++;
4542
- print $cgi->a({-href => "#patch$patchno"}, "patch") .
4554
+ print $cgi->a({-href => href(-anchor=>"patch$patchno")},
4555
+ "patch") .
4556
" | ";
4557
} elsif ($diff->{'to_id'} ne $diff->{'from_id'}) {
4558
# "commit" view and modified file (not only pure rename or copy)