git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO
@ 2009-01-31  1:31 Giuseppe Bilotta
  2009-01-31  1:31 ` [PATCHv5 1/3] " Giuseppe Bilotta
  2009-01-31  2:04 ` [PATCHv5 0/3] gitweb: make static files accessible " Jakub Narebski
  0 siblings, 2 replies; 7+ messages in thread
From: Giuseppe Bilotta @ 2009-01-31  1:31 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Junio C Hamano, Giuseppe Bilotta

This patchset includes

1. the single patch to make static files accessible with PATH_INFO, with
   the same quoting standard as the nearby code;
2. an additional patch that extends the README with some examples on how
   to configure Apache to use gitweb with PATH_INFO enabled by default
   (and gitweb as directory index);
3. the repeatedly recommended comment fix to align comments to code in the
   git_header_html() sub.

Giuseppe Bilotta (3):
  gitweb: make static files accessible with PATH_INFO
  gitweb: webserver config for PATH_INFO
  gitweb: align comments to code

 gitweb/README      |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gitweb/gitweb.perl |    9 +++++-
 2 files changed, 83 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCHv5 1/3] gitweb: make static files accessible with PATH_INFO
  2009-01-31  1:31 [PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO Giuseppe Bilotta
@ 2009-01-31  1:31 ` Giuseppe Bilotta
  2009-01-31  1:31   ` [PATCHv5 2/3] gitweb: webserver config for PATH_INFO Giuseppe Bilotta
  2009-01-31  2:04 ` [PATCHv5 0/3] gitweb: make static files accessible " Jakub Narebski
  1 sibling, 1 reply; 7+ messages in thread
From: Giuseppe Bilotta @ 2009-01-31  1:31 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Junio C Hamano, Giuseppe Bilotta

Gitweb links to a number of static files such as CSS stylesheets,
favicon or the git logo. When, such as with the default Makefile, the
paths to these files are relative (i.e. doesn't start with a "/"), the
files become inaccessible in any view other tha project list and summary
page if gitweb is invoked with a non-empty PATH_INFO.

Fix this by adding a <base> element pointing to the script's own URL,
which ensure that all relative paths will be resolved correctly.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 931db4f..538bd5a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2901,6 +2901,11 @@ 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'}) {
+		print '<base href="'.esc_url($my_url).'" />\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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCHv5 2/3] gitweb: webserver config for PATH_INFO
  2009-01-31  1:31 ` [PATCHv5 1/3] " Giuseppe Bilotta
@ 2009-01-31  1:31   ` Giuseppe Bilotta
  2009-01-31  1:31     ` [PATCHv5 3/3] gitweb: align comments to code Giuseppe Bilotta
  0 siblings, 1 reply; 7+ messages in thread
From: Giuseppe Bilotta @ 2009-01-31  1:31 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Junio C Hamano, Giuseppe Bilotta

Document some possible Apache configurations when the path_info feature
is enabled in gitweb.
---
 gitweb/README |   76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/gitweb/README b/gitweb/README
index 825162a..52ad88b 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -322,6 +322,82 @@ something like the following in your gitweb.conf (or gitweb_config.perl) file:
   $home_link = "/";
 
 
+PATH_INFO usage
+-----------------------
+If you enable PATH_INFO usage in gitweb by putting
+
+   $feature{'pathinfo'}{'default'} = [1];
+
+in your gitweb.conf, it is possible to set up your server so that it
+consumes and produces URLs in the form
+
+http://git.example.com/project.git/shortlog/sometag
+
+by using a configuration such as the following, that assumes that
+/var/www/gitweb is the DocumentRoot of your webserver, and that it
+contains the gitweb.cgi script and complementary static files
+(stylesheet, favicon):
+
+<VirtualHost *:80>
+	ServerAlias git.example.com
+
+	DocumentRoot /var/www/gitweb
+
+	<Directory /var/www/gitweb>
+		Options ExecCGI
+		AddHandler cgi-script cgi
+
+		DirectoryIndex gitweb.cgi
+
+		RewriteEngine On
+		RewriteCond %{REQUEST_FILENAME} !-f
+		RewriteCond %{REQUEST_FILENAME} !-d
+		RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
+	</Directory>
+</VirtualHost>
+
+The rewrite rule guarantees that existing static files will be properly
+served, whereas any other URL will be passed to gitweb as PATH_INFO
+parameter.
+
+Notice that in this case you don't need special settings for
+@stylesheets, $my_uri and $home_link, but you lose "dumb client" access
+to your project .git dirs. A possible workaround for the latter is the
+following: in your project root dir (e.g. /pub/git) have the projects
+named without a .git extension (e.g. /pub/git/project instead of
+/pub/git/project.git) and configure Apache as follows:
+
+<VirtualHost *:80>
+	ServerAlias git.example.com
+
+	DocumentRoot /var/www/gitweb
+
+	AliasMatch ^(/.*?)(\.git)(/.*)? /pub/git$1$3
+	<Directory /var/www/gitweb>
+		Options ExecCGI
+		AddHandler cgi-script cgi
+
+		DirectoryIndex gitweb.cgi
+
+		RewriteEngine On
+		RewriteCond %{REQUEST_FILENAME} !-f
+		RewriteCond %{REQUEST_FILENAME} !-d
+		RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
+	</Directory>
+</VirtualHost>
+
+The additional AliasMatch makes it so that
+
+http://git.example.com/project.git
+
+will give raw access to the project's git dir (so that the project can
+be cloned), while
+
+http://git.example.com/project
+
+will provide human-friendly gitweb access.
+
+
 Originally written by:
   Kay Sievers <kay.sievers@vrfy.org>
 
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCHv5 3/3] gitweb: align comments to code
  2009-01-31  1:31   ` [PATCHv5 2/3] gitweb: webserver config for PATH_INFO Giuseppe Bilotta
@ 2009-01-31  1:31     ` Giuseppe Bilotta
  2009-02-01 21:37       ` [PATCH 4/3] gitweb: Update README that gitweb works better with PATH_INFO Jakub Narebski
  0 siblings, 1 reply; 7+ messages in thread
From: Giuseppe Bilotta @ 2009-01-31  1:31 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Junio C Hamano, Giuseppe Bilotta

---
 gitweb/gitweb.perl |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 538bd5a..c5f0130 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2901,14 +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
+	# the stylesheet, favicon etc urls won't work correctly with path_info
+	# unless we set the appropriate base URL
 	if ($ENV{'PATH_INFO'}) {
 		print '<base href="'.esc_url($my_url).'" />\n';
 	}
-# print out each stylesheet that exist
+	# print out each stylesheet that exist, providing backwards capability
+	# for those people who defined $stylesheet in a config file
 	if (defined $stylesheet) {
-#provides backwards capability for those people who define style sheet in a config file
 		print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
 	} else {
 		foreach my $stylesheet (@stylesheets) {
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO
  2009-01-31  1:31 [PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO Giuseppe Bilotta
  2009-01-31  1:31 ` [PATCHv5 1/3] " Giuseppe Bilotta
