diff options
author | Jakub Narebski <jnareb@gmail.com> | 2006-10-21 17:54:44 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-10-22 22:54:08 -0700 |
commit | b6b7fc7283bd091822541c0286340e78b0c497a2 (patch) | |
tree | 89162ee7dabc8a05b023ea7822a0c03518d7d08a | |
parent | gitweb: Improve git_print_page_path (diff) | |
download | tgif-b6b7fc7283bd091822541c0286340e78b0c497a2.tar.xz |
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>
-rwxr-xr-x | gitweb/gitweb.perl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 126cf3c2e2..c9e57f0516 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2871,6 +2871,30 @@ sub git_tree { print "<div class=\"page_body\">\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 1; + # '..' (top directory) link if possible + if (defined $hash_base && + defined $file_name && $file_name =~ m![^/]+$!) { + if ($alternate) { + print "<tr class=\"dark\">\n"; + } else { + print "<tr class=\"light\">\n"; + } + $alternate ^= 1; + + my $up = $file_name; + $up =~ s!/?[^/]+$!!; + undef $up unless $up; + # based on git_print_tree_entry + print '<td class="mode">' . mode_str('040000') . "</td>\n"; + print '<td class="list">'; + print $cgi->a({-href => href(action=>"tree", hash_base=>$hash_base, + file_name=>$up)}, + ".."); + print "</td>\n"; + print "<td class=\"link\"></td>\n"; + + print "</tr>\n"; + } foreach my $line (@entries) { my %t = parse_ls_tree_line($line, -z => 1); |