summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile20
-rw-r--r--xsl/common.xsl3
-rw-r--r--xsl/img.xsl51
-rw-r--r--xsl/layout.xsl8
4 files changed, 68 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 8bfe4c6..ff356b5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,13 @@
-suffix = xhtml
+suffix = .xhtml
+link_suffix = $(suffix)
version = $(shell git rev-parse --short HEAD)
-xsltproc=xsltproc --stringparam stylesheet "$(shell cat style/style.min.css)" --stringparam version $(version)
+versioned_jpg = 's/.*/.jpg?&/'
+versioned_png = 's/.*/.png?&/'
+
+version_args = --stringparam versioned_jpg $(shell echo $(version) | sed $(versioned_jpg)) --stringparam versioned_png $(shell echo $(version) | sed $(versioned_png))
+
+xsltproc=xsltproc --stringparam stylesheet "$(shell cat style/style.min.css)" --stringparam version $(version) $(version_args)
svg2png=rsvg-convert -f png
fix_doctype=sed 's/ SYSTEM "about:legacy-compat"//'
@@ -9,7 +15,7 @@ to_html=$(fix_doctype) | xsltproc xsl/convert-xhtml-to-html.xsl - | $(fix_doctyp
pages=$(shell xsltproc xsl/main_filenames.xsl main.xml)
-pages_gen=$(pages:%.xml=%.$(suffix))
+pages_gen=$(pages:%.xml=%$(suffix))
pages_gen_html=$(pages:%.xml=%.html)
common_depend=main.xml $(wildcard xsl/*.xsl) Makefile checkmark.svg style/style.min.css
@@ -38,11 +44,11 @@ html: $(pages_gen_html)
%.png: %.svg
$(V_GEN) $(svg2png) $< > $@
-%.$(suffix): %.xml %.xsl $(common_depend)
- $(V_XSLT) $(xsltproc) --stringparam suffix .$(suffix) $< | $(fix_doctype) > $@
+%$(suffix): %.xml %.xsl $(common_depend)
+ $(V_XSLT) $(xsltproc) --stringparam suffix $(link_suffix) $< | $(fix_doctype) > $@
-%.$(suffix): %.xml $(common_depend)
- $(V_XSLT) $(xsltproc) --stringparam suffix .$(suffix) $< | $(fix_doctype) > $@
+%$(suffix): %.xml $(common_depend)
+ $(V_XSLT) $(xsltproc) --stringparam suffix $(link_suffix) $< | $(fix_doctype) > $@
%.html: %.xml %.xsl $(common_depend)
$(V_XSLT) $(xsltproc) --stringparam suffix .html $< | $(to_html) > $@
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(&quot;style/style.css&quot;);'" />
<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>