git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/4] gitweb: Improve git_print_page_path

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 21, 2006, 15:53 UTC
Message-ID
<200610211753.56029.jnareb@gmail.com>
In-Reply-To
<200610211750.49188.jnareb@gmail.com>

Add link to "tree root" (root directory) also for not defined name, for example for "tree" action without defined "file_name" which means "tree root".

Add " / " at the end of path when $type eq "tree".
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Consistency (and code simplification).
 gitweb/gitweb.perl |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 209b318..126cf3c 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1615,17 +1615,16 @@ sub git_print_page_path {
 	my $type = shift;
 	my $hb = shift;
 
-	if (!defined $name) {
-		print "<div class=\"page_path\">/</div>\n";
-	} else {
+
+	print "<div class=\"page_path\">";
+	print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
+	              -title => 'tree root'}, "[$project]");
+	print " / ";
+	if (defined $name) {
 		my @dirname = split '/', $name;
 		my $basename = pop @dirname;
 		my $fullname = '';
 
-		print "<div class=\"page_path\">";
-		print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
-			      -title => 'tree root'}, "[$project]");
-		print " / ";
 		foreach my $dir (@dirname) {
 			$fullname .= ($fullname ? '/' : '') . $dir;
 			print $cgi->a({-href => href(action=>"tree", file_name=>$fullname,
@@ -1641,11 +1640,12 @@ sub git_print_page_path {
 			print $cgi->a({-href => href(action=>"tree", file_name=>$file_name,
 			                             hash_base=>$hb),
 			              -title => $name}, esc_html($basename));
+			print " / ";
 		} else {
 			print esc_html($basename);
 		}
-		print "<br/></div>\n";
 	}
+	print "<br/></div>\n";
 }
 
 # sub git_print_log (\@;%) {
-- 
1.4.2.1
Previous: Jakub NarebskiNext: Jakub Narebski
Message 10 of 11 in “gitweb: Improving tree view (plus some cleanups)”
  1. 0/4 gitweb: Improving tree view (plus some cleanups)Jakub Narebski, Oct 21, 2006
  2. 1/4 gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)Jakub Narebski, Oct 21, 2006
  3. Junio C HamanoOct 22, 2006
  4. Jakub NarebskiOct 22, 2006
  5. Linus TorvaldsOct 22, 2006
  6. Jakub NarebskiOct 22, 2006
  7. Junio C HamanoOct 22, 2006
  8. Luben TuikovOct 22, 2006
  9. 2/4 gitweb: Do not esc_html $basedir argument to git_print_tree_entryJakub Narebski, Oct 21, 2006
  10. 3/4 gitweb: Improve git_print_page_pathJakub Narebski, Oct 21, 2006
  11. 4/4 gitweb: Add '..' (up directory) to tree view if applicableJakub Narebski, Oct 21, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.