<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:s="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
xmlns:k="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/konfigurace"
xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="fn h s k m xs">
<!--
Images
******
Generates an XHTML img tag in a paragraph for given image.
Title and Alt are filled with the EXIF comment field.
Requires a command line tool: exiv2
*
@src path to the image file relative to the input directory (where web.conf resides)
-->
<xsl:template match="m:img">
<xsl:variable name="script">
<m:skript jazyk="bash" výstup="xml">
DIR=$(dirname "$XWG_STRANKA_SOUBOR");
DIR="$DIR/../vstup"
cd "$DIR";
<![CDATA[echo -n '<metadata>';]]>
<![CDATA[echo -n '<description>';]]>
exiv2 "<xsl:value-of select="@src"/>" | <![CDATA[perl -ne 'if (/Exif comment\s*:\s*(.*)/) { print "$1"; }' ]]> | <m:escape-xml/>
<![CDATA[echo -n '</description>';]]>
<![CDATA[echo -n '</metadata>';]]>
</m:skript>
</xsl:variable>
<xsl:variable name="scriptResult">
<xsl:apply-templates select="$script/node()"/>
</xsl:variable>
<p class="img-container">
<!--
TODO: check whether the thumbnail exists and if yes, disply it and link to the full image.
-->
<a href="{@src}">
<img src="{@src}"
alt ="{$scriptResult/h:metadata/h:description}"
title="{$scriptResult/h:metadata/h:description}"/>
</a>
</p>
</xsl:template>
</xsl:stylesheet>