threads / discuss / 17370

[PATCHv2] gitweb: make static files accessible with PATH_INFO

Subject: [PATCHv2] gitweb: make static files accessible with PATH_INFO

## tl;dr

3 messages between Jan 26, 2009 and Jan 28, 2009.

replies: 2people: 2as markdown or json

Giuseppe Bilotta· Jan 26, 2009, 12:45 UTC · lore

When PATH_INFO is defined, static files such as the defalt CSS or the shortcut icon are not accessible beyond the summary page (e.g. in shortlog or commit view).

Fix this by adding a <base> tag pointing to the script base URL.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
It's sick that $cgi->url() has no way to print the script base url
without path_info information (or that, if it has, it's very well
hidden).
 gitweb/gitweb.perl |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 931db4f..910da35 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2901,6 +2901,14 @@ sub git_header_html {
 <meta name="robots" content="index, nofollow"/>
 <title>$title</title>
 EOF
+# the stylesheet, favicon etc urls won't work correctly with path_info unless we set the appropriate base URL
+	if ($ENV{'PATH_INFO'}) {
+		my $base = $my_uri;
+		my $sname = $ENV{'SCRIPT_NAME'};
+		$base =~ s,\Q$sname\E$,,;
+		$base .= "/";
+		print "<base href=\"$base\"/>\n";
+	}
 # print out each stylesheet that exist
 	if (defined $stylesheet) {
 #provides backwards capability for those people who define style sheet in a config file
-- 
1.5.6.5
Jakub Narebski· Jan 28, 2009, 00:20 UTC · re: Giuseppe Bilotta · lore

Re: [PATCHv2] gitweb: make static files accessible with PATH_INFO

On Mon, 26 Jan 2009, Giuseppe Bilotta wrote:
> It's sick that $cgi->url() has no way to print the script base url
> without path_info information (or that, if it has, it's very well
> hidden).
Actually:
http://localhost/cgi-bin/gitweb/printenv.cgi/path/info?query=a;string=b;c=c;c=a

url(-absolute=>1) = /cgi-bin/gitweb/printenv.cgi url(-relative=>1) = /cgi-bin/gitweb/printenv.cgi url(-full=>1) = http://localhost/cgi-bin/gitweb/printenv.cgi url(-path_info=>1) = http://localhost/cgi-bin/gitweb/printenv.cgi/path/info url(-query=>1) = http://localhost/cgi-bin/gitweb/printenv.cgi?query=a;string=b;c=c;c=a url(-base=>1) = http://localhost

$ENV{'SCRIPT_NAME'} = /cgi-bin/gitweb/printenv.cgi $ENV{'PATH_INFO'} = /path/info

With CGI.pm version 3.10
-- 
Jakub Narebski
Poland
Giuseppe Bilotta· Jan 28, 2009, 00:33 UTC · re: Jakub Narebski · lore

Re: [PATCHv2] gitweb: make static files accessible with PATH_INFO

On Wed, Jan 28, 2009 at 1:20 AM, Jakub Narebski <jnareb@gmail.com> wrote:
Show 19 quoted lines
> On Mon, 26 Jan 2009, Giuseppe Bilotta wrote:
>
>> It's sick that $cgi->url() has no way to print the script base url
>> without path_info information (or that, if it has, it's very well
>> hidden).
>
> Actually:
>
> http://localhost/cgi-bin/gitweb/printenv.cgi/path/info?query=a;string=b;c=c;c=a
>
> url(-absolute=>1)  = /cgi-bin/gitweb/printenv.cgi
> url(-relative=>1)  = /cgi-bin/gitweb/printenv.cgi
> url(-full=>1)      = http://localhost/cgi-bin/gitweb/printenv.cgi
> url(-path_info=>1) = http://localhost/cgi-bin/gitweb/printenv.cgi/path/info
> url(-query=>1)     = http://localhost/cgi-bin/gitweb/printenv.cgi?query=a;string=b;c=c;c=a
> url(-base=>1)      = http://localhost
>
> $ENV{'SCRIPT_NAME'} = /cgi-bin/gitweb/printenv.cgi
> $ENV{'PATH_INFO'}   = /path/info

Yeah, but all of these have the script name in it, I was looking for one without the script name. But more about this in the other reply.

-- 
Giuseppe "Oblomov" Bilotta

← back to recent threads