From 13db8faba0c694ae1c0a5299909d6b173eeabf47 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Fri, 11 Sep 2020 17:20:31 -0700 Subject: [PATCH] templates: process html templates once at install There's no compelling reason to run the html template processor every time an html template page is requested only to process the same template file with exactly the same settings into exactly the same result page every time. Instead, process all the template files just once at install time and then serve the results as static html pages for a small bit of improved efficiency. Signed-off-by: Kyle J. McKay --- apache.conf.in | 17 +++++++++++++++-- install.sh | 11 +++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/apache.conf.in b/apache.conf.in index 3c0fd48..edc13f7 100644 --- a/apache.conf.in +++ b/apache.conf.in @@ -76,7 +76,7 @@ ScriptAlias /w @@cgiroot@@/gitweb.cgi ScriptAlias /b @@cgiroot@@/bundles.cgi - ScriptAlias /h @@cgiroot@@/html.cgi + AliasMatch ^/h/(.*\.html)$ @@cgiroot@@/html/$1 ScriptAliasMatch ^/(?!(?i)gitweb\.cgi|bundles\.cgi|html\.cgi(?:/|$))([^/]+\.cgi(?:/.*)?)$ @@cgiroot@@/$1 # Any requests without the magic /[bchrw] are treated as Git requests if they @@ -175,7 +175,7 @@ # Make the leading /h optional for requests that name an existing .html template RewriteCond @@webroot@@/$1 !-f RewriteCond @@cgiroot@@/$1 !-f - RewriteCond @@basedir@@/html/$1 -s + RewriteCond @@cgiroot@@/html/$1 -s RewriteRule \ ^/(?![bchrw]/)(.*\.html)$ \ /h/$1 [NS,PT] @@ -374,6 +374,19 @@ + + + Order deny,allow + Allow from all + Satisfy all + + = 2.3> + Require all granted + + + ForceType "text/html; charset=utf-8" + + # mod_fcgid benefits from some additional config for gitweb.cgi diff --git a/install.sh b/install.sh index 238fa24..5144738 100755 --- a/install.sh +++ b/install.sh @@ -1073,6 +1073,17 @@ else fi +echo "*** Processing website html templates..." +rm -f "$cgiroot/html.cgi" +rm -rf "$cgiroot/html" +mkdir -p "$cgiroot/html" +for tf in "$basedir/html"/*.html; do + tfb="${tf##*/}" + "$perlbin" -I"$basedir" cgi/html.cgi "$webroot" "$tfb" "$basedir" >"$cgiroot/html/$tfb" + rm -f "$tf" +done + + echo "*** Finalizing permissions and moving into place..." chown -R -h "$cfg_mirror_user""$owngroup" "$basedir" "$webroot" "$cgiroot" [ -z "$cfg_httpspushurl" ] || chown -R -h "$cfg_mirror_user""$owngroup" "$cfg_certsdir" -- 2.11.4.GIT