{"thread":{"id":"17471","subject":"[PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO","startedAt":"2009-01-31T01:31:49Z","lastAt":"2009-02-01T21:37:45Z","messageCount":7,"participants":["Giuseppe Bilotta","Jakub Narebski","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"102671","messageId":"1233365512-7130-1-git-send-email-giuseppe.bilotta@gmail.com","threadId":"17471","inReplyTo":null,"subject":"[PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-01-31T01:31:49Z","receivedAt":"2009-01-31T01:31:49Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"This patchset includes\n\n1. the single patch to make static files accessible with PATH_INFO, with\n   the same quoting standard as the nearby code;\n2. an additional patch that extends the README with some examples on how\n   to configure Apache to use gitweb with PATH_INFO enabled by default\n   (and gitweb as directory index);\n3. the repeatedly recommended comment fix to align comments to code in the\n   git_header_html() sub.\n\nGiuseppe Bilotta (3):\n  gitweb: make static files accessible with PATH_INFO\n  gitweb: webserver config for PATH_INFO\n  gitweb: align comments to code\n\n gitweb/README      |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++\n gitweb/gitweb.perl |    9 +++++-\n 2 files changed, 83 insertions(+), 2 deletions(-)\n"},{"id":"102672","messageId":"1233365512-7130-2-git-send-email-giuseppe.bilotta@gmail.com","threadId":"17471","inReplyTo":"1233365512-7130-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv5 1/3] gitweb: make static files accessible with PATH_INFO","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-01-31T01:31:50Z","receivedAt":"2009-01-31T01:31:50Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Gitweb links to a number of static files such as CSS stylesheets,\nfavicon or the git logo. When, such as with the default Makefile, the\npaths to these files are relative (i.e. doesn't start with a \"/\"), the\nfiles become inaccessible in any view other tha project list and summary\npage if gitweb is invoked with a non-empty PATH_INFO.\n\nFix this by adding a <base> element pointing to the script's own URL,\nwhich ensure that all relative paths will be resolved correctly.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n gitweb/gitweb.perl |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 931db4f..538bd5a 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2901,6 +2901,11 @@ sub git_header_html {\n <meta name=\"robots\" content=\"index, nofollow\"/>\n <title>$title</title>\n EOF\n+# the stylesheet, favicon etc urls won't work correctly with path_info unless we\n+# set the appropriate base URL\n+\tif ($ENV{'PATH_INFO'}) {\n+\t\tprint '<base href=\"'.esc_url($my_url).'\" />\\n';\n+\t}\n # print out each stylesheet that exist\n \tif (defined $stylesheet) {\n #provides backwards capability for those people who define style sheet in a config file\n-- \n1.5.6.5\n"},{"id":"102674","messageId":"1233365512-7130-3-git-send-email-giuseppe.bilotta@gmail.com","threadId":"17471","inReplyTo":"1233365512-7130-2-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv5 2/3] gitweb: webserver config for PATH_INFO","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-01-31T01:31:51Z","receivedAt":"2009-01-31T01:31:51Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Document some possible Apache configurations when the path_info feature\nis enabled in gitweb.\n---\n gitweb/README |   76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 76 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/README b/gitweb/README\nindex 825162a..52ad88b 100644\n--- a/gitweb/README\n+++ b/gitweb/README\n@@ -322,6 +322,82 @@ something like the following in your gitweb.conf (or gitweb_config.perl) file:\n   $home_link = \"/\";\n \n \n+PATH_INFO usage\n+-----------------------\n+If you enable PATH_INFO usage in gitweb by putting\n+\n+   $feature{'pathinfo'}{'default'} = [1];\n+\n+in your gitweb.conf, it is possible to set up your server so that it\n+consumes and produces URLs in the form\n+\n+http://git.example.com/project.git/shortlog/sometag\n+\n+by using a configuration such as the following, that assumes that\n+/var/www/gitweb is the DocumentRoot of your webserver, and that it\n+contains the gitweb.cgi script and complementary static files\n+(stylesheet, favicon):\n+\n+<VirtualHost *:80>\n+\tServerAlias git.example.com\n+\n+\tDocumentRoot /var/www/gitweb\n+\n+\t<Directory /var/www/gitweb>\n+\t\tOptions ExecCGI\n+\t\tAddHandler cgi-script cgi\n+\n+\t\tDirectoryIndex gitweb.cgi\n+\n+\t\tRewriteEngine On\n+\t\tRewriteCond %{REQUEST_FILENAME} !-f\n+\t\tRewriteCond %{REQUEST_FILENAME} !-d\n+\t\tRewriteRule ^.* /gitweb.cgi/$0 [L,PT]\n+\t</Directory>\n+</VirtualHost>\n+\n+The rewrite rule guarantees that existing static files will be properly\n+served, whereas any other URL will be passed to gitweb as PATH_INFO\n+parameter.\n+\n+Notice that in this case you don't need special settings for\n+@stylesheets, $my_uri and $home_link, but you lose \"dumb client\" access\n+to your project .git dirs. A possible workaround for the latter is the\n+following: in your project root dir (e.g. /pub/git) have the projects\n+named without a .git extension (e.g. /pub/git/project instead of\n+/pub/git/project.git) and configure Apache as follows:\n+\n+<VirtualHost *:80>\n+\tServerAlias git.example.com\n+\n+\tDocumentRoot /var/www/gitweb\n+\n+\tAliasMatch ^(/.*?)(\\.git)(/.*)? /pub/git$1$3\n+\t<Directory /var/www/gitweb>\n+\t\tOptions ExecCGI\n+\t\tAddHandler cgi-script cgi\n+\n+\t\tDirectoryIndex gitweb.cgi\n+\n+\t\tRewriteEngine On\n+\t\tRewriteCond %{REQUEST_FILENAME} !-f\n+\t\tRewriteCond %{REQUEST_FILENAME} !-d\n+\t\tRewriteRule ^.* /gitweb.cgi/$0 [L,PT]\n+\t</Directory>\n+</VirtualHost>\n+\n+The additional AliasMatch makes it so that\n+\n+http://git.example.com/project.git\n+\n+will give raw access to the project's git dir (so that the project can\n+be cloned), while\n+\n+http://git.example.com/project\n+\n+will provide human-friendly gitweb access.\n+\n+\n Originally written by:\n   Kay Sievers <kay.sievers@vrfy.org>\n \n-- \n1.5.6.5\n"},{"id":"102673","messageId":"1233365512-7130-4-git-send-email-giuseppe.bilotta@gmail.com","threadId":"17471","inReplyTo":"1233365512-7130-3-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv5 3/3] gitweb: align comments to code","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-01-31T01:31:52Z","receivedAt":"2009-01-31T01:31:52Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"---\n gitweb/gitweb.perl |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 538bd5a..c5f0130 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2901,14 +2901,14 @@ sub git_header_html {\n <meta name=\"robots\" content=\"index, nofollow\"/>\n <title>$title</title>\n EOF\n-# the stylesheet, favicon etc urls won't work correctly with path_info unless we\n-# set the appropriate base URL\n+\t# the stylesheet, favicon etc urls won't work correctly with path_info\n+\t# unless we set the appropriate base URL\n \tif ($ENV{'PATH_INFO'}) {\n \t\tprint '<base href=\"'.esc_url($my_url).'\" />\\n';\n \t}\n-# print out each stylesheet that exist\n+\t# print out each stylesheet that exist, providing backwards capability\n+\t# for those people who defined $stylesheet in a config file\n \tif (defined $stylesheet) {\n-#provides backwards capability for those people who define style sheet in a config file\n \t\tprint '<link rel=\"stylesheet\" type=\"text/css\" href=\"'.$stylesheet.'\"/>'.\"\\n\";\n \t} else {\n \t\tforeach my $stylesheet (@stylesheets) {\n-- \n1.5.6.5\n"},{"id":"102676","messageId":"200901310304.51205.jnareb@gmail.com","threadId":"17471","inReplyTo":"1233365512-7130-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-01-31T02:04:50Z","receivedAt":"2009-01-31T02:04:50Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Giuseppe Bilotta wrote:\n\n> This patchset includes\n> \n> 1. the single patch to make static files accessible with PATH_INFO, with\n>    the same quoting standard as the nearby code;\n> 2. an additional patch that extends the README with some examples on how\n>    to configure Apache to use gitweb with PATH_INFO enabled by default\n>    (and gitweb as directory index);\n> 3. the repeatedly recommended comment fix to align comments to code in the\n>    git_header_html() sub.\n\nI like it. Ack for the whole series.\n \n> Giuseppe Bilotta (3):\n>   gitweb: make static files accessible with PATH_INFO\n>   gitweb: webserver config for PATH_INFO\n>   gitweb: align comments to code\n> \n>  gitweb/README      |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++\n>  gitweb/gitweb.perl |    9 +++++-\n>  2 files changed, 83 insertions(+), 2 deletions(-)\n> \n> \n\n-- \nJakub Narebski\nPoland\n"},{"id":"102737","messageId":"7vd4e30wno.fsf@gitster.siamese.dyndns.org","threadId":"17471","inReplyTo":"200901310304.51205.jnareb@gmail.com","subject":"Re: [PATCHv5 0/3] gitweb: make static files accessible with PATH_INFO","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-01T01:32:27Z","receivedAt":"2009-02-01T01:32:27Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Giuseppe Bilotta wrote:\n>\n>> This patchset includes\n>> \n>> 1. the single patch to make static files accessible with PATH_INFO, with\n>>    the same quoting standard as the nearby code;\n>> 2. an additional patch that extends the README with some examples on how\n>>    to configure Apache to use gitweb with PATH_INFO enabled by default\n>>    (and gitweb as directory index);\n>> 3. the repeatedly recommended comment fix to align comments to code in the\n>>    git_header_html() sub.\n>\n> I like it. Ack for the whole series.\n\nThanks, both.  Applied.\n"},{"id":"102783","messageId":"200902012237.46837.jnareb@gmail.com","threadId":"17471","inReplyTo":"1233365512-7130-4-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCH 4/3] gitweb: Update README that gitweb works better with PATH_INFO","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-02-01T21:37:45Z","receivedAt":"2009-02-01T21:37:45Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"One had to configure gitweb for it to find static files (stylesheets,\nimages) when using path_info URLs.  Now that it is not necessary\nthanks to adding BASE element to HTML head if needed, update README to\nreflect this fact.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis is update of gitweb/README to fit state after Giuseppe patches.\n\nThere is a little problem either with terminology, or with CGI.pm\nmodule itself. RFC 1808 \"Relative Uniform Resource Locators\" says\nthat:\n  http://git.example.com/cgi-bin/gitweb.cgi  is absolute URL\n  /cgi-bin/gitweb.cgi                        is relative URL\n                                            but absolute path\n  gitweb.cgi                                 is relative URL\n                                            and relative path\n\nwhile CGI.pm (or, to be more exact, its url() method) says:\n\n  url() or url(-full)  returns http://git.example.com/cgi-bin/gitweb.cgi\n  url(-absolute)       returns /cgi-bin/gitweb.cgi\n  url(-relative)       returns gitweb.cgi (or /cgi-bin/gitweb.cgi)\n\nThat is why I used \"Full URL\"  for $my_url = $cgi->url();\nand \"absolute URL\" (as before) for $my_uri = $cgi->url(-absolute);\nin gitweb/README.\n\n gitweb/README |   10 ++++------\n 1 files changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/gitweb/README b/gitweb/README\nindex 52ad88b..a9dc2e5 100644\n--- a/gitweb/README\n+++ b/gitweb/README\n@@ -162,14 +162,12 @@ not include variables usually directly set during build):\n    $GITWEB_LIST during installation.  If empty, $projectroot is used\n    to scan for repositories.\n  * $my_url, $my_uri\n-   URL and absolute URL of gitweb script; you might need to set those\n-   variables if you are using 'pathinfo' feature: see also below.\n+   Full URL and absolute URL of gitweb script;\n+   in earlier versions of gitweb you might have need to set those\n+   variables, now there should be no need to do it.\n  * $home_link\n    Target of the home link on top of all pages (the first part of view\n-   \"breadcrumbs\").  By default set to absolute URI of a page; you might\n-   need to set it up to [base] gitweb URI if you use 'pathinfo' feature\n-   (alternative format of the URLs, with project name embedded directly\n-   in the path part of URL).\n+   \"breadcrumbs\").  By default set to absolute URI of a page ($my_uri).\n  * @stylesheets\n    List of URIs of stylesheets (relative to base URI of a page). You\n    might specify more than one stylesheet, for example use gitweb.css\n-- \n1.6.1\n"}]}