[PATCH 5/8] compact code

Signed-off-by: klObs <jw@klobs.de>
This commit is contained in:
dodo 2013-03-31 16:24:28 +02:00 committed by klObs
parent 7206dda416
commit aa78e2822a
1 changed files with 23 additions and 30 deletions

View File

@ -58,36 +58,29 @@
<xsl:call-template name="normalize-path">
<xsl:with-param name="path">
<xsl:choose>
<xsl:when test="contains(string(.), '://')">
<xsl:choose>
<xsl:when test="contains(string(.), 'wikimedia.org')">
<xsl:variable name="filename">
<xsl:value-of select="string(str:tokenize(string(.),'/')[last()])"/>
</xsl:variable>
<xsl:variable name="hash">
<xsl:value-of select="concat(str:tokenize(string(.),'/')[position()=last()-2],'/',str:tokenize(string(.),'/')[position()=last()-1],'/')"/>
</xsl:variable>
<xsl:variable name="validfilename">
<xsl:choose>
<xsl:when test="contains($filename, '.svg') and string-length(substring-after($filename, '.svg'))=0">
<xsl:value-of select="concat($filename, '.png')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$filename"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat(substring-before(string(.),'commons/'),'commons/thumb/',$hash,$filename,'/600px-',$validfilename)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="string(.)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="string(.)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:when test="contains(string(.), '://') and contains(string(.), 'wikimedia.org')">
<xsl:variable name="filename">
<xsl:value-of select="string(str:tokenize(string(.),'/')[last()])"/>
</xsl:variable>
<xsl:variable name="hash">
<xsl:value-of select="concat(str:tokenize(string(.),'/')[position()=last()-2],'/',str:tokenize(string(.),'/')[position()=last()-1],'/')"/>
</xsl:variable>
<xsl:variable name="validfilename">
<xsl:choose>
<xsl:when test="contains($filename, '.svg') and string-length(substring-after($filename, '.svg'))=0">
<xsl:value-of select="concat($filename, '.png')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$filename"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat(substring-before(string(.),'commons/'),'commons/thumb/',$hash,$filename,'/600px-',$validfilename)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="string(.)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>