summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2016-07-04 07:26:37 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2016-07-04 07:37:21 +0200
commitdf7ec5a70f0effd1c7749392a86c3d7adaf83364 (patch)
tree1249e28633ddc9ba99148ee94568c94f809b9cf8
parentb2f92f6011e27de75b38ea5e88f2390cfea2fa78 (diff)
downloadmutti-web-df7ec5a70f0effd1c7749392a86c3d7adaf83364.tar.gz
mutti-web-df7ec5a70f0effd1c7749392a86c3d7adaf83364.tar.bz2
mutti-web-df7ec5a70f0effd1c7749392a86c3d7adaf83364.zip
Add git hash as query string to resources
..to be able to set an infinite cache for the browser, but to invalidate the resources for every git commit (That may be a waste of resources, but is "most safe" to ensure we get an up to date site) It has to be explicitly defined in the template. Occurences of the img-tag in the source files get the git hash automatically appended.
-rw-r--r--Makefile3
-rw-r--r--xsl/common.xsl2
-rw-r--r--xsl/img.xsl23
-rw-r--r--xsl/layout.xsl10
4 files changed, 32 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index a36830b..01cb9b0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
suffix = .xhtml
+version = $(shell git rev-parse --short HEAD)
-xsltproc=xsltproc --stringparam suffix $(suffix) --stringparam stylesheet style.min.css
+xsltproc=xsltproc --stringparam suffix $(suffix) --stringparam stylesheet style.min.css --stringparam version $(version)
svg2png=rsvg-convert -f png
pages=$(shell xsltproc xsl/main_filenames.xsl main.xml)
diff --git a/xsl/common.xsl b/xsl/common.xsl
index f9387dc..07acb7d 100644
--- a/xsl/common.xsl
+++ b/xsl/common.xsl
@@ -9,6 +9,7 @@
<xsl:include href="navi.xsl" />
<xsl:include href="link.xsl" />
<xsl:include href="svg.xsl" />
+ <xsl:include href="img.xsl" />
<xsl:strip-space elements="*"/>
@@ -16,6 +17,7 @@
<xsl:variable name="title" select="document('../main.xml')/s:site/s:page[@filename = $filename]/@title" />
<xsl:param name="suffix" select="'.xml'" />
<xsl:param name="stylesheet" select="'style.css'" />
+ <xsl:param name="version" select="''" />
<xsl:output method="xml" indent="no" encoding="utf-8"
cdata-section-elements="script style"
diff --git a/xsl/img.xsl b/xsl/img.xsl
new file mode 100644
index 0000000..e2a9824
--- /dev/null
+++ b/xsl/img.xsl
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0"
+ exclude-result-prefixes="s"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="https://beratung-franzke.de/web-tpl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+
+ <xsl:template match="html:img" mode="html">
+ <xsl:copy>
+ <!-- Copy all attributes and nested nodes -->
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates mode="html"/>
+
+ <!-- ..but modify the src attribute to have a ?git-hash suffix -->
+ <xsl:attribute name="src">
+ <xsl:value-of select="@src"/>
+ <xsl:text>?</xsl:text>
+ <xsl:value-of select="$version"/>
+ </xsl:attribute>
+ </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/xsl/layout.xsl b/xsl/layout.xsl
index 394e23a..c10b4b6 100644
--- a/xsl/layout.xsl
+++ b/xsl/layout.xsl
@@ -17,7 +17,7 @@
</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width" />
- <link rel="stylesheet" type="text/css" href="style/{$stylesheet}" />
+ <link rel="stylesheet" type="text/css" href="style/{$stylesheet}?{$version}" />
</head>
<body>
<header>
@@ -51,7 +51,7 @@
<br/>
<a href="https://plus.google.com/112211240794067152603">
- <img src="img/gplus.png" class="social-icon" alt="Google Plus" />
+ <img src="img/gplus.png?{$version}" class="social-icon" alt="Google Plus" />
</a>
<br/>
@@ -70,14 +70,14 @@
</div>
<div class="logos">
<a href="http://www.idz-zertifikat.de/voraussetzung-fachberater-existenzgruender" target="_blank">
- <img src="idz-siegel.jpg"
+ <img src="idz-siegel.jpg?{$version}"
alt="Fachberaterin für Existenzgründer - Institut für Dienstleistungszertifizierung" />
</a>
<a href="http://www.mikrokredit.net/" target="_blank">
- <img src="kapitalinstitut.png" alt="Kapitalinstitut" />
+ <img src="kapitalinstitut.png?{$version}" alt="Kapitalinstitut" />
</a>
<a href="http://www.fuer-gruender.de/beratung/dienstleister-finden/firma/beratung-controlling/" target="_blank">
- <img src="fuer-gruender.de-siegel.png" alt="Für-Gründer.de" />
+ <img src="fuer-gruender.de-siegel.png?{$version}" alt="Für-Gründer.de" />
</a>
</div>
<footer>