git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "José María Escartín Esteban" <ripero84@gmail.com>
To: Jakub Narebski <jnareb@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Static gitweb content when using pathinfo
Date: Tue, 24 Apr 2012 09:01:46 +0200	[thread overview]
Message-ID: <4F964FDA.6030807@gmail.com> (raw)
In-Reply-To: <201204171430.52650.jnareb@gmail.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello again,

On 17/04/12 14:30, Jakub Narebski wrote:
> 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.
> 

Right.

> [...]
>> 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 think now it's more clear and explicit, and more useful for users not
familiar with Perl, so better.  Thank you!

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

Aren't both configurations equivalent? (just moving a slash to one side or the
other of the definitions)

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

That option is enabled by default in all the Debian shipped /etc/gitweb.conf.
 It was like this the first time I installed the package from the Debian
repos, and it is still like this in the last version of the package in the
repos, gitweb_1.7.10-1_all.deb.  I didn't know it was any sort of modified
gitweb, the script is in git_1.7.10-1_all.deb (yes, they make a separate
package for gitweb but the script is in the git one), and the only differences
to the v1.7.10 upstream source seem to be installation variables/flags.

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

I will check that, thanks again.

Greetings,

	E.

>> 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@gmail.com> 
> Signed-off-by: Jakub Narębski <jnareb@gmail.com> --- 
> 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)).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAk+WT9YACgkQY+7weQMem3xchQCcCxsIOs7GOcluIb++KKweK76Y
TRcAnjauwtudLCc2qTwJd5D8FxwI34mC
=MbaI
-----END PGP SIGNATURE-----

      reply	other threads:[~2012-04-24  7:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-05 13:54 Static gitweb content when using pathinfo José María Escartín Esteban
2012-04-05 21:14 ` Jakub Narebski
2012-04-14 17:19   ` Jakub Narebski
2012-04-16 15:18     ` José María Escartín Esteban
2012-04-17 12:30       ` Jakub Narebski
2012-04-24  7:01         ` José María Escartín Esteban [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F964FDA.6030807@gmail.com \
    --to=ripero84@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).