root/šablona/makra/odkazy.xsl @ 87:25dec6931f18

Revision 87:25dec6931f18, 6.1 KB (checked in by František Kučera <franta-hg@…>, 12 years ago)

Lepší odsazení, tabulátory.

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"
[66]22        xmlns:xs="http://www.w3.org/2001/XMLSchema"
[51]23        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
[66]24        exclude-result-prefixes="m 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
[66]44        <xsl:variable name="tracURL" select="'https://trac.frantovo.cz/xml-web-generator'"/>   
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>
99       
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>
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>
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>
170       
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>
187       
188       
189        <xsl:template name="vložOdkaz">
190                <xsl:param name="url"/>
191                <a>
[66]192                        <!-- Zachováme pouze povolené atributy: -->
193                       
194                        <xsl:copy-of select="@charset"/>
195                        <xsl:copy-of select="@coords"/>
196                        <xsl:copy-of select="@hreflang"/>
197                        <xsl:copy-of select="@name"/>
198                        <xsl:copy-of select="@rel"/>
199                        <xsl:copy-of select="@rev"/>
200                        <xsl:copy-of select="@shape"/>
201                        <xsl:copy-of select="@target"/> <!-- Pozor: nepatří do striktního XHTML -->
202                       
203                        <xsl:copy-of select="@accesskey"/>
204                        <xsl:copy-of select="@class"/>
205                        <xsl:copy-of select="@dir"/>
206                        <xsl:copy-of select="@id"/>
207                        <xsl:copy-of select="@lang"/>
208                        <xsl:copy-of select="@style"/>
209                        <xsl:copy-of select="@tabindex"/>
210                        <xsl:copy-of select="@title"/>
211                        <xsl:copy-of select="@xml:lang"/>
212                       
213                        <xsl:copy-of select="@onblur"/>
214                        <xsl:copy-of select="@onclick"/>
215                        <xsl:copy-of select="@ondblclick"/>
216                        <xsl:copy-of select="@onfocus"/>
217                        <xsl:copy-of select="@onmousedown"/>
218                        <xsl:copy-of select="@onmousemove"/>
219                        <xsl:copy-of select="@onmouseout"/>
220                        <xsl:copy-of select="@onmouseover"/>
221                        <xsl:copy-of select="@onmouseup"/>
222                        <xsl:copy-of select="@onkeydown"/>
223                        <xsl:copy-of select="@onkeypress"/>
224                        <xsl:copy-of select="@onkeyup"/>
225                       
[53]226                        <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
227                        <xsl:apply-templates/>
[54]228                </a>
[53]229        </xsl:template>
230
[51]231</xsl:stylesheet>
[87]232
Note: See TracBrowser for help on using the browser.