]> git.draconx.ca Git - homepage.git/blob - layouts/imginfo.xsl
Solar Eclipse in Ottawa on 2021-06-10.
[homepage.git] / layouts / imginfo.xsl
1 <?xml version='1.0' encoding='UTF-8' ?>
2 <!--
3   Nick's web site: Image description page formatter
4
5   Copyright © 2020 Nick Bowler
6
7   This program is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with this program.  If not, see <https://www.gnu.org/licenses/>
19 -->
20 <xsl:stylesheet version='1.0'
21   xmlns='http://www.w3.org/1999/xhtml'
22   xmlns:xhtml='http://www.w3.org/1999/xhtml'
23   xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
24   exclude-result-prefixes='xhtml'>
25
26 <xsl:output method='xml' encoding='UTF-8' indent='yes'
27   omit-xml-declaration='yes' />
28
29 <xsl:template match='node()|@*'>
30   <xsl:copy><xsl:apply-templates select='node()|@*' /></xsl:copy>
31 </xsl:template>
32
33 <xsl:template name='exif' mode='exif' match='*'>
34   <xsl:param name='node' select='.' />
35   <xsl:param name='name' select='local-name($node)' />
36
37   <tr>
38     <td><xsl:value-of select='$name' /></td>
39     <td><xsl:value-of select='$node' /></td>
40   </tr>
41 </xsl:template>
42
43 <xsl:template match='exif'>
44   <h2>Metadata</h2>
45   <table>
46     <thead>
47       <tr><th>Attribute</th><th>Value</th></tr>
48     </thead>
49     <tbody>
50       <xsl:apply-templates select='make' mode='exif'>
51         <xsl:with-param name='name' select='"Camera make"' />
52       </xsl:apply-templates>
53       <xsl:apply-templates select='model' mode='exif'>
54         <xsl:with-param name='name' select='"Camera model"' />
55       </xsl:apply-templates>
56       <xsl:apply-templates select='date_time_original' mode='exif'>
57         <xsl:with-param name='name' select='"Date taken"' />
58       </xsl:apply-templates>
59       <xsl:apply-templates select='exposure_time' mode='exif'>
60         <xsl:with-param name='node' select='concat(exposure_time, "s")' />
61         <xsl:with-param name='name' select='"Shutter speed"' />
62       </xsl:apply-templates>
63       <xsl:apply-templates select='f_number' mode='exif'>
64         <xsl:with-param name='node' select='concat("f/", f_number)' />
65         <xsl:with-param name='name' select='"Aperture"' />
66       </xsl:apply-templates>
67       <xsl:apply-templates select='exposure_bias_value' mode='exif'>
68         <xsl:with-param name='name' select='"Exposure compensation"' />
69       </xsl:apply-templates>
70       <xsl:apply-templates select='focal_length' mode='exif'>
71         <xsl:with-param name='node' select='concat(focal_length, "mm")' />
72         <xsl:with-param name='name' select='"Focal length"' />
73       </xsl:apply-templates>
74       <xsl:apply-templates select='flash' mode='exif'>
75         <xsl:with-param name='name' select='"Flash"' />
76       </xsl:apply-templates>
77       <xsl:apply-templates select='iso_speed_ratings' mode='exif'>
78         <xsl:with-param name='name' select='"ISO speed rating"' />
79       </xsl:apply-templates>
80       <xsl:apply-templates select='exposure_program' mode='exif'>
81         <xsl:with-param name='name' select='"Exposure program"' />
82       </xsl:apply-templates>
83       <xsl:apply-templates select='metering_mode' mode='exif'>
84         <xsl:with-param name='name' select='"Metering mode"' />
85       </xsl:apply-templates>
86     </tbody>
87   </table>
88 </xsl:template>
89
90 <xsl:template match='variant'>
91   <li>
92     <a href='{uri}'>
93       <xsl:value-of
94         select='concat(name, " (", width, "x", height, ", ", filesize, ")")' />
95     </a>
96   </li>
97 </xsl:template>
98
99 <xsl:template match='xhtml:description'>
100   <h2 id='desc'>Description</h2>
101   <xsl:choose>
102     <xsl:when test='*'>
103       <xsl:apply-templates select='node()' />
104     </xsl:when>
105     <xsl:otherwise>
106       <p><xsl:apply-templates select='node()' /></p>
107     </xsl:otherwise>
108   </xsl:choose>
109 </xsl:template>
110
111 <xsl:template match='/'>
112   <p>
113     <img src='{/image/variant[1]/uri}' alt=''
114       width='{/image/variant[1]/width}'
115       height='{/image/variant[1]/height}'>
116       <xsl:if test='/image/xhtml:description'>
117         <xsl:attribute name='longdesc'>#desc</xsl:attribute>
118       </xsl:if>
119     </img>
120   </p>
121   <xsl:apply-templates select='/image/xhtml:description' />
122   <h2>Files</h2>
123   <ul>
124     <xsl:apply-templates select='/image/variant'>
125       <xsl:sort select='width*height' order='ascending' data-type='number' />
126     </xsl:apply-templates>
127   </ul>
128   <xsl:apply-templates select='/image/exif' />
129 </xsl:template>
130
131 </xsl:stylesheet>