From: Luben Tuikov Date: Sun, 23 Jul 2006 20:31:15 +0000 (-0700) Subject: gitweb.cgi: Centralize printing of the page path X-Git-Tag: v1.4.2-rc3~33^2~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=634331061599a82968daddae2d2c0896b6137d4c;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index c04283ba5..4106cb8eb 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -1199,6 +1199,20 @@ sub git_summary { git_footer_html(); } +sub git_print_page_path { + my $name = shift; + my $type = shift; + + if (!defined $name) { + print "
/
\n"; + } elsif ($type =~ "blob") { + print "
" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;f=$file_name")}, esc_html($name)) . "
\n"; + } else { + print "
" . esc_html($name) . "
\n"; + } +} + sub git_tag { my $head = git_read_head($project); git_header_html(); @@ -1266,7 +1280,7 @@ sub git_blame { "
" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "
\n"; - print "
" . esc_html($file_name) . "
\n"; + git_print_page_path($file_name); print "
\n"; print < @@ -1604,9 +1618,7 @@ sub git_blob { "

\n" . "
$hash
\n"; } - if (defined $file_name) { - print "
" . esc_html($file_name) . "
\n"; - } + git_print_page_path($file_name, "blob"); print "
\n"; my $nr; while (my $line = <$fd>) { @@ -1671,10 +1683,8 @@ sub git_tree { } if (defined $file_name) { $base = esc_html("$file_name/"); - print "
/" . esc_html($file_name) . "
\n"; - } else { - print "
/
\n"; } + git_print_page_path($file_name); print "
\n"; print "\n"; my $alternate = 0; @@ -2132,9 +2142,7 @@ sub git_blobdiff { "

\n" . "
$hash vs $hash_parent
\n"; } - if (defined $file_name) { - print "
/" . esc_html($file_name) . "
\n"; - } + git_print_page_path($file_name, "blob"); print "
\n" . "
blob:" . $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 { if (!defined $hash_base) { $hash_base = git_read_head($project); } + my $ftype; my %co = git_read_commit($hash_base); if (!%co) { die_error(undef, "Unknown commit object."); @@ -2330,17 +2339,9 @@ sub git_history { $hash = git_get_hash_by_path($hash_base, $file_name); } if (defined $hash) { - my $ftype = git_get_type($hash); - - if ($ftype =~ "blob") { - print "
/" . - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;f=$file_name")}, esc_html($file_name)) . "
\n"; - } else { - print "
/" . esc_html($file_name) . "
\n"; - } - } else { - print "
/" . esc_html($file_name) . "
\n"; + $ftype = git_get_type($hash); } + git_print_page_path($file_name, $ftype); open my $fd, "-|", "$GIT rev-list --full-history $hash_base -- \'$file_name\'";