[PATCH] gitweb: provide a way to customize html headers

Subsystems: the rest

DORMANTno replies

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] gitweb: provide a way to customize html headers

From: Lénaïc Huard <hidden>
Date: 2016-06-15 22:52:16

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 a filename the content
of which will be inserted at the end of the <head> section of each
page generated by gitweb.

Signed-off-by: Lénaïc Huard <redacted>
---
 gitweb/INSTALL     |    3 +++
 gitweb/Makefile    |    2 ++
 gitweb/gitweb.perl |    7 +++++++
 t/gitweb-lib.sh    |    1 +
 4 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/gitweb/INSTALL b/gitweb/INSTALL
index f5efe74..e23eafa 100644
--- a/gitweb/INSTALL
+++ b/gitweb/INSTALL
@@ -130,6 +130,9 @@ You can specify the following configuration variables 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
+   Filename of html code to include in the <head> section of each page.
+   Relative to gitweb.cgi script.  [No default]
  * 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 = static/gitweb.css
 GITWEB_LOGO = static/git-logo.png
 GITWEB_FAVICON = static/git-favicon.png
 GITWEB_JS = static/gitweb.js
+GITWEB_SITE_HTMLHEADER =
 GITWEB_SITE_HEADER =
 GITWEB_SITE_FOOTER =
 HIGHLIGHT_BIN = highlight
@@ -144,6 +145,7 @@ GITWEB_REPLACE = \
        -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..63b0115 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -85,6 +85,8 @@ our $home_link_str = "++GITWEB_HOME_LINK_STR++";
 our $site_name = "++GITWEB_SITENAME++"
                  || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";
 
+# filename of html code to include in the <head> section of each page
+our $site_htmlheader = "++GITWEB_SITE_HTMLHEADER++";
 # filename of html text to include at top of each page
 our $site_header = "++GITWEB_SITE_HEADER++";
 # html text to include at home page
@@ -3879,6 +3881,11 @@ EOF
                print "<base href=\"".esc_url($base_url)."\" />\n";
        }
        print_header_links($status);
+
+       if (defined $site_htmlheader && -f $site_htmlheader) {
+               insert_file($site_htmlheader);
+       }
+
        print "</head>\n" .
              "<body>\n";
 
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 = "$safe_pwd";
 our \$project_maxdepth = 8;
 our \$home_link_str = 'projects';
 our \$site_name = '[localhost]';
+our \$site_htmlheader = '';
 our \$site_header = '';
 our \$site_footer = '';
 our \$home_text = 'indextext.html';
-- 
1.7.7

Re: [PATCH] gitweb: provide a way to customize html headers

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:52:16

䳾＀懾＀⁈畡牤‼汥湡楣䁬桵慲搮晲⹥甮潲朾⁷物瑥猺ਊ㸠周楳⁡汬潷猠睥戠獩瑥猠瑯⁡摤⁳潭攠獰散楦楣⁨瑭氠桥慤敲猠瑯⁴桥⁰慧敳ਾ⁧敮敲慴敤⁢礠杩瑷敢⸊੗桡琠摯⁹潵敥搠瑨楳⁦潲㼊 㸠周攠湥眠癡物慢汥․獩瑥彨瑭汨敡摥爠捡渠扥⁳整⁴漠愠晩汥湡浥⁴桥⁣潮瑥湴ਾ映睨楣栠睩汬⁢攠楮獥牴敤⁡琠瑨攠敮搠潦⁴桥‼桥慤㸠獥捴楯渠潦⁥慣栊㸠灡来⁧敮敲慴敤⁢礠杩瑷敢⸊ੈ浭洮⸮⁉⁷潮摥爠楦⁡⁦楬攠睩瑨⁨瑭氠桥慤敲⁦牡杭敮琠⡷桩捨⁩猠煵楴攊獰散楦楣⁳畢獥琠潦⁈呍䰩⁩猠愠扥獴⁳潬畴楯渮ਊ㸠ਾ⁓楧湥搭潦昭批㨠䳾＀懾＀⁈畡牤‼汥湡楣䁬桵慲搮晲⹥甮潲朾ਾ‭ⴭਾ†杩瑷敢⽉乓呁䱌††⁼††㌠⬫⬊੎戮⁴桥牥⁩猠灡瑣栠楮⁦汩杨琠慤摩湧⁧楴睥戮捯湦⠵⤠慮搠杩瑷敢⠱⤊浡湰慧敳⸮⸊ਭⴠ੊慫畢⁎慲ę扳歩�
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help