]> git.draconx.ca Git - homepage.git/blob - layouts/default.xsl
Add links from generated pages to source code on gitweb.
[homepage.git] / layouts / default.xsl
1 <?xml version='1.0' encoding='UTF-8' ?>
2 <!--
3   Nick's web site: Final XHTML output stage
4
5   Copyright © 2018 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   doctype-public='-//W3C//DTD XHTML 1.1//EN'
28   doctype-system='http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd' />
29 <xsl:strip-space elements='*' />
30
31 <xsl:param name='source-uri'
32   select='"//git.draconx.ca/gitweb/homepage.git/blob/"' />
33 <xsl:param name='site-title' select='"The Citrine Citadel"' />
34
35 <xsl:template match='node()|@*'>
36   <xsl:copy><xsl:apply-templates select='node()|@*' /></xsl:copy>
37 </xsl:template>
38
39 <xsl:template match='source'>
40   <p>
41     <xsl:text>This document was compiled from </xsl:text>
42     <a href='{concat($source-uri, revision, ":", file)}'>
43       <xsl:value-of select='file' />
44     </a>
45     <xsl:text> on </xsl:text>
46     <xsl:value-of select='compiletime' />
47     <xsl:text>.</xsl:text>
48   </p>
49 </xsl:template>
50
51 <xsl:template match='/'>
52   <html>
53     <head>
54       <meta name='viewport' content='width=device-width, initial-scale=1' />
55       <link rel='stylesheet' type='text/css' href='/style.css' />
56       <title>
57         <xsl:variable name='page-title' select='string(/document/title)' />
58         <xsl:if test='$page-title and $site-title != $page-title'>
59           <xsl:value-of select='concat($page-title, " – ")' />
60         </xsl:if>
61         <xsl:value-of select='$site-title' />
62       </title>
63     </head>
64     <body>
65       <xsl:apply-templates select='/document/xhtml:html/@*' />
66       <xsl:apply-templates select='/document/xhtml:html/node()' />
67
68       <div id='footer'>
69         <xsl:apply-templates select='/document/source' />
70       </div>
71     </body>
72   </html>
73 </xsl:template>
74
75 </xsl:stylesheet>