diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2016-07-05 08:54:53 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2016-07-05 08:57:55 +0200 |
commit | ec83b34a8f2ab92966ecbfc196245f5965306484 (patch) | |
tree | c38ff2e99b54598aed3b897e6416b3d9da46ddf4 /xsl | |
parent | 7c0de6da893a1e709663c462170ff2c0e4110ac1 (diff) | |
download | mutti-web-ec83b34a8f2ab92966ecbfc196245f5965306484.tar.gz mutti-web-ec83b34a8f2ab92966ecbfc196245f5965306484.tar.bz2 mutti-web-ec83b34a8f2ab92966ecbfc196245f5965306484.zip |
Allow to use different resource caching schemes
On the deployment server we no use
make versioned_jpg="'s/.*/.&.jpg/'" versioned_png="'s/.*/.&.png/'"
to generate resource urls like image.f74d4ea.png
Diffstat (limited to 'xsl')
-rw-r--r-- | xsl/common.xsl | 3 | ||||
-rw-r--r-- | xsl/img.xsl | 51 | ||||
-rw-r--r-- | xsl/layout.xsl | 8 |
3 files changed, 55 insertions, 7 deletions
diff --git a/xsl/common.xsl b/xsl/common.xsl index 0b7eefc..007d8a2 100644 --- a/xsl/common.xsl +++ b/xsl/common.xsl @@ -19,6 +19,9 @@ <xsl:param name="stylesheet" select="'@import url("style/style.css");'" /> <xsl:param name="version" select="''" /> + <xsl:param name="versioned_jpg" select="'.jpg'" /> + <xsl:param name="versioned_png" select="'.png'" /> + <xsl:output method="xml" indent="no" encoding="utf-8" cdata-section-elements="script style" media-type="application/xhtml+xml" diff --git a/xsl/img.xsl b/xsl/img.xsl index e2a9824..0c10fd2 100644 --- a/xsl/img.xsl +++ b/xsl/img.xsl @@ -14,10 +14,55 @@ <!-- ..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:variable name="replace_jpg"> + <xsl:call-template name="replace-string"> + <xsl:with-param name="text" select="@src"/> + <xsl:with-param name="replace" select="'.jpg'" /> + <xsl:with-param name="with" select="''"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="replace_jpg_png"> + <xsl:call-template name="replace-string"> + <xsl:with-param name="text" select="$replace_jpg"/> + <xsl:with-param name="replace" select="'.png'" /> + <xsl:with-param name="with" select="''"/> + </xsl:call-template> + </xsl:variable> + + <xsl:value-of select="$replace_jpg_png"/> + + <xsl:choose> + <xsl:when test="contains(@src, '.jpg')"> + <xsl:value-of select="$versioned_jpg"/> + </xsl:when> + <xsl:when test="contains(@src, '.png')"> + <xsl:value-of select="$versioned_png"/> + </xsl:when> + </xsl:choose> </xsl:attribute> </xsl:copy> </xsl:template> + + <xsl:template name="replace-string"> + <xsl:param name="text"/> + <xsl:param name="replace"/> + <xsl:param name="with"/> + <xsl:choose> + <xsl:when test="contains($text,$replace)"> + <xsl:value-of select="substring-before($text,$replace)"/> + <xsl:value-of select="$with"/> + <xsl:call-template name="replace-string"> + <xsl:with-param name="text" +select="substring-after($text,$replace)"/> + <xsl:with-param name="replace" select="$replace"/> + <xsl:with-param name="with" select="$with"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$text"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> </xsl:stylesheet> diff --git a/xsl/layout.xsl b/xsl/layout.xsl index 7b0a4c9..21d466d 100644 --- a/xsl/layout.xsl +++ b/xsl/layout.xsl @@ -48,7 +48,7 @@ <br/> <br/> <a href="https://plus.google.com/112211240794067152603"> - <img src="img/gplus32.png?{$version}" width="32" height="32" class="social-icon" alt="Google Plus" /> + <img src="img/gplus32{$versioned_png}" width="32" height="32" class="social-icon" alt="Google Plus" /> </a> <br/> <a href="contact{$suffix}" class="redbox"> @@ -65,14 +65,14 @@ </div> <div class="logos"> <a href="http://www.idz-zertifikat.de/voraussetzung-fachberater-existenzgruender" target="_blank"> - <img src="idz-siegel.jpg?{$version}" width="190" height="79" + <img src="idz-siegel{$versioned_jpg}" width="190" height="79" alt="Fachberaterin für Existenzgründer - Institut für Dienstleistungszertifizierung" /> </a> <a href="http://www.mikrokredit.net/" target="_blank"> - <img src="kapitalinstitut.png?{$version}" width="180" height="32" alt="Kapitalinstitut" /> + <img src="kapitalinstitut{$versioned_png}" width="180" height="32" 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?{$version}" width="77" height="77" alt="Für-Gründer.de" /> + <img src="fuer-gruender.de-siegel{$versioned_png}" width="77" height="77" alt="Für-Gründer.de" /> </a> </div> <footer> |