root/šablona/stránka-společné.xsl @ 132:1b16c8828fc0

Revision 132:1b16c8828fc0, 5.8 KB (checked in by František Kučera <franta-hg@…>, 11 years ago)

zaostalé prohlížeče: textarea

Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3XML Web generátor – program na generování webových stránek
4Copyright © 2012 František Kučera (frantovo.cz)
5
6This program is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program.  If not, see <http://www.gnu.org/licenses/>.
18-->
19<xsl:stylesheet version="2.0"
20        xmlns="http://www.w3.org/1999/xhtml"
21        xmlns:h="http://www.w3.org/1999/xhtml"
22        xmlns:s="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
23        xmlns:k="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/konfigurace"
24        xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
25        xmlns:j="java:cz.frantovo.xmlWebGenerator.Funkce"
26        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27        xmlns:fn="http://www.w3.org/2005/xpath-functions"
28        xmlns:svg="http://www.w3.org/2000/svg"
29        xmlns:xs="http://www.w3.org/2001/XMLSchema"
30        exclude-result-prefixes="fn h s k m j xs">
31       
32        <xsl:param name="vstup" select="'../vstup/'"/>
33        <xsl:param name="výstup" select="'../výstup/'"/>
34        <xsl:param name="vstupníPřípona" select="'.xml'"/>
35        <xsl:param name="výstupníPřípona" select="'.xhtml'"/>
36        <xsl:param name="vsuvkováPřípona" select="'.inc'"/>
37        <xsl:param name="podporaZaostalýchProhlížečů" select="false()" as="xs:boolean"/>
38       
39        <xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/>
40       
41        <xsl:include href=".makra-seznam.xsl"/>
42       
43        <!--
44                Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace:
45        -->
46        <xsl:template match="*">
47                <xsl:element name="{name()}">
48                        <xsl:copy-of select="@*"/>
49                        <xsl:apply-templates/>
50                </xsl:element>
51        </xsl:template>
52
53        <!--
54                Varování pro případ, že jsme v režimu podpory pro zaostalé prohlížeče
55        -->
56        <xsl:template name="varováníRetardace">
57                <xsl:if test="$podporaZaostalýchProhlížečů">
58                        <xsl:comment>PZP</xsl:comment>
59                </xsl:if>
60        </xsl:template>
61       
62        <xsl:template name="varováníRetardaceDlouhé">
63                <xsl:if test="$podporaZaostalýchProhlížečů">
64                        <xsl:comment>
65                                Generátor byl spuštěn v režimu podpory zaostalých prohlížečů (PZP).
66                                Uživatelům doporučujeme upgrade na skutečný WWW prohlížeč,
67                                jako je např. GNU IceCat, Firefox nebo rekonq.
68                        </xsl:comment>
69                </xsl:if>
70        </xsl:template>
71       
72        <xsl:template match="h:textarea">
73                <xsl:element name="{name()}">
74                        <xsl:copy-of select="@*"/>
75                        <xsl:call-template name="varováníRetardace"/>
76                        <xsl:apply-templates/>
77                </xsl:element>
78        </xsl:template>
79
80        <!--
81                Odkazy na JavaScript a kaskádové styly
82        -->
83        <xsl:template match="k:web/k:js">
84                <script src="{text()}" type="text/javascript">
85                        <xsl:call-template name="varováníRetardace"/>
86                </script>
87        </xsl:template>
88        <xsl:template match="k:web/k:css">
89                <link href="{text()}" type="text/css" rel="StyleSheet" />
90        </xsl:template>
91       
92        <!--
93                Metainformace o autorovi a popisu stránky
94        -->
95        <xsl:template match="k:web/k:autor/k:jméno">
96                <meta content="{text()}" name="author"/>
97        </xsl:template>
98        <xsl:template match="s:stránka/s:perex">
99                <meta content="{text()}" name="description"/>
100        </xsl:template>
101        <xsl:template match="s:stránka/s:klíčováSlova">
102                <xsl:element name="meta">
103                        <xsl:attribute name="content">
104                                <xsl:for-each select="s:slovo">
105                                        <xsl:value-of select="text()"/>
106                                        <xsl:if test="not(position() = last())">, </xsl:if>
107                                </xsl:for-each>
108                        </xsl:attribute>
109                        <xsl:attribute name="name">keywords</xsl:attribute>
110                </xsl:element>
111        </xsl:template>
112
113        <!--
114                Vloží nečíslovaný seznam obsahující hlavní nabídku webu (seznam stránek)
115                Pro potřeby CSS stylování má nabídka @id='nabídka'
116        -->
117        <xsl:template name="vložNabídku">
118                <ul id="nabídka">
119                        <xsl:for-each select="collection(concat('./', $vstup ,'/?select=*', $vstupníPřípona))[s:stránka/s:pořadí]">
120                                <xsl:sort select="empty(./s:stránka/s:pořadí)"/>
121                                <xsl:sort select="./s:stránka/s:pořadí"/>
122                                <li>
123                                        <xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/>
124                                        <xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, $vstupníPřípona, $výstupníPřípona)"/>
125                                        <a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./s:stránka/s:nadpis"/></a>
126                                </li>
127                        </xsl:for-each>
128                </ul>
129        </xsl:template>
130
131        <!--
132                Vloží záhlaví (společné pro všechny stránky)
133                Pro potřeby CSS stylování má @id='záhlaví'
134        -->
135        <xsl:template name="vložZáhlaví">
136                <div id="záhlaví">
137                        <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'záhlaví', $vsuvkováPřípona)))/s:stránka/h:text/node()"/>
138                </div>
139        </xsl:template>
140
141        <!--
142                Vloží zápatí (společné pro všechny stránky)
143                Pro potřeby CSS stylování má @id='zápatí'
144        -->
145        <xsl:template name="vložZápatí">
146                <div id="zápatí">
147                        <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'zápatí', $vsuvkováPřípona)))/s:stránka/h:text/node()"/>
148                </div>
149        </xsl:template>
150
151        <!--
152                Vrací cestu v URL kódování, ale lomítka nekóduje
153        -->
154        <xsl:function name="m:escapuj-url-zachovej-lomítka" as="xs:string">
155                <xsl:param name="cesta"/>
156                <xsl:value-of select="replace(encode-for-uri($cesta), '%2F', '/')"/>
157        </xsl:function>
158
159        <!--
160                Vrací obsah textového souboru ve vstupním adresáři.
161                Obvykle jako parametr předáváme atribut „src“.
162        -->
163        <xsl:function name="m:načti-textový-soubor" as="xs:string">
164                <xsl:param name="soubor"/>
165                <xsl:value-of select="unparsed-text(concat($vstup, $soubor))"/>
166        </xsl:function>
167
168</xsl:stylesheet>
169
Note: See TracBrowser for help on using the browser.