gitweb: consolidate action URL generation.
Use the href() function instead of string concatenation to generate most URLs to our own CGI. This is a work in progress, not everything has been converted yet. Signed-off-by: Martin Waitz <tali@admingilde.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Martin Waitz committed
Aug 16, 2006 at 00:24 UTC
1c2a4f5addce479c619057c6cdc841802139982f
1 file changed
+84
-87
gitweb/gitweb.perl
+84
-87
@@ -388,7 +388,7 @@ sub format_log_line_html {
388
if ($line =~ m/([0-9a-fA-F]{40})/) {
389
my $hash_text = $1;
390
if (git_get_type($hash_text) eq "commit") {
391
- my $link = $cgi->a({-class => "text", -href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_text")}, $hash_text);
391
+ my $link = $cgi->a({-class => "text", -href => href(action=>"commit", hash=>$hash_text)}, $hash_text);
392
$line =~ s/$hash_text/$link/;
393
}
394
}
@@ -425,16 +425,15 @@ sub format_ref_marker {
425
426
# format, perhaps shortened and with markers, title line
427
sub format_subject_html {
428
- my ($long, $short, $query, $extra) = @_;
428
+ my ($long, $short, $href, $extra) = @_;
429
$extra = '' unless defined($extra);
430
431
if (length($short) < length($long)) {
432
- return $cgi->a({-href => "$my_uri?" . esc_param($query),
433
- -class => "list", -title => $long},
432
+ return $cgi->a({-href => $href, -class => "list",
433
+ -title => $long},
434
esc_html($short) . $extra);
435
} else {
436
- return $cgi->a({-href => "$my_uri?" . esc_param($query),
437
- -class => "list"},
436
+ return $cgi->a({-href => $href, -class => "list"},
437
esc_html($long) . $extra);
438
}
439
}
@@ -998,8 +997,7 @@ EOF
997
if (defined $project) {
998
printf('<link rel="alternate" title="%s log" '.
999
'href="%s" type="application/rss+xml"/>'."\n",
1001
- esc_param($project),
1002
- esc_param("$my_uri?p=$project;a=rss"));
1000
+ esc_param($project), href(action=>"rss"));
1001
}
1002
1003
print "</head>\n" .
@@ -1010,7 +1008,7 @@ EOF
1008
"</a>\n";
1009
print $cgi->a({-href => esc_param($home_link)}, $home_link_str) . " / ";
1010
if (defined $project) {
1013
- print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, esc_html($project));
1011
+ print $cgi->a({-href => href(action=>"summary")}, esc_html($project));
1012
if (defined $action) {
1013
print " / $action";
1014
}
@@ -1047,7 +1045,7 @@ sub git_footer_html {
1045
if (defined $descr) {
1046
print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
1047
}
1050
- print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n";
1048
+ print $cgi->a({-href => href(action=>"rss"), -class => "rss_logo"}, "RSS") . "\n";
1049
} else {
1050
print $cgi->a({-href => "$my_uri?" . esc_param("a=opml"), -class => "rss_logo"}, "OPML") . "\n";
1051
}
@@ -1082,27 +1080,25 @@ sub git_print_page_nav {
1080
@navs = grep { $_ ne $suppress } @navs;
1081
}
1082
1085
- my %arg = map { $_, ''} @navs;
1083
+ my %arg = map { $_ => {action=>$_} } @navs;
1084
if (defined $head) {
1085
for (qw(commit commitdiff)) {
1088
- $arg{$_} = ";h=$head";
1086
+ $arg{$_}{hash} = $head;
1087
}
1088
if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {
1089
for (qw(shortlog log)) {
1092
- $arg{$_} = ";h=$head";
1090
+ $arg{$_}{hash} = $head;
1091
}
1092
}
1093
}
1096
- $arg{tree} .= ";h=$treehead" if defined $treehead;
1097
- $arg{tree} .= ";hb=$treebase" if defined $treebase;
1094
+ $arg{tree}{hash} = $treehead if defined $treehead;
1095
+ $arg{tree}{hash_base} = $treebase if defined $treebase;
1096
1097
print "<div class=\"page_nav\">\n" .
1098
(join " | ",
1101
- map { $_ eq $current
1102
- ? $_
1103
- : $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$_$arg{$_}")}, "$_")
1104
- }
1105
- @navs);
1099
+ map { $_ eq $current ?
1100
+ $_ : $cgi->a({-href => href(%{$arg{$_}})}, "$_")
1101
+ } @navs);
1102
print "<br/>\n$extra<br/>\n" .
1103
"</div>\n";
1104
}
@@ -1113,14 +1109,14 @@ sub format_paging_nav {
1109
1110
1111
if ($hash ne $head || $page) {
1116
- $paging_nav .= $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$action")}, "HEAD");
1112
+ $paging_nav .= $cgi->a({-href => href(action=>$action)}, "HEAD");
1113
} else {
1114
$paging_nav .= "HEAD";
1115
}
1116
1117
if ($page > 0) {
1118
$paging_nav .= " ⋅ " .
1123
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$action;h=$hash;pg=" . ($page-1)),
1119
+ $cgi->a({-href => href(action=>$action, hash=>$hash, page=>$page-1),
1120
-accesskey => "p", -title => "Alt-p"}, "prev");
1121
} else {
1122
$paging_nav .= " ⋅ prev";
@@ -1128,7 +1124,7 @@ sub format_paging_nav {
1124
1125
if ($nrevs >= (100 * ($page+1)-1)) {
1126
$paging_nav .= " ⋅ " .
1131
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$action;h=$hash;pg=" . ($page+1)),
1127
+ $cgi->a({-href => href(action=>$action, hash=>$hash, page=>$page+1),
1128
-accesskey => "n", -title => "Alt-n"}, "next");
1129
} else {
1130
$paging_nav .= " ⋅ next";
@@ -1142,15 +1138,16 @@ sub format_paging_nav {
1138
1139
sub git_print_header_div {
1140
my ($action, $title, $hash, $hash_base) = @_;
1145
- my $rest = '';
1141
+ my %args = ();
1142
1147
- $rest .= ";h=$hash" if $hash;
1148
- $rest .= ";hb=$hash_base" if $hash_base;
1143
+ $args{action} = $action;
1144
+ $args{hash} = $hash if $hash;
1145
+ $args{hash_base} = $hash_base if $hash_base;
1146
1147
print "<div class=\"header\">\n" .
1151
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$action$rest"),
1152
- -class => "title"}, $title ? $title : $action) . "\n" .
1153
- "</div>\n";
1148
+ $cgi->a({-href => href(%args), -class => "title"},
1149
+ $title ? $title : $action) .
1150
+ "\n</div>\n";
1151
}
1152
1153
sub git_print_page_path {
@@ -1161,7 +1158,7 @@ sub git_print_page_path {
1158
print "<div class=\"page_path\"><b>/</b></div>\n";
1159
} elsif (defined $type && $type eq 'blob') {
1160
print "<div class=\"page_path\"><b>" .
1164
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;f=$file_name")}, esc_html($name)) . "</b><br/></div>\n";
1161
+ $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name)}, esc_html($name)) . "</b><br/></div>\n";
1162
} else {
1163
print "<div class=\"page_path\"><b>" . esc_html($name) . "</b><br/></div>\n";
1164
}
@@ -1208,22 +1205,22 @@ sub git_difftree_body {
1205
$mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777);
1206
}
1207
print "<td>" .
1211
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"),
1208
+ $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file),
1209
-class => "list"}, esc_html($file)) .
1210
"</td>\n" .
1211
"<td><span class=\"file_status new\">[new " . file_type($to_mode) . "$mode_chng]</span></td>\n" .
1212
"<td class=\"link\">" .
1216
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") .
1213
+ $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, "blob") .
1214
"</td>\n";
1215
1216
} elsif ($status eq "D") { # deleted
1217
print "<td>" .
1221
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$parent;f=$file"),
1218
+ $cgi->a({-href => href(action=>"blob", hash=>$from_id, hash_base=>$parent, file_name=>$file),
1219
-class => "list"}, esc_html($file)) . "</td>\n" .
1220
"<td><span class=\"file_status deleted\">[deleted " . file_type($from_mode). "]</span></td>\n" .
1221
"<td class=\"link\">" .
1225
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$parent;f=$file")}, "blob") . " | " .
1226
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;hb=$parent;f=$file")}, "history") .
1222
+ $cgi->a({-href => href(action=>"blob", hash=>$from_id, hash_base=>$parent, file_name=>$file)}, "blob") . " | " .
1223
+ $cgi->a({-href => href(action=>"history", hash_base=>$parent, file_name=>$file)}, "history") .
1224
"</td>\n"
1225
1226
} elsif ($status eq "M" || $status eq "T") { # modified, or type changed
@@ -1244,20 +1241,20 @@ sub git_difftree_body {
1241
}
1242
print "<td>";
1243
if ($to_id ne $from_id) { # modified
1247
- print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"),
1244
+ print $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file),
1245
-class => "list"}, esc_html($file));
1246
} else { # mode changed
1250
- print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"),
1247
+ print $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file),
1248
-class => "list"}, esc_html($file));
1249
}
1250
print "</td>\n" .
1251
"<td>$mode_chnge</td>\n" .
1252
"<td class=\"link\">" .
1256
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob");
1253
+ $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, "blob");
1254
if ($to_id ne $from_id) { # modified
1258
- print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff");
1255
+ print $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, "diff");
1256
}
1260
- print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;hb=$hash;f=$file")}, "history") . "\n";
1257
+ print " | " . $cgi->a({-href => href(action=>"history", hash_base=>$hash, file_name=>$file)}, "history") . "\n";
1258
print "</td>\n";
1259
1260
} elsif ($status eq "R") { # renamed
@@ -1267,14 +1264,14 @@ sub git_difftree_body {
1264
$mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777);
1265
}
1266
print "<td>" .
1270
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"),
1267
+ $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$to_file),
1268
-class => "list"}, esc_html($to_file)) . "</td>\n" .
1269
"<td><span class=\"file_status moved\">[moved from " .
1273
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$parent;f=$from_file"),
1270
+ $cgi->a({-href => href(action=>"blob", hash=>$from_id, hash_base=>$parent, file_name=>$from_file),
1271
-class => "list"}, esc_html($from_file)) .
1272
" with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" .
1273
"<td class=\"link\">" .
1277
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob");
1274
+ $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$to_file)}, "blob");
1275
if ($to_id ne $from_id) {
1276
print " | " .
1277
$cgi->a({-href => "$my_uri?" .
@@ -1289,14 +1286,14 @@ sub git_difftree_body {
1286
$mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777);
1287
}
1288
print "<td>" .
1292
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"),
1289
+ $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$to_file),
1290
-class => "list"}, esc_html($to_file)) . "</td>\n" .
1291
"<td><span class=\"file_status copied\">[copied from " .
1295
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$parent;f=$from_file"),
1292
+ $cgi->a({-href => href(action=>"blob", hash=>$from_id, hash_base=>$parent, file_name=>$from_file),
1293
-class => "list"}, esc_html($from_file)) .
1294
" with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" .
1295
"<td class=\"link\">" .
1299
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob");
1296
+ $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$to_file)}, "blob");
1297
if ($to_id ne $from_id) {
1298
print " | " .
1299
$cgi->a({-href => "$my_uri?" .
@@ -1332,11 +1329,11 @@ sub git_shortlog_body {
1329
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1330
"<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
1331
"<td>";
1335
- print format_subject_html($co{'title'}, $co{'title_short'}, "p=$project;a=commit;h=$commit", $ref);
1332
+ print format_subject_html($co{'title'}, $co{'title_short'}, href(action=>"commit", hash=>$commit), $ref);
1333
print "</td>\n" .
1334
"<td class=\"link\">" .
1338
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . " | " .
1339
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1335
+ $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
1336
+ $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
1337
"</td>\n" .
1338
"</tr>\n";
1339
}
@@ -1378,12 +1375,12 @@ sub git_history_body {
1375
"<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" .
1376
"<td>";
1377
# originally git_history used chop_str($co{'title'}, 50)
1381
- print format_subject_html($co{'title'}, $co{'title_short'}, "p=$project;a=commit;h=$commit", $ref);
1378
+ print format_subject_html($co{'title'}, $co{'title_short'}, href(action=>"commit", hash=>$commit), $ref);
1379
print "</td>\n" .
1380
"<td class=\"link\">" .
1384
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . " | " .
1385
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") . " | " .
1386
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$ftype;hb=$commit;f=$file_name")}, $ftype);
1381
+ $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
1382
+ $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") . " | " .
1383
+ $cgi->a({-href => href(action=>$ftype, hash_base=>$commit, file_name=>$file_name)}, $ftype);
1384
1385
if ($ftype eq 'blob') {
1386
my $blob_current = git_get_hash_by_path($hash_base, $file_name);
@@ -1391,7 +1388,7 @@ sub git_history_body {
1388
if (defined $blob_current && defined $blob_parent &&
1389
$blob_current ne $blob_parent) {
1390
print " | " .
1394
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$blob_current;hp=$blob_parent;hb=$commit;f=$file_name")},
1391
+ $cgi->a({-href => href(action=>"blobdiff", hash=>$blob_current, hash_parent=>$blob_parent, hash_base=>$commit, file_name=>$file_name)},
1392
"diff to current");
1393
}
1394
}
@@ -1431,28 +1428,28 @@ sub git_tags_body {
1428
$alternate ^= 1;
1429
print "<td><i>$tag{'age'}</i></td>\n" .
1430
"<td>" .
1434
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"),
1431
+ $cgi->a({-href => href(action=>$tag{'reftype'}, hash=>$tag{'refid'}),
1432
-class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") .
1433
"</td>\n" .
1434
"<td>";
1435
if (defined $comment) {
1439
- print format_subject_html($comment, $comment_short, "p=$project;a=tag;h=$tag{'id'}");
1436
+ print format_subject_html($comment, $comment_short, href(action=>"tag", hash=>$tag{'id'}));
1437
}
1438
print "</td>\n" .
1439
"<td class=\"selflink\">";
1440
if ($tag{'type'} eq "tag") {
1444
- print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}")}, "tag");
1441
+ print $cgi->a({-href => href(action=>"tag", hash=>$tag{'id'})}, "tag");
1442
} else {
1443
print " ";
1444
}
1445
print "</td>\n" .
1446
"<td class=\"link\">" . " | " .
1450
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1447
+ $cgi->a({-href => href(action=>$tag{'reftype'}, hash=>$tag{'refid'})}, $tag{'reftype'});
1448
if ($tag{'reftype'} eq "commit") {
1452
- print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1453
- " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'refid'}")}, "log");
1449
+ print " | " . $cgi->a({-href => href(action=>"shortlog", hash=>$tag{'name'})}, "shortlog") .
1450
+ " | " . $cgi->a({-href => href(action=>"log", hash=>$tag{'refid'})}, "log");
1451
} elsif ($tag{'reftype'} eq "blob") {
1455
- print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$tag{'refid'}")}, "raw");
1452
+ print " | " . $cgi->a({-href => href(action=>"blob_plain", hash=>$tag{'refid'})}, "raw");
1453
}
1454
print "</td>\n" .
1455
"</tr>";
@@ -1485,12 +1482,12 @@ sub git_heads_body {
1482
$alternate ^= 1;
1483
print "<td><i>$tag{'age'}</i></td>\n" .
1484
($tag{'id'} eq $head ? "<td class=\"current_head\">" : "<td>") .
1488
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}"),
1485
+ $cgi->a({-href => href(action=>"shortlog", hash=>$tag{'name'}),
1486
-class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") .
1487
"</td>\n" .
1488
"<td class=\"link\">" .
1492
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . " | " .
1493
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'name'}")}, "log") .
1489
+ $cgi->a({-href => href(action=>"shortlog", hash=>$tag{'name'})}, "shortlog") . " | " .
1490
+ $cgi->a({-href => href(action=>"log", hash=>$tag{'name'})}, "log") .
1491
"</td>\n" .
1492
"</tr>";
1493
}
@@ -1714,20 +1711,20 @@ sub git_summary {
1711
close $fd;
1712
git_print_header_div('shortlog');
1713
git_shortlog_body(\@revlist, 0, 15, $refs,
1717
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "..."));
1714
+ $cgi->a({-href => href(action=>"shortlog")}, "..."));
1715
1716
my $taglist = git_get_refs_list("refs/tags");
1717
if (defined @$taglist) {
1718
git_print_header_div('tags');
1719
git_tags_body($taglist, 0, 15,
1723
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tags")}, "..."));
1720
+ $cgi->a({-href => href(action=>"tags")}, "..."));
1721
}
1722
1723
my $headlist = git_get_refs_list("refs/heads");
1724
if (defined @$headlist) {
1725
git_print_header_div('heads');
1726
git_heads_body($headlist, $head, 0, 15,
1730
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=heads")}, "..."));
1727
+ $cgi->a({-href => href(action=>"heads")}, "..."));
1728
}
1729
1730
git_footer_html();
@@ -1743,8 +1740,8 @@ sub git_tag {
1740
"<table cellspacing=\"0\">\n" .
1741
"<tr>\n" .
1742
"<td>object</td>\n" .
1746
- "<td>" . $cgi->a({-class => "list", -href => "$my_uri?" . esc_param("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" .
1747
- "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" .
1743
+ "<td>" . $cgi->a({-class => "list", -href => href(action=>$tag{'type'}, hash=>$tag{'object'})}, $tag{'object'}) . "</td>\n" .
1744
+ "<td class=\"link\">" . $cgi->a({-href => href(action=>$tag{'type'}, hash=>$tag{'object'})}, $tag{'type'}) . "</td>\n" .
1745
"</tr>\n";
1746
if (defined($tag{'author'})) {
1747
my %ad = parse_date($tag{'epoch'}, $tag{'tz'});
@@ -1783,8 +1780,8 @@ sub git_blame2 {
1780
or die_error(undef, "Open git-blame failed");
1781
git_header_html();
1782
my $formats_nav =
1786
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, "blob") .
1787
- " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;f=$file_name")}, "head");
1783
+ $cgi->a({-href => href(action=>"blobl", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, "blob") .
1784
+ " | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, "head");
1785
git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1786
git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
1787
git_print_page_path($file_name, $ftype);
@@ -1810,7 +1807,7 @@ sub git_blame2 {
1807
}
1808
print "<tr class=\"$rev_color[$current_color]\">\n";
1809
print "<td class=\"sha1\">" .
1813
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$full_rev;f=$file_name")}, esc_html($rev)) . "</td>\n";
1810
+ $cgi->a({-href => href(action=>"commit", hash=>$full_rev, file_name=>$file_name)}, esc_html($rev)) . "</td>\n";
1811
print "<td class=\"linenr\"><a id=\"l$lineno\" href=\"#l$lineno\" class=\"linenr\">" . esc_html($lineno) . "</a></td>\n";
1812
print "<td class=\"pre\">" . esc_html($data) . "</td>\n";
1813
print "</tr>\n";
@@ -1837,8 +1834,8 @@ sub git_blame {
1834
or die_error(undef, "Open git-annotate failed");
1835
git_header_html();
1836
my $formats_nav =
1840
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, "blob") .
1841
- " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;f=$file_name")}, "head");
1837
+ $cgi->a({-href => href(action=>"blobl", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, "blob") .
1838
+ " | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, "head");
1839
git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1840
git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
1841
git_print_page_path($file_name, 'blob');
@@ -1893,7 +1890,7 @@ HTML
1890
1891
print <<HTML;
1892
<tr class="$line_class[$line_class_num]">
1896
- <td class="sha1"><a href="$my_uri?${\esc_param ("p=$project;a=commit;h=$long_rev")}" class="text">$short_rev..</a></td>
1893
+ <td class="sha1"><a href="${\href (action=>"commit", hash=>$long_rev)}" class="text">$short_rev..</a></td>
1894
<td class="$age_class">$age_str</td>
1895
<td>$author</td>
1896
<td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
@@ -1989,13 +1986,13 @@ sub git_blob {
1986
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
1987
if (defined $file_name) {
1988
if ($have_blame) {
1992
- $formats_nav .= $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$hash;hb=$hash_base;f=$file_name")}, "blame") . " | ";
1989
+ $formats_nav .= $cgi->a({-href => href(action=>"blame", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, "blame") . " | ";
1990
}
1991
$formats_nav .=
1995
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") .
1996
- " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;hb=HEAD;f=$file_name")}, "head");
1992
+ $cgi->a({-href => href(action=>"blob_plain", hash=>$hash, file_name=>$file_name)}, "plain") .
1993
+ " | " . $cgi->a({-href => href(action=>"blob", hash_base=>"HEAD", file_name=>$file_name)}, "head");
1994
} else {
1998
- $formats_nav .= $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash")}, "plain");
1995
+ $formats_nav .= $cgi->a({-href => href(action=>"blob_plain", hash=>$hash)}, "plain");
1996
}
1997
git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1998
git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
@@ -2139,8 +2136,8 @@ sub git_log {
2136
$commit);
2137
print "<div class=\"title_text\">\n" .
2138
"<div class=\"log_link\">\n" .
2142
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
2143
- " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2139
+ $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") .
2140
+ " | " . $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
2141
"<br/>\n" .
2142
"</div>\n" .
2143
"<i>" . esc_html($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
@@ -2197,7 +2194,7 @@ sub git_commit {
2194
my $formats_nav = '';
2195
if (defined $file_name && defined $co{'parent'}) {
2196
my $parent = $co{'parent'};
2200
- $formats_nav .= $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;hb=$parent;f=$file_name")}, "blame");
2197
+ $formats_nav .= $cgi->a({-href => href(action=>"blame", hash_parent=>$parent, file_name=>$file_name)}, "blame");
2198
}
2199
git_header_html(undef, $expires);
2200
git_print_page_nav('commit', defined $co{'parent'} ? '' : 'commitdiff',
@@ -2227,19 +2224,19 @@ sub git_commit {
2224
print "<tr>" .
2225
"<td>tree</td>" .
2226
"<td class=\"sha1\">" .
2230
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) .
2227
+ $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash), class => "list"}, $co{'tree'}) .
2228
"</td>" .
2232
- "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2229
+ "<td class=\"link\">" . $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash)}, "tree") .
2230
"</td>" .
2231
"</tr>\n";
2232
my $parents = $co{'parents'};
2233
foreach my $par (@$parents) {
2234
print "<tr>" .
2235
"<td>parent</td>" .
2239
- "<td class=\"sha1\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" .
2236
+ "<td class=\"sha1\">" . $cgi->a({-href => href(action=>"commit", hash=>$par), class => "list"}, $par) . "</td>" .
2237
"<td class=\"link\">" .
2241
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$par")}, "commit") .
2242
- " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") .
2238
+ $cgi->a({-href => href(action=>"commit", hash=>$par)}, "commit") .
2239
+ " | " . $cgi->a({-href => href(action=>"commitdiff", hash=>$hash, hash_parent=>$par)}, "commitdiff") .
2240
"</td>" .
2241
"</tr>\n";
2242
}