gitweb: Add '..' (up directory) to tree view if applicable
Adds '..' (up directory) link at the top of "tree" view listing, if both $hash_base and $file_name are provided, and $file_name is not empty string. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jakub Narebski committed
Oct 21, 2006 at 17:54 UTC
b6b7fc7283bd091822541c0286340e78b0c497a2
1 file changed
+24
gitweb/gitweb.perl
+24
@@ -2871,6 +2871,30 @@ sub git_tree {
2871
print "<div class=\"page_body\">\n";
2872
print "<table cellspacing=\"0\">\n";
2873
my $alternate = 1;
2874
+ # '..' (top directory) link if possible
2875
+ if (defined $hash_base &&
2876
+ defined $file_name && $file_name =~ m![^/]+$!) {
2877
+ if ($alternate) {
2878
+ print "<tr class=\"dark\">\n";
2879
+ } else {
2880
+ print "<tr class=\"light\">\n";
2881
+ }
2882
+ $alternate ^= 1;
2883
+
2884
+ my $up = $file_name;
2885
+ $up =~ s!/?[^/]+$!!;
2886
+ undef $up unless $up;
2887
+ # based on git_print_tree_entry
2888
+ print '<td class="mode">' . mode_str('040000') . "</td>\n";
2889
+ print '<td class="list">';
2890
+ print $cgi->a({-href => href(action=>"tree", hash_base=>$hash_base,
2891
+ file_name=>$up)},
2892
+ "..");
2893
+ print "</td>\n";
2894
+ print "<td class=\"link\"></td>\n";
2895
+
2896
+ print "</tr>\n";
2897
+ }
2898
foreach my $line (@entries) {
2899
my %t = parse_ls_tree_line($line, -z => 1);
2900