{"thread":{"id":"17414","subject":"[PATCHv4 2/2] gitweb: webserver config for PATH_INFO","startedAt":"2009-01-28T10:50:31Z","lastAt":"2009-01-31T01:14:47Z","messageCount":3,"participants":["Giuseppe Bilotta","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"102299","messageId":"1233139832-24124-1-git-send-email-giuseppe.bilotta@gmail.com","threadId":"17414","inReplyTo":null,"subject":"[PATCHv4 1/2] gitweb: make static files accessible with PATH_INFO","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-01-28T10:50:31Z","receivedAt":"2009-01-28T10:50:31Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"When gitweb is invoked with PATH_INFO and links to static files such as\nthe CSS and favicon/shortcut icon are relative URLs with relative paths\n(as is the case when using the default Makefile), these files are not\naccessible beyond the project list and summary page (e.g. in shortlog or\ncommit view).\n\nFix this by adding a <base> tag pointing to the script's own URL, that\nensure that all relative paths will be based on this.\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..f7aaf9a 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":"102298","messageId":"1233139832-24124-2-git-send-email-giuseppe.bilotta@gmail.com","threadId":"17414","inReplyTo":"1233139832-24124-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv4 2/2] gitweb: webserver config for PATH_INFO","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-01-28T10:50:32Z","receivedAt":"2009-01-28T10:50:32Z","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---\nSo I decided to document the best way to set up the web server with the\npath_info feature. I particularly like the second trick, although I haven't\nfound a way to make git-daemon accept both git://git.example.com/project and\ngit://git.example.com/project.git when the project dirs don't have the .git\nextensions (e.g. /pub/git/project instead of /pub/git/project.git)\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":"102669","messageId":"200901310214.49247.jnareb@gmail.com","threadId":"17414","inReplyTo":"1233139832-24124-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCHv4 1/2] gitweb: make static files accessible with PATH_INFO","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-01-31T01:14:47Z","receivedAt":"2009-01-31T01:14:47Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 28 Jan 2009, Giuseppe Bilotta wrote:\n\n> When gitweb is invoked with PATH_INFO and links to static files such as\n> the CSS and favicon/shortcut icon are relative URLs with relative paths\n> (as is the case when using the default Makefile), these files are not\n> accessible beyond the project list and summary page (e.g. in shortlog or\n> commit view).\n> \n> Fix this by adding a <base> tag pointing to the script's own URL, that\n> ensure that all relative paths will be based on this.\n\nI think it is a very good idea, good patch (now with esc_url, just in\ncase, even though I think it should be needed), and commit message has\nall info that it should have. But I think that it could be phrased\nbetter: instead of one long sentence, perhaps split it into few\nsentences, each dealing with one issue. Something like below:\n\n-- >8 --\nGitweb links to a few static files: CSS stylesheet, favicon/shortcut\nicon and git logo.  When links to those files are given by relative\nURLs with relative paths (not starting with '/'), and gitweb is invoked\nwith (non empty) PATH_INFO, these files are not accessible beyond\nprojects list and 'summary' view for a project (e.g. in 'shortlog' or\n'commit' view).  Default Makefile rules use base filenames for those\nstatic files.\n\nFix this by adding <base> element pointing to script's own URL,\nwhich ensures that all relative paths relative URLs will be resolved\ncorrectly.\n-- 8< --\n\nGaaahhh... I think this version could be better, but I cannot think\nhow it should look like...\n\n> \n> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n> ---\n>  gitweb/gitweb.perl |    5 +++++\n>  1 files changed, 5 insertions(+), 0 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 931db4f..f7aaf9a 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\nBTW. I think there should be independent patch making those comments\nindented properly...\n\n> +\tif ($ENV{'PATH_INFO'}) {\n> +\t\tprint \"<base href='\".esc_url($my_url).\"' />\\n\";\n\nErrr... here we use ' as attribute delimiter, while everywhere else\nwe use \"; I don't know if esc_url deals correctly with this... it does\nas neither \" nor ' is in \"allowed\" list, but I'd personally use\n\n+\t\tprint '<base href=\"'.esc_url($my_url).'\" />'.\"\\n\";\n\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> -- \n> 1.5.6.5\n> \n> \n\n-- \nJakub Narebski\nPoland\n"}]}