random news image fallback
continuous-integration/drone/push Build is failing Details

This commit is contained in:
vv01f 2023-07-11 22:00:24 +02:00
parent 77197c4977
commit 2e1d0c607c
11 changed files with 17 additions and 4 deletions

View File

@ -0,0 +1 @@
../hq/new1.jpg

View File

@ -0,0 +1 @@
../hq/old1.jpg

View File

@ -0,0 +1 @@
../hq/old2.jpg

View File

@ -0,0 +1 @@
../hq/pano1.jpg

View File

@ -0,0 +1 @@
../hq/pano3.jpg

View File

@ -0,0 +1 @@
gchq-hdr.jpg

View File

@ -0,0 +1 @@
../hq/schalter.jpg

View File

@ -0,0 +1 @@
./zentralwerk_bau.jpg

View File

@ -0,0 +1 @@
../hqdefault.jpg

View File

@ -0,0 +1 @@
gchq-werkbank.jpg

View File

@ -4,7 +4,8 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:str="http://exslt.org/strings"
exclude-result-prefixes="xsl date str">
xmlns:crypto="http://exslt.org/crypto"
exclude-result-prefixes="xsl date str crypto">
<xsl:include href="common.xsl" />
@ -379,6 +380,8 @@
</xsl:template>
<xsl:template match="/page/portal/item">
<!-- 1 (not really) random character 1-9 and blank -->
<xsl:variable name="random" select="translate(substring(crypto:sha1(.),1,1),'0abcdef','')"/>
<article>
<xsl:if test="@class">
<xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
@ -393,10 +396,10 @@
</xsl:when>
<xsl:otherwise><!-- Fallback image -->
<xsl:choose><!-- depending on class -->
<!-- todo: random image from list (filenames might be links), maybe based on hash() -->
<xsl:when test="@class = 'news'"><xsl:attribute name="style">background-image: url('images/news/gchq-hdr.jpg');</xsl:attribute></xsl:when>
<!-- "random" image from list (filenames should be links) -->
<xsl:when test="@class = 'news'"><xsl:attribute name="style">background-image: url('images/news/rnd<xsl:value-of select="$random"/>');</xsl:attribute></xsl:when>
<!--
<xsl:when test="@class = 'wiki'"><xsl:attribute name="style">background-image: url('images/news/wikidata.png');</xsl:attribute></xsl:when>
<xsl:when test="@class = 'news'"><xsl:attribute name="style">background-image: url('images/news/gchq-hdr.jpg');</xsl:attribute></xsl:when>
-->
</xsl:choose>
</xsl:otherwise>