From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?q?L=C3=A9na=C3=AFc_Huard?= Subject: Re: [PATCH] gitweb: provide a way to customize html headers Date: Fri, 21 Oct 2011 00:46:34 +0200 Message-ID: <201110210046.34679.lenaic@lhuard.fr.eu.org> References: <201110170928.56075.lenaic@lhuard.fr.eu.org> <201110171357.00278.jnareb@gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: git@vger.kernel.org To: Jakub Narebski X-From: git-owner@vger.kernel.org Fri Oct 21 00:46:47 2011 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RH1Ns-0001Xg-8G for gcvg-git-2@lo.gmane.org; Fri, 21 Oct 2011 00:46:44 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751582Ab1JTWqj convert rfc822-to-quoted-printable (ORCPT ); Thu, 20 Oct 2011 18:46:39 -0400 Received: from freebox.lhuard.fr.eu.org ([88.182.161.122]:53337 "EHLO coruscant.lhuard.fr.eu.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751550Ab1JTWqj convert rfc822-to-8bit (ORCPT ); Thu, 20 Oct 2011 18:46:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lhuard.fr.eu.org; s=dkim; h=Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:In-Reply-To:References:Cc:Date:Subject:To:From; bh=I9mlrErYjy0Jnz+uKIwhzRHzGjJYcfiEKSX48eUlABk=; b=bJ3vGb9CO3iA6C6pjPHmRrTMfe65ur6BG8KdhIGHOCO6WfEKPcgENcqggkv886uIMxsq+nAe2f50kQRNTFrUExZ3v2EaWNlki/KXI3zqwWd2WnjYhraymp3jqkltLrRu8LW038jC5XMLtli0Isz0zpwjZr8y5HR3SFWU8wxYCjg=; Received: from lenaic by coruscant.lhuard.fr.eu.org with local (Exim 4.76) (envelope-from ) id 1RH1Ni-0003Q7-Sw; Fri, 21 Oct 2011 00:46:35 +0200 User-Agent: KMail/1.13.7 (Linux/3.0.0-2-amd64; KDE/4.6.5; x86_64; ; ) In-Reply-To: <201110171357.00278.jnareb@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: This allows web sites to add some specific html headers to the pages generated by gitweb. The new variable $site_htmlheader can be set to an html snippet that will be inserted at the end of the section of each page generated by gitweb. Signed-off-by: L=C3=A9na=C3=AFc Huard --- Le lundi 17 octobre 2011, Jakub Narebski a =C3=A9crit : > On Mon, 17 Oct 2011, L=C3=A9na=C3=AFc Huard wrote: > > Jakub Narebski writes: > > > L=C3=A9na=C3=AFc Huard writes: > > > > This allows web sites to add some specific html headers to the = pages > > > > generated by gitweb. > > >=20 > > > What do you need this for? > >=20 > > I want to decorate the gitweb pages with the =E2=80=9CGoogle Analyt= ics=E2=80=9D tracking > > code. In order to do so, today, Google is recommending to add a > > tag just before the closing tag. > >=20 > > https://www.google.com/support/analyticshelp/bin/answer.py?answer=3D= 1008080 > > &hl=3Den >=20 > Hmmm... the modern recommendation from both Google and Yahoo is to pu= t > script tags at the end of HTML, just before closing , which yo= u > can do nowadays with $site_footer / GITWEB_SITE_FOOTER. >=20 > But I guess that analytics script needs to be loaded earlier. In fact, I used to insert the Google Analytics tracking code before , but I recently noticed that Google is now recommending to put the html snippet at the end of the section. Here is the recommendation from Google: https://code.google.com/apis/analytics/docs/tracking/asyncTracking.html =46rom what I understood, the goal of putting the script tags just befo= re was to avoid to increase the page load time in case of latency = of the remote server serving the js script. The GA tracking code is now loading the js asynchronously. So, it doesn= =E2=80=99t block the page load anymore. So, the load can be started asap. > > > > The new variable $site_htmlheader can be set to a filename the > > > > content of which will be inserted at the end of the sect= ion > > > > of each page generated by gitweb. > > >=20 > > > Hmmm... I wonder if a file with html header fragment (which is qu= ite > > > specific subset of HTML) is a best solution. > >=20 > > That=E2=80=99s true. The piece of code to be inserted in is = maybe small > > enough so that we don=E2=80=99t need a file. Maybe $site_htmlheader= could > > contain directly the html snippet to be inserted in the pages? >=20 > I think it might be a better solution. I changed this in the patch attached in this mail. Now the variable sho= uld contain directly the html code to be inserted. > > > > gitweb/INSTALL | 3 +++ > > >=20 > > > Nb. there is patch in flight adding gitweb.conf(5) and gitweb(1) > > > manpages... > >=20 > > Ok. So, I=E2=80=99ll update them once a decision will be taken conc= erning this > > $site_htmlheader. >=20 > You might have to wait a bit till patches containing gitweb.conf(5) > manpage are merged in, and rebase your patch to add information about > new config variable not to gitweb/INSTALL, but to > Documentation/gitweb.conf.txt I added the documentation to Documentation/gitweb.conf.txt. But, as I noticed that gitweb/INSTALL still exists and still documents = the old variables, I left the doc of the new one. Documentation/gitweb.conf.txt | 5 +++++ gitweb/INSTALL | 2 ++ gitweb/Makefile | 2 ++ gitweb/gitweb.perl | 7 +++++++ t/gitweb-lib.sh | 1 + 5 files changed, 17 insertions(+), 0 deletions(-) diff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.= txt index 4ca3e27..5e69c2d 100644 --- a/Documentation/gitweb.conf.txt +++ b/Documentation/gitweb.conf.txt @@ -364,6 +364,11 @@ $site_name:: + Can be set using the `GITWEB_SITENAME` at build time. Unset by defaul= t. =20 +$site_htmlheader:: + HTML snippet to be included in the section of each page. + Can be set using `GITWEB_SITE_HTMLHEADER` at build time. No default + value. + $site_header:: Name of a file with HTML to be included at the top of each page. Relative to the directory containing the 'gitweb.cgi' script. diff --git a/gitweb/INSTALL b/gitweb/INSTALL index d134ffe..a6a9f06 100644 --- a/gitweb/INSTALL +++ b/gitweb/INSTALL @@ -130,6 +130,8 @@ You can specify the following configuration variabl= es when building GIT: Points to an .html file which is included on the gitweb project overview page ('projects_list' view), if it exists. Relative to gitweb.cgi script. [Default: indextext.html] + * GITWEB_SITE_HTMLHEADER + html snippet to include in the section of each page. [No def= ault] * GITWEB_SITE_HEADER Filename of html text to include at top of each page. Relative to gitweb.cgi script. [No default] diff --git a/gitweb/Makefile b/gitweb/Makefile index 1c85b5f..ecfb311 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -34,6 +34,7 @@ GITWEB_CSS =3D static/gitweb.css GITWEB_LOGO =3D static/git-logo.png GITWEB_FAVICON =3D static/git-favicon.png GITWEB_JS =3D static/gitweb.js +GITWEB_SITE_HTMLHEADER =3D GITWEB_SITE_HEADER =3D GITWEB_SITE_FOOTER =3D HIGHLIGHT_BIN =3D highlight @@ -144,6 +145,7 @@ GITWEB_REPLACE =3D \ -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \ -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \ -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ + -e 's|++GITWEB_SITE_HTMLHEADER++|$(GITWEB_SITE_HTMLHEADER)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g' diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 85d64b2..10b118b 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -85,6 +85,8 @@ our $home_link_str =3D "++GITWEB_HOME_LINK_STR++"; our $site_name =3D "++GITWEB_SITENAME++" || ($ENV{'SERVER_NAME'} || "Untitled") . " Git"; =20 +# html snippet to include in the section of each page +our $site_htmlheader =3D "++GITWEB_SITE_HTMLHEADER++"; # filename of html text to include at top of each page our $site_header =3D "++GITWEB_SITE_HEADER++"; # html text to include at home page @@ -3879,6 +3881,11 @@ EOF print "\n"; } print_header_links($status); + + if (defined $site_htmlheader) { + print to_utf8($site_htmlheader); + } + print "\n" . "\n"; =20 diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh index 292753f..cfe5d74 100644 --- a/t/gitweb-lib.sh +++ b/t/gitweb-lib.sh @@ -16,6 +16,7 @@ our \$projectroot =3D "$safe_pwd"; our \$project_maxdepth =3D 8; our \$home_link_str =3D 'projects'; our \$site_name =3D '[localhost]'; +our \$site_htmlheader =3D ''; our \$site_header =3D ''; our \$site_footer =3D ''; our \$home_text =3D 'indextext.html'; --=20 1.7.7