Re: Static gitweb content when using pathinfo

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

 



On Mon, 16 Apr 2012, José María Escartín Esteban wrote:
> On 14/04/12 19:19, Jakub Narebski wrote:
>> On Thu, 5 Apr 2012, Jakub Narebski wrote:
>>> On Thu, 5 Apr 2012, José María Escartín Esteban wrote:

>>> 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/"; />
>>
>> [...]
>>
> 
> Yes, that was precisely the problem.

Note that you won't have problem with `http://localhost` as base url
(without any directory), or in more realistic case using virtual host
rather than virtual directory.  The problem is that without '/' the
path part of $base_url is stripped of last element.

Just for completeness.

[...]
> This addition to the man page would of course have been useful, since it took me
> a while to detect that the problem was a missing slash in the base url.
> However, it would not have solved completely my problem, and for me the best has
> been to add the line of code you proposed in the previous email.

So how about the proposed updated addition at the end of this email?

> I am running a Debian testing (wheezy) server, so the distro gitweb files are:
> 
> 	/etc/apache2/conf.d/gitweb
> 	/etc/gitweb.conf
> 	/usr/share/gitweb/gitweb.cgi
> 	/usr/share/gitweb/index.cgi -> /usr/share/gitweb/gitweb.cgi
> 	/usr/share/gitweb/static/*
> 
> I am using two sets of git repositories, and each of the sets works through a
> particular gitolite user:
> 
> 	user     home
> 	----------------------
> 	git      /srv/project
> 	mygit    /srv/mygit
> 
> I wanted that different groups of people were able to browse the 'project' repos
> (in fact it is a mirror from the main project server) from
> 	http://server.example.com/project/ ,
> and the 'mygit' repos from
> 	http://server.example.com/mygit/ .
> And I wanted to keep urls as short and easy as possible, and to avoid
> proliferation of configs as much as possible.

I think that is this "two sets" that created configuration with a problem.
 
> The setup I came up with was to link
> 
> 	/srv/www/project -> /usr/share/gitweb
> 	/srv/www/mygit -> /usr/share/gitweb
> 
> and to use the following configuration files:
> 
> ######### /etc/apache2/conf.d/gitweb ##################
> <Directory /srv/www/project>
>         SetEnv  GITWEB_PROJECTROOT      /srv/git/
>         SetEnv  GITWEB_CONFIG           /etc/gitweb.conf
[...]
> #######################################################
> 
> ######### /etc/gitweb.conf ############################
> $projectroot = $ENV{'GITWEB_PROJECTROOT'}."repositories";
> $git_temp = "/tmp";
> $projects_list = $ENV{'GITWEB_PROJECTROOT'}."projects.list";
> @diff_opts = ();
> $feature{'pathinfo'}{'default'} = [1];
> $feature{'highlight'}{'default'} = [1];
> $projects_list_description_width = 50;
> #######################################################

A question: why not have

          SetEnv  GITWEB_PROJECTROOT      /srv/git

and use

  $projectroot = "$ENV{'GITWEB_PROJECTROOT'}/repositories";
  $projects_list = "$ENV{'GITWEB_PROJECTROOT'}/projects.list";
 

BTW. what is this $git_temp?  Is it modified gitweb, because core one
doesn't need to use temporary directory for anything nowadays?

A tip: you can use GITWEB_CONFIG_COMMON for the common part of
configuration and separate GITWEB_CONFIG for per-instance configuration.
Though I am not sure if it would help in your case.  It requires
modern gitweb. though.

> Probably there are better ways to implement this, but at least this seems to
> work, once I have added
> 
> 	$base_url .= '/' unless ($base_url =~ m!/$!);
> 
> to /etc/gitweb.conf .

-- >8 ---------- >8 --
Subject: [PATCH] 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, and how.

Based-on-report-by: José María Escartín Esteban <ripero84@xxxxxxxxx>
Signed-off-by: Jakub Narębski <jnareb@xxxxxxxxx>
---
 Documentation/gitweb.conf.txt |   24 ++++++++++++++++++++++++
 Documentation/gitweb.txt      |    4 ++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt
index 7aba497..4716a0f 100644
--- a/Documentation/gitweb.conf.txt
+++ b/Documentation/gitweb.conf.txt
@@ -559,6 +559,30 @@ $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 path_info-based URLs
+while using gitweb as a directory handler (which means that full path
+to browse repositories looks like `http://git.example.com/gitweb`
+rather than looking like `http://git.example.com/gitweb/gitweb.cgi`).
+You can find yourself in this situation (gitweb as directory handler)
+when configuring gitweb to use FastCGI interface as shown in
+"Webserver configuration" section on linkgit:gitweb[1] manpage.
++
+If static files are served from 'static' subdirectory of directory
+the gitweb script is handler for, with default URLs of static files
+(e.g. `$logo` is `static/git-logo.png`), then you would need to ensure
+that `$base_url` ends with slash to denote that it is directory, to
+work correctly:
++
+----------------------------------------------------------------------
+$base_url .= '/' unless ($base_url =~ m!/$!);
+----------------------------------------------------------------------
++
+For example if gitweb URL is `http://git.example.com/gitweb`, and
+static files are available in `http://git.example.com/gitweb/static/`
+then `$base_url` must end up to be `http://git.example.com/gitweb/`
+(with trailing slash) for e.g. `static/git-logo.png` relative link
+to refer to `http://git.example.com/gitweb/static/git-logo.png`.
 
 
 CONFIGURING GITWEB FEATURES
diff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt
index b394ecc..c3db66a 100644
--- a/Documentation/gitweb.txt
+++ b/Documentation/gitweb.txt
@@ -473,6 +473,10 @@ With that configuration the full path to browse repositories would be:
 
   http://server/gitweb
 
+Note that for this configuration `$base_url` must be set as described
+in linkgit:gitweb.conf[5] for gitweb to correctly serve static files
+with path_info links.
+
 As PSGI using plackup
 ~~~~~~~~~~~~~~~~~~~~~
 Gitweb can run as PSGI app (via emulation with *CGI::Emulate::PSGI*(3pm)).
-- 
1.7.9

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