generate navigation html from xml
[cmcms:cmcms.git] / src / page.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3
4 cmcms == CMCMS Content Management System
5 Copyright (C) 2008,2009,2010  Claude Heiland-Allen <claudiusmaximus@goto10.org>
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Affero 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 Affero General Public License for more details.
16
17 You should have received a copy of the GNU Affero General Public License
18 along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 -->
21 <xsl:stylesheet version="1.0"
22  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
23  xmlns="http://www.w3.org/1999/xhtml">
24 <xsl:output method="xml" indent="no" encoding="UTF-8"
25  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
26  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
27 <xsl:param name="SITENAME" />
28 <xsl:param name="HEADER" />
29 <xsl:param name="FOOTER" />
30 <xsl:param name="NAVIGATION" />
31 <xsl:param name="PAGE" />
32 <xsl:template match="/">
33 <xsl:apply-templates select="pages/page[file=$PAGE]" />
34 </xsl:template>
35 <xsl:template match="page">
36 <xsl:variable name="top" select="/" />
37 <html xml:lang="en" lang="en">
38 <head>
39 <title><xsl:value-of select="title" /> :: <xsl:value-of select="$SITENAME" /></title>
40 <link rel="stylesheet" type="text/css" href="cmcms.css" title="cmcms" />
41 <link rel="alternate stylesheet" type="text/css" href="print.css" title="print" />
42 </head>
43 <body>
44 <div class="top">
45 <xsl:copy-of select="document($HEADER)" />
46 <div class="main">
47 <h2 class="title"><xsl:value-of select="title" /></h2>
48 <xsl:apply-templates select="document($NAVIGATION)/navigation" />
49 <div class="content"><xsl:apply-templates select="content/node()" /></div>
50 </div>
51 </div>
52 <xsl:copy-of select="document($FOOTER)" />
53 </body>
54 </html>
55 </xsl:template>
56 <xsl:template match="@*|node()">
57 <xsl:choose>
58 <xsl:when test="@class='gallery'">
59 <xsl:copy-of select="document(concat('gallery_', node(), '.xml'))" />
60 </xsl:when><xsl:otherwise>
61 <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
62 </xsl:otherwise>
63 </xsl:choose>
64 </xsl:template>
65 <xsl:template match="navigation">
66 <ul class="navigation">
67 <xsl:for-each select="by-date"><li><ul class="by-date">
68 <xsl:for-each select="later[.!='']"><li class="later"><a href="{.}.html" title="later">↑</a></li></xsl:for-each>
69 <xsl:for-each select="date"><li class="date"><xsl:value-of select="." /></li></xsl:for-each>
70 <xsl:for-each select="earlier[.!='']"><li class="earlier"><a href="{.}.html" title="earlier">↓</a></li></xsl:for-each>
71 </ul></li></xsl:for-each>
72 <xsl:for-each select="by-tag"><li><ul class="by-tag">
73 <xsl:for-each select="later[.!='']"><li class="later"><a href="{.}.html" title="later">↑</a></li></xsl:for-each>
74 <xsl:for-each select="tag"><li class="tag"><a href="{.}.html" title="{.}"><xsl:value-of select="." /></a></li></xsl:for-each>
75 <xsl:for-each select="earlier[.!='']"><li class="earlier"><a href="{.}.html" title="earlier">↓</a></li></xsl:for-each>
76 </ul></li></xsl:for-each>
77 </ul>
78 </xsl:template>
79 </xsl:stylesheet>