gitweb: Headers refactoring - use git_header_div for header divs
Add git_header_div subroutine which prints "header" divs, now with class "header" (class "title" is taken, and has set CSS style, changing appereance and maing layout wrong), and use it thorough gitweb.cgi. Change header linking to project summary from empty ( as a contents of link) to having $project as contents/name of link. Sometimes a little reordering. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jakub Narebski committed
Jul 30, 2006 at 20:32 UTC
27fb8c40c6b634c67f5b5fb3b354a207cc10b343
1 file changed
+40
-60
gitweb/gitweb.cgi
+40
-60
@@ -420,6 +420,19 @@ sub git_page_nav {
420
"</div>\n";
421
}
422
423
+sub git_header_div {
424
+ my ($action, $title, $hash, $hash_base) = @_;
425
+ my $rest = '';
426
+
427
+ $rest .= ";h=$hash" if $hash;
428
+ $rest .= ";hb=$hash_base" if $hash_base;
429
+
430
+ print "<div class=\"header\">\n" .
431
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$action$rest"),
432
+ -class => "title"}, $title ? $title : $action) . "\n" .
433
+ "</div>\n";
434
+}
435
+
436
sub git_get_paging_nav {
437
my ($action, $hash, $head, $page, $nrevs) = @_;
438
my $paging_nav;
@@ -1123,9 +1136,7 @@ sub git_summary {
1136
or die_error(undef, "Open git-rev-list failed.");
1137
my @revlist = map { chomp; $_ } <$fd>;
1138
close $fd;
1126
- print "<div>\n" .
1127
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog"), -class => "title"}, "shortlog") .
1128
- "</div>\n";
1139
+ git_header_div('shortlog');
1140
my $i = 16;
1141
print "<table cellspacing=\"0\">\n";
1142
my $alternate = 0;
@@ -1169,9 +1180,7 @@ sub git_summary {
1180
1181
my $taglist = git_read_refs("refs/tags");
1182
if (defined @$taglist) {
1172
- print "<div>\n" .
1173
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tags"), -class => "title"}, "tags") .
1174
- "</div>\n";
1183
+ git_header_div('tags');
1184
my $i = 16;
1185
print "<table cellspacing=\"0\">\n";
1186
my $alternate = 0;
@@ -1221,9 +1230,7 @@ sub git_summary {
1230
1231
my $headlist = git_read_refs("refs/heads");
1232
if (defined @$headlist) {
1224
- print "<div>\n" .
1225
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=heads"), -class => "title"}, "heads") .
1226
- "</div>\n";
1233
+ git_header_div('heads');
1234
my $i = 16;
1235
print "<table cellspacing=\"0\">\n";
1236
my $alternate = 0;
@@ -1276,9 +1283,7 @@ sub git_tag {
1283
git_header_html();
1284
git_page_nav('','', $head,undef,$head);
1285
my %tag = git_read_tag($hash);
1279
- print "<div>\n" .
1280
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($tag{'name'})) . "\n" .
1281
- "</div>\n";
1286
+ git_header_div('commit', esc_html($tag{'name'}), $hash);
1287
print "<div class=\"title_text\">\n" .
1288
"<table cellspacing=\"0\">\n" .
1289
"<tr>\n" .
@@ -1326,9 +1331,7 @@ sub git_blame2 {
1331
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, "blob") .
1332
" | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;f=$file_name")}, "head");
1333
git_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1329
- print "<div>" .
1330
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) .
1331
- "</div>\n";
1334
+ git_header_div('commit', esc_html($co{'title'}), $hash_base);
1335
git_print_page_path($file_name, $ftype);
1336
my @rev_color = (qw(light dark));
1337
my $num_colors = scalar(@rev_color);
@@ -1382,9 +1385,7 @@ sub git_blame {
1385
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, "blob") .
1386
" | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;f=$file_name")}, "head");
1387
git_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1385
- print "<div>" .
1386
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) .
1387
- "</div>\n";
1388
+ git_header_div('commit', esc_html($co{'title'}), $hash_base);
1389
git_print_page_path($file_name);
1390
print "<div class=\"page_body\">\n";
1391
print <<HTML;
@@ -1460,11 +1461,10 @@ sub git_tags {
1461
my $head = git_read_head($project);
1462
git_header_html();
1463
git_page_nav('','', $head,undef,$head);
1463
- my $taglist = git_read_refs("refs/tags");
1464
- print "<div>\n" .
1465
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") .
1466
- "</div>\n";
1464
+ git_header_div('summary', $project);
1465
print "<table cellspacing=\"0\">\n";
1466
+
1467
+ my $taglist = git_read_refs("refs/tags");
1468
my $alternate = 0;
1469
if (defined @$taglist) {
1470
foreach my $entry (@$taglist) {
@@ -1511,11 +1511,10 @@ sub git_heads {
1511
my $head = git_read_head($project);
1512
git_header_html();
1513
git_page_nav('','', $head,undef,$head);
1514
- my $taglist = git_read_refs("refs/heads");
1515
- print "<div>\n" .
1516
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") .
1517
- "</div>\n";
1514
+ hit_header_div('summary', $project);
1515
print "<table cellspacing=\"0\">\n";
1516
+
1517
+ my $taglist = git_read_refs("refs/heads");
1518
my $alternate = 0;
1519
if (defined @$taglist) {
1520
foreach my $entry (@$taglist) {
@@ -1684,9 +1683,7 @@ sub git_blob {
1683
$formats_nav .= $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash")}, "plain");
1684
}
1685
git_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1687
- print "<div>" .
1688
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) .
1689
- "</div>\n";
1686
+ git_header_div('commit', esc_html($co{'title'}), $hash_base);
1687
} else {
1688
print "<div class=\"page_nav\">\n" .
1689
"<br/><br/></div>\n" .
@@ -1740,9 +1737,7 @@ sub git_tree {
1737
if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1738
$base_key = ";hb=$hash_base";
1739
git_page_nav('tree','', $hash_base);
1743
- print "<div>\n" .
1744
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" .
1745
- "</div>\n";
1740
+ git_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);
1741
} else {
1742
print "<div class=\"page_nav\">\n";
1743
print "<br/><br/></div>\n";
@@ -1909,10 +1904,9 @@ sub git_log {
1904
git_page_nav('log','', $hash,undef,undef, $paging_nav);
1905
1906
if (!@revlist) {
1912
- print "<div>\n" .
1913
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") .
1914
- "</div>\n";
1907
my %co = git_read_commit($hash);
1908
+
1909
+ git_header_div('summary', $project);
1910
print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1911
}
1912
for (my $i = ($page * 100); $i <= $#revlist; $i++) {
@@ -1924,10 +1918,10 @@ sub git_log {
1918
my %co = git_read_commit($commit);
1919
next if !%co;
1920
my %ad = date_str($co{'author_epoch'});
1927
- print "<div>\n" .
1928
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "title"},
1929
- "<span class=\"age\">$co{'age_string'}</span>" . esc_html($co{'title'}) . $ref) . "\n";
1930
- print "</div>\n";
1921
+ git_header_div('commit',
1922
+ "<span class=\"age\">$co{'age_string'}</span>" .
1923
+ esc_html($co{'title'}) . $ref,
1924
+ $commit);
1925
print "<div class=\"title_text\">\n" .
1926
"<div class=\"log_link\">\n" .
1927
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
@@ -1999,13 +1993,9 @@ sub git_commit {
1993
$formats_nav);
1994
1995
if (defined $co{'parent'}) {
2002
- print "<div>\n" .
2003
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" .
2004
- "</div>\n";
1996
+ git_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);
1997
} else {
2006
- print "<div>\n" .
2007
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
2008
- "</div>\n";
1998
+ git_header_div('tree', esc_html($co{'title'}), $co{'tree'}, $hash);
1999
}
2000
print "<div class=\"title_text\">\n" .
2001
"<table cellspacing=\"0\">\n";
@@ -2171,9 +2161,7 @@ sub git_blobdiff {
2161
my $formats_nav =
2162
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain");
2163
git_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2174
- print "<div>\n" .
2175
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" .
2176
- "</div>\n";
2164
+ git_header_div('commit', esc_html($co{'title'}), $hash_base);
2165
} else {
2166
print "<div class=\"page_nav\">\n" .
2167
"<br/><br/></div>\n" .
@@ -2225,9 +2213,7 @@ sub git_commitdiff {
2213
my $formats_nav =
2214
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain");
2215
git_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
2228
- print "<div>\n" .
2229
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" .
2230
- "</div>\n";
2216
+ git_header_div('commit', esc_html($co{'title'}) . $ref, $hash);
2217
print "<div class=\"page_body\">\n";
2218
my $comment = $co{'comment'};
2219
my $empty = 0;
@@ -2357,9 +2343,7 @@ sub git_history {
2343
my $refs = read_info_ref();
2344
git_header_html();
2345
git_page_nav('','', $hash_base,$co{'tree'},$hash_base);
2360
- print "<div>\n" .
2361
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" .
2362
- "</div>\n";
2346
+ git_header_div('commit', esc_html($co{'title'}), $hash_base);
2347
if (!defined $hash && defined $file_name) {
2348
$hash = git_get_hash_by_path($hash_base, $file_name);
2349
}
@@ -2440,10 +2424,8 @@ sub git_search {
2424
}
2425
git_header_html();
2426
git_page_nav('','', $hash,$co{'tree'},$hash);
2427
+ git_header_div('commit', esc_html($co{'title'}), $hash);
2428
2444
- print "<div>\n" .
2445
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
2446
- "</div>\n";
2429
print "<table cellspacing=\"0\">\n";
2430
my $alternate = 0;
2431
if ($commit_search) {
@@ -2570,10 +2552,8 @@ sub git_shortlog {
2552
2553
git_header_html();
2554
git_page_nav('shortlog','', $hash,$hash,$hash, $paging_nav);
2555
+ git_header_div('summary', $project);
2556
2574
- print "<div>\n" .
2575
- $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") .
2576
- "</div>\n";
2557
print "<table cellspacing=\"0\">\n";
2558
my $alternate = 0;
2559
for (my $i = ($page * 100); $i <= $#revlist; $i++) {