@ 2009-01-31  2:04 ` Jakub Narebski
  2009-02-01  1:32   ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Jakub Narebski @ 2009-01-31  2:04 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Junio C Hamano

Giuseppe Bilotta wrote:

> This patchset includes
> 
> 1. the single patch to make static files accessible with PATH_INFO, with
>    the same quoting standard as the nearby code;
> 2. an additional patch that extends the README with some examples on how
>    to configure Apache to use gitweb with PATH_INFO enabled by default
>    (and gitweb as directory index);
> 3. the repeatedly recommended comment fix to align comments to code in the
>    git_header_html() sub.

I like it. Ack for the whole series.
 
> Giuseppe Bilotta (3):
>   gitweb: make static files accessible with PATH_INFO
>   gitweb: webserver config for PATH_INFO
>   gitweb: align comments to code
> 
>  gitweb/README      |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  gitweb/gitweb.perl |    9 +++++-
>  2 files changed, 83 insertions(+), 2 deletions(-)
> 
> 

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO
  2009-01-31  2:04 ` [PATCHv5 0/3] gitweb: make static files accessible " Jakub Narebski
@ 2009-02-01  1:32   ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2009-02-01  1:32 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: Giuseppe Bilotta, git

Jakub Narebski <jnareb@gmail.com> writes:

