|
1 <?xml version="1.0" encoding="UTF-8"?> |
|
2 <xsl:stylesheet version="2.0" |
|
3 xmlns="http://www.w3.org/1999/xhtml" |
|
4 xmlns:h="http://www.w3.org/1999/xhtml" |
|
5 xmlns:s="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" |
|
6 xmlns:k="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/konfigurace" |
|
7 xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro" |
|
8 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
9 xmlns:fn="http://www.w3.org/2005/xpath-functions" |
|
10 xmlns:svg="http://www.w3.org/2000/svg" |
|
11 xmlns:xs="http://www.w3.org/2001/XMLSchema" |
|
12 exclude-result-prefixes="fn h s k m xs"> |
|
13 |
|
14 <!-- |
|
15 Images |
|
16 ****** |
|
17 Generates an XHTML img tag in a paragraph for given image. |
|
18 Title and Alt are filled with the EXIF comment field. |
|
19 Requires a command line tool: exiv2 |
|
20 * |
|
21 @src path to the image file relative to the input directory (where web.conf resides) |
|
22 --> |
|
23 <xsl:template match="m:img"> |
|
24 <xsl:variable name="script"> |
|
25 <m:skript jazyk="bash" výstup="xml"> |
|
26 DIR=$(dirname "$XWG_STRANKA_SOUBOR"); |
|
27 DIR="$DIR/../vstup" |
|
28 cd "$DIR"; |
|
29 |
|
30 <![CDATA[echo -n '<metadata>';]]> |
|
31 |
|
32 <![CDATA[echo -n '<description>';]]> |
|
33 exiv2 "<xsl:value-of select="@src"/>" | <![CDATA[perl -ne 'if (/Exif comment\s*:\s*(.*)/) { print "$1"; }' ]]> | <m:escape-xml/> |
|
34 <![CDATA[echo -n '</description>';]]> |
|
35 |
|
36 <![CDATA[echo -n '</metadata>';]]> |
|
37 </m:skript> |
|
38 </xsl:variable> |
|
39 |
|
40 <xsl:variable name="scriptResult"> |
|
41 <xsl:apply-templates select="$script/node()"/> |
|
42 </xsl:variable> |
|
43 |
|
44 <p> |
|
45 <!-- |
|
46 TODO: check whether the thumbnail exists and if yes, disply it and link to the full image. |
|
47 --> |
|
48 <a href="{@src}"> |
|
49 <img src="{@src}" |
|
50 alt ="{$scriptResult/h:metadata/h:description}" |
|
51 title="{$scriptResult/h:metadata/h:description}"/> |
|
52 </a> |
|
53 </p> |
|
54 |
|
55 </xsl:template> |
|
56 |
|
57 </xsl:stylesheet> |
|
58 |