Subject: Re: Static gitweb content when using pathinfo

From: Jakub Narebski <[email-masked]>
Date: Sat, 14 Apr 2012 19:19:18 +0200

On Thu, 5 Apr 2012, Jakub Narebski wrote:
> On Thu, 5 Apr 2012, José María Escartín Esteban wrote:
> > Hi,
> > 
> > I'm running gitweb in a server.example.com/gitweb/ scenario.  If I don't enable
> > pathinfo everything works fine, but when I enable pathinfo the static content
> > stops showing up in the browser.
> > 
> > I'm not an HTML or perl expert, but I think that this may be due to a missing
> > slash in the construction of the base tag:  Using the upstream script I am getting
> > 
> > <base href="http://server.example.com/gitweb" />
> > 
> > and no static content.  Once I tune the script to add a final slash to the url
> > 
> > <base href="http://server.example.com/gitweb/" />
> > 
> > the static content shows up again.
>
> How do you deploy gitweb, what is your web server configuration, and
> what is the URL of main gitweb page (using placeholders like 'example.com'
> or 'foo')?

Ping?

[...]

> There might be problem if you configured your web server to serve gitweb
> using it as a handler for subdirectory, so the script name does not need
> to appear in URL, e.g.
> 
>   http://localhost/cgi-bin/gitweb
> 
> which would require the following base element
> 
>   <base href="http://localhost/cgi-bin/gitweb/" />

[...]

> > Once I tune the script to add a final slash to the url
> > 
> > <base href="http://server.example.com/gitweb/" />
> > 
> > the static content shows up again.
> 
> By "tune the script" do you mean editing gitweb.cgi, or adding setting
> $base_url to gitweb configuration file, see gitweb.conf(5):
> 
>   $base_url
>      Base  URL  for  relative  URLs  in  pages generated by gitweb, (e.g.
>      $logo, $favicon, @stylesheets if they are relative URLs), needed and
>      used  <base href="$base_url"> only for URLs with nonempty PATH_INFO.
>      Usually gitweb sets its value correctly, and there is no need to set
>      this  variable,  e.g.  to $my_uri or "/". See $per_request_config if
>      you need to override it anyway.
> 
> You can e.g. put
> 
>   $base_url .= '/' unless ($base_url =~ m!/$!);
> 
> in the gitweb configuration file to ensure that it ends with '/', whatever
> it is.

By the way, would the following proposed addition to gitweb.conf(5)
manpage would help your situation?

-------- >8 ---------- >8 ---------
Subject: [PATCH/RFC] gitweb.conf(5): When to set $base_url

Add a paragraph to description of $base_url variable in gitweb.conf(5)
manpage explaining when and why one might need to set it.

Based-on-report-by: José María Escartín Esteban <[email-masked]>
Signed-off-by: Jakub Narebski <[email-masked]>
---
 Documentation/gitweb.conf.txt |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt
index 7aba497..a2a6ddf 100644
--- a/Documentation/gitweb.conf.txt
+++ b/Documentation/gitweb.conf.txt
@@ -559,6 +559,20 @@ $base_url::
 	PATH_INFO.  Usually gitweb sets its value correctly,
 	and there is no need to set this variable, e.g. to $my_uri or "/".
 	See `$per_request_config` if you need to override it anyway.
++
+You would need to set this variable when using gitweb as a directory
+handler and using path_info-based URLs.  For example if your web
+server is set up in such way that full path to browse repositories is
+`http://git.example.com/gitweb` and static files are served from
+'/gitweb/static' directory with default values (e.g. `$logo` is
+`static/git-logo.png`), then you would need to set `$base_url` to
+(for example):
++
+----------------------------------------------------------------------
+our $base_url = "http://git.example.com/gitweb/";
+----------------------------------------------------------------------
++
+The trailing slash is required!

 CONFIGURING GITWEB FEATURES
-- 
1.7.9