{"thread":{"id":"28702","subject":"Re: [PATCH] gitweb: provide a way to customize html headers","startedAt":"2011-10-17T07:28:55Z","lastAt":"2011-10-21T19:14:33Z","messageCount":6,"participants":["Lénaïc Huard","Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"177838","messageId":"201110170928.56075.lenaic@lhuard.fr.eu.org","threadId":"28702","inReplyTo":null,"subject":"Re: [PATCH] gitweb: provide a way to customize html headers","fromName":"Lénaïc Huard","fromEmail":"lenaic@lhuard.fr.eu.org","sentAt":"2011-10-17T07:28:55Z","receivedAt":"2011-10-17T07:28:55Z","isPatch":true,"sender":{"key":"lenaic@lhuard.fr.eu.org","avatar":null},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Lénaïc Huard <lenaic@lhuard.fr.eu.org> writes:\n\n> > This allows web sites to add some specific html headers to the pages\n> > generated by gitweb.\n\n> What do you need this for?\n\nI want to decorate the gitweb pages with the “Google Analytics” tracking code.\nIn order to do so, today, Google is recommending to add a <script> tag just \nbefore the closing </head> tag.\n\nhttps://www.google.com/support/analyticshelp/bin/answer.py?answer=1008080&hl=en\n\n> > The new variable $site_htmlheader can be set to a filename the content\n> > of which will be inserted at the end of the <head> section of each\n> > page generated by gitweb.\n\n> Hmmm... I wonder if a file with html header fragment (which is quite\n> specific subset of HTML) is a best solution.\n\nThat’s true. The piece of code to be inserted in <head> is maybe small enough \nso that we don’t need a file. Maybe $site_htmlheader could contain directly \nthe html snippet to be inserted in the pages?\n\n> > Signed-off-by: L=FE=FF=00=E9na=FE=FF=00=EFc Huard <lenaic@lhuard.fr.eu.or=\ng>\n> > ---\n> >  gitweb/INSTALL     |    3 +++\n\n> Nb. there is patch in flight adding gitweb.conf(5) and gitweb(1)\n> manpages...\n\nOk. So, I’ll update them once a decision will be taken concerning this \n$site_htmlheader.\n-- \nLénaïc Huard\n"},{"id":"177858","messageId":"201110171357.00278.jnareb@gmail.com","threadId":"28702","inReplyTo":"201110170928.56075.lenaic@lhuard.fr.eu.org","subject":"Re: [PATCH] gitweb: provide a way to customize html headers","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-10-17T11:56:59Z","receivedAt":"2011-10-17T11:56:59Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 17 Oct 2011, Lénaïc Huard wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > Lénaïc Huard <lenaic@lhuard.fr.eu.org> writes:\n> \n> > > This allows web sites to add some specific html headers to the pages\n> > > generated by gitweb.\n> \n> > What do you need this for?\n> \n> I want to decorate the gitweb pages with the “Google Analytics” tracking code.\n> In order to do so, today, Google is recommending to add a <script> tag just \n> before the closing </head> tag.\n> \n> https://www.google.com/support/analyticshelp/bin/answer.py?answer=1008080&hl=en\n\nHmmm... the modern recommendation from both Google and Yahoo is to put\nscript tags at the end of HTML, just before closing </body>, which you\ncan do nowadays with $site_footer / GITWEB_SITE_FOOTER.\n\nBut I guess that analytics script needs to be loaded earlier.\n\n> > > The new variable $site_htmlheader can be set to a filename the content\n> > > of which will be inserted at the end of the <head> section of each\n> > > page generated by gitweb.\n> \n> > Hmmm... I wonder if a file with html header fragment (which is quite\n> > specific subset of HTML) is a best solution.\n> \n> That’s true. The piece of code to be inserted in <head> is maybe small enough \n> so that we don’t need a file. Maybe $site_htmlheader could contain directly \n> the html snippet to be inserted in the pages?\n\nI think it might be a better solution.\n \n\n> > > ---\n> > >  gitweb/INSTALL     |    3 +++\n> \n> > Nb. there is patch in flight adding gitweb.conf(5) and gitweb(1)\n> > manpages...\n> \n> Ok. So, I’ll update them once a decision will be taken concerning this \n> $site_htmlheader.\n\nYou might have to wait a bit till patches containing gitweb.conf(5)\nmanpage are merged in, and rebase your patch to add information about\nnew config variable not to gitweb/INSTALL, but to Documentation/gitweb.conf.txt\n\n-- \nJakub Narebski\nPoland\n"},{"id":"178107","messageId":"201110210046.34679.lenaic@lhuard.fr.eu.org","threadId":"28702","inReplyTo":"201110171357.00278.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: provide a way to customize html headers","fromName":"Lénaïc Huard","fromEmail":"lenaic@lhuard.fr.eu.org","sentAt":"2011-10-20T22:46:34Z","receivedAt":"2011-10-20T22:46:34Z","isPatch":true,"sender":{"key":"lenaic@lhuard.fr.eu.org","avatar":null},"body":"This allows web sites to add some specific html headers to the pages\ngenerated by gitweb.\n\nThe new variable $site_htmlheader can be set to an html snippet that\nwill be inserted at the end of the <head> section of each\npage generated by gitweb.\n\nSigned-off-by: Lénaïc Huard <lenaic@lhuard.fr.eu.org>\n---\nLe lundi 17 octobre 2011, Jakub Narebski a écrit :\n> On Mon, 17 Oct 2011, Lénaïc Huard wrote:\n> > Jakub Narebski <jnareb@gmail.com> writes:\n> > > Lénaïc Huard <lenaic@lhuard.fr.eu.org> writes:\n> > > > This allows web sites to add some specific html headers to the pages\n> > > > generated by gitweb.\n> > > \n> > > What do you need this for?\n> > \n> > I want to decorate the gitweb pages with the “Google Analytics” tracking\n> > code. In order to do so, today, Google is recommending to add a <script>\n> > tag just before the closing </head> tag.\n> > \n> > https://www.google.com/support/analyticshelp/bin/answer.py?answer=1008080\n> > &hl=en\n> \n> Hmmm... the modern recommendation from both Google and Yahoo is to put\n> script tags at the end of HTML, just before closing </body>, which you\n> can do nowadays with $site_footer / GITWEB_SITE_FOOTER.\n> \n> But I guess that analytics script needs to be loaded earlier.\n\nIn fact, I used to insert the Google Analytics tracking code before </body>,\nbut I recently noticed that Google is now recommending to put the html\nsnippet at the end of the <head> section.\n\nHere is the recommendation from Google:\nhttps://code.google.com/apis/analytics/docs/tracking/asyncTracking.html\n\nFrom what I understood, the goal of putting the script tags just before\n</body> was to avoid to increase the page load time in case of latency of\nthe remote server serving the js script.\nThe GA tracking code is now loading the js asynchronously. So, it doesn’t\nblock the page load anymore. So, the load can be started asap.\n\n> > > > The new variable $site_htmlheader can be set to a filename the\n> > > > content of which will be inserted at the end of the <head> section\n> > > > of each page generated by gitweb.\n> > > \n> > > Hmmm... I wonder if a file with html header fragment (which is quite\n> > > specific subset of HTML) is a best solution.\n> > \n> > That’s true. The piece of code to be inserted in <head> is maybe small\n> > enough so that we don’t need a file. Maybe $site_htmlheader could\n> > contain directly the html snippet to be inserted in the pages?\n> \n> I think it might be a better solution.\n\nI changed this in the patch attached in this mail. Now the variable should\ncontain directly the html code to be inserted.\n\n> > > >  gitweb/INSTALL     |    3 +++\n> > > \n> > > Nb. there is patch in flight adding gitweb.conf(5) and gitweb(1)\n> > > manpages...\n> > \n> > Ok. So, I’ll update them once a decision will be taken concerning this\n> > $site_htmlheader.\n> \n> You might have to wait a bit till patches containing gitweb.conf(5)\n> manpage are merged in, and rebase your patch to add information about\n> new config variable not to gitweb/INSTALL, but to\n> Documentation/gitweb.conf.txt\n\nI added the documentation to Documentation/gitweb.conf.txt.\nBut, as I noticed that gitweb/INSTALL still exists and still documents the\nold variables, I left the doc of the new one.\n\n Documentation/gitweb.conf.txt |    5 +++++\n gitweb/INSTALL                |    2 ++\n gitweb/Makefile               |    2 ++\n gitweb/gitweb.perl            |    7 +++++++\n t/gitweb-lib.sh               |    1 +\n 5 files changed, 17 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt\nindex 4ca3e27..5e69c2d 100644\n--- a/Documentation/gitweb.conf.txt\n+++ b/Documentation/gitweb.conf.txt\n@@ -364,6 +364,11 @@ $site_name::\n +\n Can be set using the `GITWEB_SITENAME` at build time.  Unset by default.\n \n+$site_htmlheader::\n+\tHTML snippet to be included in the <head> section of each page.\n+\tCan be set using `GITWEB_SITE_HTMLHEADER` at build time. No default\n+\tvalue.\n+\n $site_header::\n \tName of a file with HTML to be included at the top of each page.\n \tRelative to the directory containing the 'gitweb.cgi' script.\ndiff --git a/gitweb/INSTALL b/gitweb/INSTALL\nindex d134ffe..a6a9f06 100644\n--- a/gitweb/INSTALL\n+++ b/gitweb/INSTALL\n@@ -130,6 +130,8 @@ You can specify the following configuration variables when building GIT:\n    Points to an .html file which is included on the gitweb project\n    overview page ('projects_list' view), if it exists.  Relative to\n    gitweb.cgi script.  [Default: indextext.html]\n+ * GITWEB_SITE_HTMLHEADER\n+   html snippet to include in the <head> section of each page. [No default]\n  * GITWEB_SITE_HEADER\n    Filename of html text to include at top of each page.  Relative to\n    gitweb.cgi script.  [No default]\ndiff --git a/gitweb/Makefile b/gitweb/Makefile\nindex 1c85b5f..ecfb311 100644\n--- a/gitweb/Makefile\n+++ b/gitweb/Makefile\n@@ -34,6 +34,7 @@ GITWEB_CSS = static/gitweb.css\n GITWEB_LOGO = static/git-logo.png\n GITWEB_FAVICON = static/git-favicon.png\n GITWEB_JS = static/gitweb.js\n+GITWEB_SITE_HTMLHEADER =\n GITWEB_SITE_HEADER =\n GITWEB_SITE_FOOTER =\n HIGHLIGHT_BIN = highlight\n@@ -144,6 +145,7 @@ GITWEB_REPLACE = \\\n \t-e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \\\n \t-e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \\\n \t-e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \\\n+\t-e 's|++GITWEB_SITE_HTMLHEADER++|$(GITWEB_SITE_HTMLHEADER)|g' \\\n \t-e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \\\n \t-e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \\\n \t-e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 85d64b2..10b118b 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -85,6 +85,8 @@ our $home_link_str = \"++GITWEB_HOME_LINK_STR++\";\n our $site_name = \"++GITWEB_SITENAME++\"\n                  || ($ENV{'SERVER_NAME'} || \"Untitled\") . \" Git\";\n \n+# html snippet to include in the <head> section of each page\n+our $site_htmlheader = \"++GITWEB_SITE_HTMLHEADER++\";\n # filename of html text to include at top of each page\n our $site_header = \"++GITWEB_SITE_HEADER++\";\n # html text to include at home page\n@@ -3879,6 +3881,11 @@ EOF\n \t\tprint \"<base href=\\\"\".esc_url($base_url).\"\\\" />\\n\";\n \t}\n \tprint_header_links($status);\n+\n+\tif (defined $site_htmlheader) {\n+\t\tprint to_utf8($site_htmlheader);\n+\t}\n+\n \tprint \"</head>\\n\" .\n \t      \"<body>\\n\";\n \ndiff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh\nindex 292753f..cfe5d74 100644\n--- a/t/gitweb-lib.sh\n+++ b/t/gitweb-lib.sh\n@@ -16,6 +16,7 @@ our \\$projectroot = \"$safe_pwd\";\n our \\$project_maxdepth = 8;\n our \\$home_link_str = 'projects';\n our \\$site_name = '[localhost]';\n+our \\$site_htmlheader = '';\n our \\$site_header = '';\n our \\$site_footer = '';\n our \\$home_text = 'indextext.html';\n-- \n1.7.7\n"},{"id":"178109","messageId":"7vmxcv89jl.fsf@alter.siamese.dyndns.org","threadId":"28702","inReplyTo":"201110210046.34679.lenaic@lhuard.fr.eu.org","subject":"Re: [PATCH] gitweb: provide a way to customize html headers","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-21T00:37:02Z","receivedAt":"2011-10-21T00:37:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lénaïc Huard <lenaic@lhuard.fr.eu.org> writes:\n\n> +GITWEB_SITE_HTMLHEADER =\n>  GITWEB_SITE_HEADER =\n>  GITWEB_SITE_FOOTER =\n\nIs it just me or does the inconsistency between the existing two variables\nand this new one with a very similar name stand out like a sore something?\n\nIt might have been better if GITWEB_SITE_(HEADER|FOOTER) were named with\n\"_FILE\" suffix, but as long as we consider/declare insert_file is the norm\nand in-place inclusion of mini-string is an oddball, it is sufficient to\ncall this GITWEB_SITE_HTML_HEAD_STRING to avoid confusion?\n\nPerhaps GITWEB_SITE_HEADER_STRING and GITWEB_SITE_FOOTER_STRING might turn\nout to be useful in the future for in-place inclusion of mini-strings, and\nwhen that happens, you two would thank me for this suggestion ;-)\n"},{"id":"178112","messageId":"201110210909.30145.lenaic@lhuard.fr.eu.org","threadId":"28702","inReplyTo":"7vmxcv89jl.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] gitweb: provide a way to customize html headers","fromName":"Lénaïc Huard","fromEmail":"lenaic@lhuard.fr.eu.org","sentAt":"2011-10-21T07:09:29Z","receivedAt":"2011-10-21T07:09:29Z","isPatch":true,"sender":{"key":"lenaic@lhuard.fr.eu.org","avatar":null},"body":"This allows web sites to add some specific html headers to the pages\ngenerated by gitweb.\n\nThe new variable $site_html_head_string can be set to an html snippet that\nwill be inserted at the end of the <head> section of each page generated\nby gitweb.\n\nSigned-off-by: Lénaïc Huard <lenaic@lhuard.fr.eu.org>\n---\nLe vendredi 21 octobre 2011, Junio C Hamano a écrit :\n> It might have been better if GITWEB_SITE_(HEADER|FOOTER) were named with\n> \"_FILE\" suffix, but as long as we consider/declare insert_file is the norm\n> and in-place inclusion of mini-string is an oddball, it is sufficient to\n> call this GITWEB_SITE_HTML_HEAD_STRING to avoid confusion?\n\nIndeed, things will be clearer like this.\n\n\n Documentation/gitweb.conf.txt |    5 +++++\n gitweb/INSTALL                |    2 ++\n gitweb/Makefile               |    2 ++\n gitweb/gitweb.perl            |    7 +++++++\n t/gitweb-lib.sh               |    1 +\n 5 files changed, 17 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt\nindex 4ca3e27..7aba497 100644\n--- a/Documentation/gitweb.conf.txt\n+++ b/Documentation/gitweb.conf.txt\n@@ -364,6 +364,11 @@ $site_name::\n +\n Can be set using the `GITWEB_SITENAME` at build time.  Unset by default.\n \n+$site_html_head_string::\n+\tHTML snippet to be included in the <head> section of each page.\n+\tCan be set using `GITWEB_SITE_HTML_HEAD_STRING` at build time.\n+\tNo default value.\n+\n $site_header::\n \tName of a file with HTML to be included at the top of each page.\n \tRelative to the directory containing the 'gitweb.cgi' script.\ndiff --git a/gitweb/INSTALL b/gitweb/INSTALL\nindex d134ffe..6d45406 100644\n--- a/gitweb/INSTALL\n+++ b/gitweb/INSTALL\n@@ -130,6 +130,8 @@ You can specify the following configuration variables when building GIT:\n    Points to an .html file which is included on the gitweb project\n    overview page ('projects_list' view), if it exists.  Relative to\n    gitweb.cgi script.  [Default: indextext.html]\n+ * GITWEB_SITE_HTML_HEAD_STRING\n+   html snippet to include in the <head> section of each page. [No default]\n  * GITWEB_SITE_HEADER\n    Filename of html text to include at top of each page.  Relative to\n    gitweb.cgi script.  [No default]\ndiff --git a/gitweb/Makefile b/gitweb/Makefile\nindex 1c85b5f..e65fc27 100644\n--- a/gitweb/Makefile\n+++ b/gitweb/Makefile\n@@ -34,6 +34,7 @@ GITWEB_CSS = static/gitweb.css\n GITWEB_LOGO = static/git-logo.png\n GITWEB_FAVICON = static/git-favicon.png\n GITWEB_JS = static/gitweb.js\n+GITWEB_SITE_HTML_HEAD_STRING =\n GITWEB_SITE_HEADER =\n GITWEB_SITE_FOOTER =\n HIGHLIGHT_BIN = highlight\n@@ -144,6 +145,7 @@ GITWEB_REPLACE = \\\n \t-e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \\\n \t-e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \\\n \t-e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \\\n+\t-e 's|++GITWEB_SITE_HTML_HEAD_STRING++|$(GITWEB_SITE_HTML_HEAD_STRING)|g' \\\n \t-e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \\\n \t-e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \\\n \t-e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 85d64b2..fa9b83b 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -85,6 +85,8 @@ our $home_link_str = \"++GITWEB_HOME_LINK_STR++\";\n our $site_name = \"++GITWEB_SITENAME++\"\n                  || ($ENV{'SERVER_NAME'} || \"Untitled\") . \" Git\";\n \n+# html snippet to include in the <head> section of each page\n+our $site_html_head_string = \"++GITWEB_SITE_HTML_HEAD_STRING++\";\n # filename of html text to include at top of each page\n our $site_header = \"++GITWEB_SITE_HEADER++\";\n # html text to include at home page\n@@ -3879,6 +3881,11 @@ EOF\n \t\tprint \"<base href=\\\"\".esc_url($base_url).\"\\\" />\\n\";\n \t}\n \tprint_header_links($status);\n+\n+\tif (defined $site_html_head_string) {\n+\t\tprint to_utf8($site_html_head_string);\n+\t}\n+\n \tprint \"</head>\\n\" .\n \t      \"<body>\\n\";\n \ndiff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh\nindex 292753f..21d11d6 100644\n--- a/t/gitweb-lib.sh\n+++ b/t/gitweb-lib.sh\n@@ -16,6 +16,7 @@ our \\$projectroot = \"$safe_pwd\";\n our \\$project_maxdepth = 8;\n our \\$home_link_str = 'projects';\n our \\$site_name = '[localhost]';\n+our \\$site_html_head_string = '';\n our \\$site_header = '';\n our \\$site_footer = '';\n our \\$home_text = 'indextext.html';\n-- \n1.7.7\n"},{"id":"178141","messageId":"201110212114.34325.jnareb@gmail.com","threadId":"28702","inReplyTo":"201110210046.34679.lenaic@lhuard.fr.eu.org","subject":"Re: [PATCH] gitweb: provide a way to customize html headers","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-10-21T19:14:33Z","receivedAt":"2011-10-21T19:14:33Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Dnia piątek 21. października 2011 00:46, Lénaïc Huard napisał:\n> Le lundi 17 octobre 2011, Jakub Narebski a écrit :\n>> On Mon, 17 Oct 2011, Lénaïc Huard wrote:\n>>> Jakub Narebski <jnareb@gmail.com> writes:\n>>>> Lénaïc Huard <lenaic@lhuard.fr.eu.org> writes:\n[...]\n>>>>>  gitweb/INSTALL     |    3 +++\n>>>> \n>>>> Nb. there is patch in flight adding gitweb.conf(5) and gitweb(1)\n>>>> manpages...\n>>> \n>>> Ok. So, I’ll update them once a decision will be taken concerning this\n>>> $site_htmlheader.\n>> \n>> You might have to wait a bit till patches containing gitweb.conf(5)\n>> manpage are merged in, and rebase your patch to add information about\n>> new config variable not to gitweb/INSTALL, but to\n>> Documentation/gitweb.conf.txt\n> \n> I added the documentation to Documentation/gitweb.conf.txt.\n> But, as I noticed that gitweb/INSTALL still exists and still documents the\n> old variables, I left the doc of the new one.\n> \n>  Documentation/gitweb.conf.txt |    5 +++++\n>  gitweb/INSTALL                |    2 ++\n>  gitweb/Makefile               |    2 ++\n>  gitweb/gitweb.perl            |    7 +++++++\n>  t/gitweb-lib.sh               |    1 +\n>  5 files changed, 17 insertions(+), 0 deletions(-)\n\nWell, gitweb/INSTALL documents _build_ time [make] variables, and that\ndidn't change with introduction of gitweb manpages.  Those are important\nonly during explanation.\n\nIt is only runtime _configuration_ that moved from gitweb/README (which\nshould be short description of project) to manpages for gitweb config.\n\n-- \nJakub Narebski\nPoland\n"}]}