root/šablona/makra/odkazy.xsl @ 136:d5feb9d8ebc3

Revision 136:d5feb9d8ebc3, 7.2 KB (checked in by František Kučera <franta-hg@…>, 5 years ago)

fix license version: GNU GPLv3

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