aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Waitz <tali@admingilde.org>2006-10-01 23:57:48 +0200
committerJunio C Hamano <junkio@cox.net>2006-10-02 00:49:42 -0700
commit9e756904d05a53f1f519492ea1addc3e3163c678 (patch)
treee70388015568b49ca30d6d3f474e2b372c3f70ce
parentf5961572a02ef08324f297fe93b704ff2137e5a6 (diff)
downloadgit-9e756904d05a53f1f519492ea1addc3e3163c678.tar.gz
git-9e756904d05a53f1f519492ea1addc3e3163c678.tar.xz
gitweb: start to generate PATH_INFO URLs.
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 this can be enabled with the "pathinfo" feature in gitweb_config.perl. [jc: let's introduce new features disabled by default not to upset too many existing installations.] Signed-off-by: Martin Waitz <tali@admingilde.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rwxr-xr-xgitweb/gitweb.perl22
1 files changed, 21 insertions, 1 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 44991b153..10e803a97 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' => [0]},
);
sub gitweb_check_feature {
@@ -375,6 +379,7 @@ exit;
sub href(%) {
my %params = @_;
+ my $href = $my_uri;
my @mapping = (
project => "p",
@@ -393,6 +398,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]);
@@ -400,7 +418,9 @@ sub href(%) {
push @result, $symbol . "=" . esc_param($params{$name});
}
}
- return "$my_uri?" . join(';', @result);
+ $href .= "?" . join(';', @result) if scalar @result;
+
+ return $href;
}