All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 4/4] gitweb: Add '..' (up directory) to tree view if applicable
Date: Sat, 21 Oct 2006 17:54:44 +0200	[thread overview]
Message-ID: <200610211754.44981.jnareb@gmail.com> (raw)
In-Reply-To: <200610211750.49188.jnareb@gmail.com>

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>
---
This was meant to send as single patch...

 gitweb/gitweb.perl |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 126cf3c..c9e57f0 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);
 
-- 
1.4.2.1

      parent reply	other threads:[~2006-10-21 15:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-21 15:50 [PATCH 0/4] gitweb: Improving tree view (plus some cleanups) Jakub Narebski
2006-10-21 15:52 ` [PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2) Jakub Narebski
2006-10-22 20:22   ` Junio C Hamano
2006-10-22 20:36     ` Jakub Narebski
2006-10-22 21:03       ` Linus Torvalds
2006-10-22 21:27         ` Jakub Narebski
2006-10-22 22:55         ` Junio C Hamano
2006-10-22 23:36         ` Luben Tuikov
2006-10-21 15:53 ` [PATCH 2/4] gitweb: Do not esc_html $basedir argument to git_print_tree_entry Jakub Narebski
2006-10-21 15:53 ` [PATCH 3/4] gitweb: Improve git_print_page_path Jakub Narebski
2006-10-21 15:54 ` Jakub Narebski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200610211754.44981.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.