> Giuseppe Bilotta wrote:
>
>> This patchset includes
>> 
>> 1. the single patch to make static files accessible with PATH_INFO, with
>>    the same quoting standard as the nearby code;
>> 2. an additional patch that extends the README with some examples on how
>>    to configure Apache to use gitweb with PATH_INFO enabled by default
>>    (and gitweb as directory index);
>> 3. the repeatedly recommended comment fix to align comments to code in the
>>    git_header_html() sub.
>
> I like it. Ack for the whole series.

Thanks, both.  Applied.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/3] gitweb: Update README that gitweb works better with PATH_INFO
  2009-01-31  1:31     ` [PATCHv5 3/3] gitweb: align comments to code Giuseppe Bilotta
@ 2009-02-01 21:37       ` Jakub Narebski
  0 siblings, 0 replies; 7+ messages in thread
From: Jakub Narebski @ 2009-02-01 21:37 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git, Junio C Hamano, bug-CGI.pm

One had to configure gitweb for it to find static files (stylesheets,
images) when using path_info URLs.  Now that it is not necessary
thanks to adding BASE element to HTML head if needed, update README to
reflect this fact.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is update of gitweb/README to fit state after Giuseppe patches.

There is a little problem either with terminology, or with CGI.pm
module itself. RFC 1808 "Relative Uniform Resource Locators" says
that:
  http://git.example.com/cgi-bin/gitweb.cgi  is absolute URL
  /cgi-bin/gitweb.cgi                        is relative URL
                                            but absolute path
  gitweb.cgi                                 is relative URL
                                            and relative path

while CGI.pm (or, to be more exact, its url() method) says:

  url() or url(-full)  returns http://git.example.com/cgi-bin/gitweb.cgi
  url(-absolute)       returns /cgi-bin/gitweb.cgi
  url(-relative)       returns gitweb.cgi (or /cgi-bin/gitweb.cgi)

That is why I used "Full URL"  for $my_url = $cgi->url();
and "absolute URL" (as before) for $my_uri = $cgi->url(-absolute);
in gitweb/README.

 gitweb/README |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/gitweb/README b/gitweb/README
index 52ad88b..a9dc2e5 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -162,14 +162,12 @@ not include variables usually directly set during build):
    $GITWEB_LIST during installation.  If empty, $projectroot is used
    to scan for repositories.
  * $my_url, $my_uri
-   URL and absolute URL of gitweb script; you might need to set those
-   variables if you are using 'pathinfo' feature: see also below.
+   Full URL and absolute URL of gitweb script;
+   in earlier versions of gitweb you might have need to set those
+   variables, now there should be no need to do it.
  * $home_link
    Target of the home link on top of all pages (the first part of view
-   "breadcrumbs").  By default set to absolute URI of a page; you might
-   need to set it up to [base] gitweb URI if you use 'pathinfo' feature
-   (alternative format of the URLs, with project name embedded directly
-   in the path part of URL).
+   "breadcrumbs").  By default set to absolute URI of a page ($my_uri).
  * @stylesheets
    List of URIs of stylesheets (relative to base URI of a page). You
    might specify more than one stylesheet, for example use gitweb.css
-- 
1.6.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-01 21:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-31  1:31 [PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO Giuseppe Bilotta
2009-01-31  1:31 ` [PATCHv5 1/3] " Giuseppe Bilotta
2009-01-31  1:31   ` [PATCHv5 2/3] gitweb: webserver config for PATH_INFO Giuseppe Bilotta
2009-01-31  1:31     ` [PATCHv5 3/3] gitweb: align comments to code Giuseppe Bilotta
2009-02-01 21:37       ` [PATCH 4/3] gitweb: Update README that gitweb works better with PATH_INFO Jakub Narebski
2009-01-31  2:04 ` [PATCHv5 0/3] gitweb: make static files accessible " Jakub Narebski
2009-02-01  1:32   ` Junio C Hamano

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