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