@matheusbsbs / matheus-bagliano / commits / 6343310615
Fork 0

gitweb.cgi: Centralize printing of the page path

Centralize printing of the page path so that if the entity is a blob, we can set the page path to be the link to the HEAD revision of the "raw" blob. Signed-off-by: Luben Tuikov <ltuikov@yahoo.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Luben Tuikov committed Jul 23, 2006 at 13:31 UTC 634331061599a82968daddae2d2c0896b6137d4c
1 file changed +21 -20
gitweb/gitweb.cgi
+21 -20
@@ -1199,6 +1199,20 @@ sub git_summary {
1199 git_footer_html();
1200 }
1201
1202 +sub git_print_page_path {
1203 + my $name = shift;
1204 + my $type = shift;
1205 +
1206 + if (!defined $name) {
1207 + print "<div class=\"page_path\"><b>/</b></div>\n";
1208 + } elsif ($type =~ "blob") {
1209 + print "<div class=\"page_path\"><b>" .
1210 + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;f=$file_name")}, esc_html($name)) . "</b><br/></div>\n";
1211 + } else {
1212 + print "<div class=\"page_path\"><b>" . esc_html($name) . "</b><br/></div>\n";
1213 + }
1214 +}
1215 +
1216 sub git_tag {
1217 my $head = git_read_head($project);
1218 git_header_html();
@@ -1266,7 +1280,7 @@ sub git_blame {
1280 "<div>" .
1281 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) .
1282 "</div>\n";
1269 - print "<div class=\"page_path\"><b>" . esc_html($file_name) . "</b></div>\n";
1283 + git_print_page_path($file_name);
1284 print "<div class=\"page_body\">\n";
1285 print <<HTML;
1286 <table class="blame">
@@ -1604,9 +1618,7 @@ sub git_blob {
1618 "<br/><br/></div>\n" .
1619 "<div class=\"title\">$hash</div>\n";
1620 }
1607 - if (defined $file_name) {
1608 - print "<div class=\"page_path\"><b>" . esc_html($file_name) . "</b></div>\n";
1609 - }
1621 + git_print_page_path($file_name, "blob");
1622 print "<div class=\"page_body\">\n";
1623 my $nr;
1624 while (my $line = <$fd>) {
@@ -1671,10 +1683,8 @@ sub git_tree {
1683 }
1684 if (defined $file_name) {
1685 $base = esc_html("$file_name/");
1674 - print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b></div>\n";
1675 - } else {
1676 - print "<div class=\"page_path\"><b>/</b></div>\n";
1686 }
1687 + git_print_page_path($file_name);
1688 print "<div class=\"page_body\">\n";
1689 print "<table cellspacing=\"0\">\n";
1690 my $alternate = 0;
@@ -2132,9 +2142,7 @@ sub git_blobdiff {
2142 "<br/><br/></div>\n" .
2143 "<div class=\"title\">$hash vs $hash_parent</div>\n";
2144 }
2135 - if (defined $file_name) {
2136 - print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b></div>\n";
2137 - }
2145 + git_print_page_path($file_name, "blob");
2146 print "<div class=\"page_body\">\n" .
2147 "<div class=\"diff_info\">blob:" .
2148 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) .
@@ -2308,6 +2316,7 @@ sub git_history {
2316 if (!defined $hash_base) {
2317 $hash_base = git_read_head($project);
2318 }
2319 + my $ftype;
2320 my %co = git_read_commit($hash_base);
2321 if (!%co) {
2322 die_error(undef, "Unknown commit object.");
@@ -2330,17 +2339,9 @@ sub git_history {
2339 $hash = git_get_hash_by_path($hash_base, $file_name);
2340 }
2341 if (defined $hash) {
2333 - my $ftype = git_get_type($hash);
2334 -
2335 - if ($ftype =~ "blob") {
2336 - print "<div class=\"page_path\"><b>/" .
2337 - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;f=$file_name")}, esc_html($file_name)) . "</b><br/></div>\n";
2338 - } else {
2339 - print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b><br/></div>\n";
2340 - }
2341 - } else {
2342 - print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b><br/></div>\n";
2342 + $ftype = git_get_type($hash);
2343 }
2344 + git_print_page_path($file_name, $ftype);
2345
2346 open my $fd, "-|",
2347 "$GIT rev-list --full-history $hash_base -- \'$file_name\'";