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

[PATCH] gitweb: start to generate PATH_INFO URLs.

From
Martin Waitz <tali@admingilde.org>
Date
Oct 1, 2006, 21:57 UTC
Message-ID
<20061001215748.GG2871@admingilde.org>
In-Reply-To
<7vfye9dtv7.fsf@assigned-by-dhcp.cox.net>

Instead of providing the project as a ?p= parameter it is simply appended to the base URI. All other parameters are appended to that, except for ?a=summary which is the default and can be omitted.

The old URL generation can be selected by disabling the "pathinfo" feature in gitweb_config.perl.

Signed-off-by: Martin Waitz <tali@admingilde.org>
---
 gitweb/gitweb.perl |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 597d29f..edbd3ea 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -102,6 +102,10 @@ our %feature = (
 		'sub' => \&feature_pickaxe,
 		'override' => 0,
 		'default' => [1]},
+
+	'pathinfo' => {
+		'override' => 0,
+		'default' => [1]},
 );
 
 sub gitweb_check_feature {
@@ -355,6 +359,7 @@ ## action links
 
 sub href(%) {
 	my %params = @_;
+	my $href = $my_uri;
 
 	my @mapping = (
 		project => "p",
@@ -373,6 +378,19 @@ sub href(%) {
 
 	$params{'project'} = $project unless exists $params{'project'};
 
+	my ($use_pathinfo) = gitweb_check_feature('pathinfo');
+	if ($use_pathinfo) {
+		# use PATH_INFO for project name
+		$href .= "/$params{'project'}" if defined $params{'project'};
+		delete $params{'project'};
+
+		# Summary just uses the project path URL
+		if (defined $params{'action'} && $params{'action'} eq 'summary') {
+			delete $params{'action'};
+		}
+	}
+
+	# now encode the parameters explicitly
 	my @result = ();
 	for (my $i = 0; $i < @mapping; $i += 2) {
 		my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
@@ -380,7 +398,9 @@ sub href(%) {
 			push @result, $symbol . "=" . esc_param($params{$name});
 		}
 	}
-	return "$my_uri?" . join(';', @result);
+	$href .= "?" . join(';', @result) if scalar @result;
+
+	return $href;
 }
 
 
-- 
1.4.2.gb8b6b

-- 
Martin Waitz
Previous: Junio C HamanoNext: Jakub Narebski
Message 5 of 19 in “gitweb: start to generate PATH_INFO URLs”
  1. gitweb: start to generate PATH_INFO URLsMartin Waitz, Sep 29, 2006
  2. Junio C HamanoSep 29, 2006
  3. Martin WaitzSep 30, 2006
  4. Junio C HamanoSep 30, 2006
  5. gitweb: start to generate PATH_INFO URLs.Martin Waitz, Oct 1, 2006
  6. Jakub NarebskiOct 3, 2006
  7. Junio C HamanoOct 3, 2006
  8. Jakub NarebskiOct 3, 2006
  9. Junio C HamanoOct 3, 2006
  10. Martin WaitzOct 3, 2006
  11. gitweb: warn if feature cannot be overridden.Martin Waitz, Oct 3, 2006
  12. Jakub NarebskiOct 3, 2006
  13. gitweb: make PATHINFO URL generation conditional on input URL.Martin Waitz, Oct 3, 2006
  14. Petr BaudisOct 6, 2006
  15. Junio C HamanoOct 7, 2006
  16. Jakub NarebskiOct 3, 2006
  17. Martin WaitzOct 3, 2006
  18. Jakub NarebskiOct 3, 2006
  19. Junio C HamanoOct 3, 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.