root/šablona/makra/odkazy.xsl @ 98:532deb4b908e

Revision 98:532deb4b908e, 7.2 KB (checked in by František Kučera <franta-hg@…>, 12 years ago)

drobnosti

RevLine 
[51]1<?xml version="1.0" encoding="UTF-8"?>
[61]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-->
[51]19<xsl:stylesheet version="2.0"
20        xmlns="http://www.w3.org/1999/xhtml"
21        xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
[93]22        xmlns:k="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/konfigurace"
[66]23        xmlns:xs="http://www.w3.org/2001/XMLSchema"
[51]24        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
[93]25        exclude-result-prefixes="m k xs">
[53]26
27        <!--
[54]28                Interní odkazy
29                **************
30                Slouží k vkládání odkazů na jiné stránky v rámci webu.
[53]31                *
32                @href zadáváme jen název souboru bez přípony – s nezakódovanou češtinou a s mezerami
[54]33                @typ nevyplňujeme
[53]34        -->
[54]35        <xsl:template match="m:a[not(@typ)]">
[53]36                <a>
37                        <xsl:copy-of select="@*"/>
38                        <xsl:attribute name="href">
39                                <xsl:value-of select="encode-for-uri(concat(@href, $výstupníPřípona))"/>
40                        </xsl:attribute>
41                        <xsl:apply-templates/>
42                </a>
43        </xsl:template>
44
[98]45        <xsl:variable name="tracURL" select="'https://trac.frantovo.cz/xml-web-generator'"/>
[66]46
[53]47        <!--
48                Trac – wiki
49                ***********
50                Odkazy na Trac našeho generátoru.
[56]51                *
[53]52                @href nečíselné parametry vedou do wiki
53        -->
54        <xsl:template match="m:a[@typ='trac' and not(number(@href))]">
55                <xsl:call-template name="vložOdkaz">
56                        <xsl:with-param name="url" select="
57                                concat(
[66]58                                        $tracURL, '/wiki/',
59                                        m:escapuj-url-zachovej-lomítka(@href)
[53]60                                )"/>
61                </xsl:call-template>           
62        </xsl:template>
[66]63
[53]64        <!--
65                Trac – úkoly
66                ************
67                Odkazy na Trac našeho generátoru.
[56]68                *
[53]69                @href číselné parametry vedou na úkoly
70        -->
71        <xsl:template match="m:a[@typ='trac' and number(@href)]">
72                <xsl:call-template name="vložOdkaz">
73                        <xsl:with-param name="url" select="
74                                concat(
[66]75                                        $tracURL, '/ticket/',
[53]76                                        @href
77                                )"/>
78                </xsl:call-template>
79        </xsl:template>
80
[54]81        <!--
[66]82                Zdroják
83                *******
84                Odkazy zdrojový kód našeho generátoru.
85                *
86                @href název souboru
87                @řádek číslo řádku (volitelně)
88        -->
89        <xsl:template match="m:a[@typ='zdroják' and (not(@řádek) or number(@řádek))]">
90                <xsl:call-template name="vložOdkaz">
91                        <xsl:with-param name="url" select="
92                                concat(
93                                        $tracURL, '/browser/',
94                                        m:escapuj-url-zachovej-lomítka(@href),
95                                        '#L',
96                                        (@řádek,'1')[1]
97                                )"/>
98                </xsl:call-template>
99        </xsl:template>
[93]100
[66]101        <!--
[54]102                Wikipedia
[56]103                *********
[63]104                Stránka v encyklopedii.
[56]105                *
[54]106                @href název stránky
107                @jazyk kód jazyka (výchozí je čeština)
108        -->
109        <xsl:template match="m:a[@typ='wiki']">
110                <xsl:call-template name="vložOdkaz">
111                        <xsl:with-param name="url" select="
112                                concat(
113                                        'https://secure.wikimedia.org/wikipedia/', (@jazyk,'cs')[1], '/wiki/',
[81]114                                        m:escapuj-url-zachovej-lomítka(@href)
[54]115                                )"/>
116                </xsl:call-template>
117        </xsl:template>
[93]118
[63]119        <!--
120                Javadoc
121                *******
122                Dokumentace k javovským třídám.
123                *
124                @href jméno třídy včetně balíčku – např. java.lang.String
125                @verze verze Javy, výchozí: 7
126        -->
127        <xsl:template match="m:a[@typ='javadoc']">
128                <xsl:call-template name="vložOdkaz">
129                        <xsl:with-param name="url" select="
130                                concat(
131                                        'http://docs.oracle.com/javase/', (@verze,'7')[1], '/docs/api/',
132                                        replace(@href, '\.', '/'),
133                                        '.html'
134                                )"/>
135                </xsl:call-template>
136        </xsl:template>
[93]137
[53]138        <!--
139                Seznam.cz
140                *********
[63]141                Vyhledávání pomocí Seznamu.
[56]142                *
[54]143                @href náš dotaz
[53]144        -->
145        <xsl:template match="m:a[@typ='seznam']">
146                <xsl:call-template name="vložOdkaz">
[54]147                        <xsl:with-param name="url" select="
148                                concat(
149                                        'http://search.seznam.cz/?q=',
150                                        encode-for-uri(@href)
151                                )"/>
[53]152                </xsl:call-template>
153        </xsl:template>
154
155        <!--
156                Google.com
157                **********
[63]158                Vyhledávání pomocí Googlu.
[56]159                *
[54]160                @href náš dotaz
[53]161        -->
162        <xsl:template match="m:a[@typ='google']">
163                <xsl:call-template name="vložOdkaz">
[54]164                        <xsl:with-param name="url" select="
165                                concat(
166                                        'https://encrypted.google.com/search?q=',
167                                        encode-for-uri(@href)
168                                )"/>
[53]169                </xsl:call-template>   
170        </xsl:template>
[93]171
[53]172        <!--
173                Request for comments
174                ********************
[63]175                Internetové standardy – RFC.
[56]176                *
[54]177                @href číslo RFCčka
[53]178        -->
[57]179        <xsl:template match="m:a[@typ='rfc' and number(@href)]">
[53]180                <xsl:call-template name="vložOdkaz">
[54]181                        <xsl:with-param name="url" select="
182                                concat(
183                                        'https://tools.ietf.org/html/rfc',
184                                        @href
185                                )"/>
[53]186                </xsl:call-template>
187        </xsl:template>
[93]188
189        <!--
190                E-mail
191                ******
192                Odkaz na e-mail v „obfuskovaném“ tvaru,
193                aby spamovací roboti nemohli tak snadno sbírat e-mailové adresy z webů.
194                Ale zároveň klikatelný, aby ho uživatel nemusel opisovat (vyžaduje JavaScript).
195                Obsah elementu je nepovinný – pokud chybí, vloží se e-mailová adresa.
196                *
197                @href e-mailová adresa (bez „mailto:“)
198        -->
199        <xsl:template match="m:a[@typ='email']">
200                <xsl:variable name="česky" select="replace(replace(@href, '@', ' zavináč '), '\.', ' tečka ')"/>
201                <xsl:variable name="klíč" select="concat(tokenize($konfigurace/k:web/k:uuid/text(), '-')[1], '9df1')"/>
202                <xsl:variable name="pořadí"><xsl:number level="any"/></xsl:variable>
203                <xsl:variable name="idSpanu" select="concat('c', $klíč, $pořadí)"/>
204                <span title="{text()}" id="{$idSpanu}">
205                        <xsl:value-of select="$česky"/>
206                </span>
207                <span id="{$idSpanu}b" style="display: none">
208                        <xsl:apply-templates/>
209                </span>
210                <script type="text/javascript">
211                        xwg.odkazNaElektronickouPoštu("<xsl:value-of select="$idSpanu"/>");
212                </script>
213        </xsl:template>
214
215
[53]216        <xsl:template name="vložOdkaz">
217                <xsl:param name="url"/>
218                <a>
[66]219                        <!-- Zachováme pouze povolené atributy: -->
220                       
221                        <xsl:copy-of select="@charset"/>
222                        <xsl:copy-of select="@coords"/>
223                        <xsl:copy-of select="@hreflang"/>
224                        <xsl:copy-of select="@name"/>
225                        <xsl:copy-of select="@rel"/>
226                        <xsl:copy-of select="@rev"/>
227                        <xsl:copy-of select="@shape"/>
228                        <xsl:copy-of select="@target"/> <!-- Pozor: nepatří do striktního XHTML -->
229                       
230                        <xsl:copy-of select="@accesskey"/>
231                        <xsl:copy-of select="@class"/>
232                        <xsl:copy-of select="@dir"/>
233                        <xsl:copy-of select="@id"/>
234                        <xsl:copy-of select="@lang"/>
235                        <xsl:copy-of select="@style"/>
236                        <xsl:copy-of select="@tabindex"/>
237                        <xsl:copy-of select="@title"/>
238                        <xsl:copy-of select="@xml:lang"/>
239                       
240                        <xsl:copy-of select="@onblur"/>
241                        <xsl:copy-of select="@onclick"/>
242                        <xsl:copy-of select="@ondblclick"/>
243                        <xsl:copy-of select="@onfocus"/>
244                        <xsl:copy-of select="@onmousedown"/>
245                        <xsl:copy-of select="@onmousemove"/>
246                        <xsl:copy-of select="@onmouseout"/>
247                        <xsl:copy-of select="@onmouseover"/>
248                        <xsl:copy-of select="@onmouseup"/>
249                        <xsl:copy-of select="@onkeydown"/>
250                        <xsl:copy-of select="@onkeypress"/>
251                        <xsl:copy-of select="@onkeyup"/>
252                       
[53]253                        <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
254                        <xsl:apply-templates/>
[54]255                </a>
[53]256        </xsl:template>
257
[51]258</xsl:stylesheet>
[87]259
Note: See TracBrowser for help on using the browser.