Re: Static gitweb content when using pathinfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
> 
> Maybe I'm doing something wrong (am I?), and possibly this can be solved from
> the web server side, but maybe it also makes some sense to include in the script
> some check that the url used in the base tag ends with a slash.  In that case,
> given my lack of perl skills, I would be really grateful if somebody implemented it.

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')?

When I am running gitweb, it uses http://localhost/cgi-bin/gitweb/gitweb.cgi
URL, and BASE element for path_info is

  <base href="http://localhost/cgi-bin/gitweb/gitweb.cgi"; />

Note that last component of 'href' attribute of base element is the
basename of script, which according to HTML 4.01[1] and RFC 3986[2]
is removed[3]

   o  return a string consisting of the reference's path component
      appended to all but the last segment of the base URI's path (i.e.,
      excluding any characters after the right-most "/" in the base URI
      path, or excluding the entire base URI path if it does not contain
      any "/" characters).


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/"; />

Gitweb would have to distinguish those two cases somehow, and either add
or not add trailing slash '/'.

[1]: http://www.w3.org/TR/html401/struct/links.html#h-12.4
[2]: http://tools.ietf.org/html/rfc3986#section-5.2
[3]: http://tools.ietf.org/html/rfc3986#section-5.2.3

> 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.

HTH
-- 
Jakub Narebski
Poland
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]