gitweb: provide a way to customize html headers

This allows web sites to add some specific html headers to the pages generated by gitweb. The new variable $site_html_head_string can be set to an html snippet that will be inserted at the end of the <head> section of each page generated by gitweb. Signed-off-by: Lénaïc Huard <lenaic@lhuard.fr.eu.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lénaïc Huard committed Oct 21, 2011 at 09:09 UTC c1355b7ffb6573ff7c76aef7d3bab664fb895dc8
5 files changed +17
Documentation/gitweb.conf.txt
+5
@@ -364,6 +364,11 @@ $site_name::
364 +
365 Can be set using the `GITWEB_SITENAME` at build time. Unset by default.
366
367 +$site_html_head_string::
368 + HTML snippet to be included in the <head> section of each page.
369 + Can be set using `GITWEB_SITE_HTML_HEAD_STRING` at build time.
370 + No default value.
371 +
372 $site_header::
373 Name of a file with HTML to be included at the top of each page.
374 Relative to the directory containing the 'gitweb.cgi' script.
gitweb/INSTALL
+2
@@ -130,6 +130,8 @@ You can specify the following configuration variables when building GIT:
130 Points to an .html file which is included on the gitweb project
131 overview page ('projects_list' view), if it exists. Relative to
132 gitweb.cgi script. [Default: indextext.html]
133 + * GITWEB_SITE_HTML_HEAD_STRING
134 + html snippet to include in the <head> section of each page. [No default]
135 * GITWEB_SITE_HEADER
136 Filename of html text to include at top of each page. Relative to
137 gitweb.cgi script. [No default]
gitweb/Makefile
+2
@@ -34,6 +34,7 @@ GITWEB_CSS = static/gitweb.css
34 GITWEB_LOGO = static/git-logo.png
35 GITWEB_FAVICON = static/git-favicon.png
36 GITWEB_JS = static/gitweb.js
37 +GITWEB_SITE_HTML_HEAD_STRING =
38 GITWEB_SITE_HEADER =
39 GITWEB_SITE_FOOTER =
40 HIGHLIGHT_BIN = highlight
@@ -144,6 +145,7 @@ GITWEB_REPLACE = \
145 -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
146 -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
147 -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
148 + -e 's|++GITWEB_SITE_HTML_HEAD_STRING++|$(GITWEB_SITE_HTML_HEAD_STRING)|g' \
149 -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
150 -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
151 -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
gitweb/gitweb.perl
+7
@@ -85,6 +85,8 @@ our $home_link_str = "++GITWEB_HOME_LINK_STR++";
85 our $site_name = "++GITWEB_SITENAME++"
86 || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";
87
88 +# html snippet to include in the <head> section of each page
89 +our $site_html_head_string = "++GITWEB_SITE_HTML_HEAD_STRING++";
90 # filename of html text to include at top of each page
91 our $site_header = "++GITWEB_SITE_HEADER++";
92 # html text to include at home page
@@ -3868,6 +3870,11 @@ EOF
3870 print "<base href=\"".esc_url($base_url)."\" />\n";
3871 }
3872 print_header_links($status);
3873 +
3874 + if (defined $site_html_head_string) {
3875 + print to_utf8($site_html_head_string);
3876 + }
3877 +
3878 print "</head>\n" .
3879 "<body>\n";
3880
t/gitweb-lib.sh
+1
@@ -16,6 +16,7 @@ our \$projectroot = "$safe_pwd";
16 our \$project_maxdepth = 8;
17 our \$home_link_str = 'projects';
18 our \$site_name = '[localhost]';
19 +our \$site_html_head_string = '';
20 our \$site_header = '';
21 our \$site_footer = '';
22 our \$home_text = 'indextext.html';