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>
Martin Waitz committed
Oct 1, 2006 at 23:57 UTC
9e756904d05a53f1f519492ea1addc3e3163c678
1 file changed
+21
-1
gitweb/gitweb.perl
+21
-1
@@ -102,6 +102,10 @@ our %feature = (
102
'sub' => \&feature_pickaxe,
103
'override' => 0,
104
'default' => [1]},
105
+
106
+ 'pathinfo' => {
107
+ 'override' => 0,
108
+ 'default' => [0]},
109
);
110
111
sub gitweb_check_feature {
@@ -375,6 +379,7 @@ exit;
379
380
sub href(%) {
381
my %params = @_;
382
+ my $href = $my_uri;
383
384
my @mapping = (
385
project => "p",
@@ -393,6 +398,19 @@ sub href(%) {
398
399
$params{'project'} = $project unless exists $params{'project'};
400
401
+ my ($use_pathinfo) = gitweb_check_feature('pathinfo');
402
+ if ($use_pathinfo) {
403
+ # use PATH_INFO for project name
404
+ $href .= "/$params{'project'}" if defined $params{'project'};
405
+ delete $params{'project'};
406
+
407
+ # Summary just uses the project path URL
408
+ if (defined $params{'action'} && $params{'action'} eq 'summary') {
409
+ delete $params{'action'};
410
+ }
411
+ }
412
+
413
+ # now encode the parameters explicitly
414
my @result = ();
415
for (my $i = 0; $i < @mapping; $i += 2) {
416
my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
@@ -400,7 +418,9 @@ sub href(%) {
418
push @result, $symbol . "=" . esc_param($params{$name});
419
}
420
}
403
- return "$my_uri?" . join(';', @result);
421
+ $href .= "?" . join(';', @result) if scalar @result;
422
+
423
+ return $href;
424
}
425
426