root/šablona/makra/odkazy.xsl @ 63:75ee09ccc0ec

Revision 63:75ee09ccc0ec, 4.4 KB (checked in by František Kučera <franta-hg@…>, 12 years ago)

Odkazy #16: podpora odkazů na Javadoc.

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:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
22        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
23        exclude-result-prefixes="m">
24
25        <!--
26                Interní odkazy
27                **************
28                Slouží k vkládání odkazů na jiné stránky v rámci webu.
29                *
30                @href zadáváme jen název souboru bez přípony – s nezakódovanou češtinou a s mezerami
31                @typ nevyplňujeme
32        -->
33        <xsl:template match="m:a[not(@typ)]">
34                <a>
35                        <xsl:copy-of select="@*"/>
36                        <xsl:attribute name="href">
37                                <xsl:value-of select="encode-for-uri(concat(@href, $výstupníPřípona))"/>
38                        </xsl:attribute>
39                        <xsl:apply-templates/>
40                </a>
41        </xsl:template>
42
43        <!--
44                Trac – wiki
45                ***********
46                Odkazy na Trac našeho generátoru.
47                *
48                @href nečíselné parametry vedou do wiki
49        -->
50        <xsl:template match="m:a[@typ='trac' and not(number(@href))]">
51                <xsl:call-template name="vložOdkaz">
52                        <xsl:with-param name="url" select="
53                                concat(
54                                        'https://trac.frantovo.cz/xml-web-generator/wiki/',
55                                        replace(encode-for-uri(@href), '%2F', '/')
56                                )"/>
57                </xsl:call-template>           
58        </xsl:template>
59       
60        <!--
61                Trac – úkoly
62                ************
63                Odkazy na Trac našeho generátoru.
64                *
65                @href číselné parametry vedou na úkoly
66        -->
67        <xsl:template match="m:a[@typ='trac' and number(@href)]">
68                <xsl:call-template name="vložOdkaz">
69                        <xsl:with-param name="url" select="
70                                concat(
71                                        'https://trac.frantovo.cz/xml-web-generator/ticket/',
72                                        @href
73                                )"/>
74                </xsl:call-template>
75        </xsl:template>
76
77        <!--
78                Wikipedia
79                *********
80                Stránka v encyklopedii.
81                *
82                @href název stránky
83                @jazyk kód jazyka (výchozí je čeština)
84        -->
85        <xsl:template match="m:a[@typ='wiki']">
86                <xsl:call-template name="vložOdkaz">
87                        <xsl:with-param name="url" select="
88                                concat(
89                                        'https://secure.wikimedia.org/wikipedia/', (@jazyk,'cs')[1], '/wiki/',
90                                        encode-for-uri(@href)
91                                )"/>
92                </xsl:call-template>
93        </xsl:template>
94       
95        <!--
96                Javadoc
97                *******
98                Dokumentace k javovským třídám.
99                *
100                @href jméno třídy včetně balíčku – např. java.lang.String
101                @verze verze Javy, výchozí: 7
102        -->
103        <xsl:template match="m:a[@typ='javadoc']">
104                <xsl:call-template name="vložOdkaz">
105                        <xsl:with-param name="url" select="
106                                concat(
107                                        'http://docs.oracle.com/javase/', (@verze,'7')[1], '/docs/api/',
108                                        replace(@href, '\.', '/'),
109                                        '.html'
110                                )"/>
111                </xsl:call-template>
112        </xsl:template>
113       
114        <!--
115                Seznam.cz
116                *********
117                Vyhledávání pomocí Seznamu.
118                *
119                @href náš dotaz
120        -->
121        <xsl:template match="m:a[@typ='seznam']">
122                <xsl:call-template name="vložOdkaz">
123                        <xsl:with-param name="url" select="
124                                concat(
125                                        'http://search.seznam.cz/?q=',
126                                        encode-for-uri(@href)
127                                )"/>
128                </xsl:call-template>
129        </xsl:template>
130
131        <!--
132                Google.com
133                **********
134                Vyhledávání pomocí Googlu.
135                *
136                @href náš dotaz
137        -->
138        <xsl:template match="m:a[@typ='google']">
139                <xsl:call-template name="vložOdkaz">
140                        <xsl:with-param name="url" select="
141                                concat(
142                                        'https://encrypted.google.com/search?q=',
143                                        encode-for-uri(@href)
144                                )"/>
145                </xsl:call-template>   
146        </xsl:template>
147       
148        <!--
149                Request for comments
150                ********************
151                Internetové standardy – RFC.
152                *
153                @href číslo RFCčka
154        -->
155        <xsl:template match="m:a[@typ='rfc' and number(@href)]">
156                <xsl:call-template name="vložOdkaz">
157                        <xsl:with-param name="url" select="
158                                concat(
159                                        'https://tools.ietf.org/html/rfc',
160                                        @href
161                                )"/>
162                </xsl:call-template>
163        </xsl:template>
164       
165       
166        <xsl:template name="vložOdkaz">
167                <xsl:param name="url"/>
168                <a>
169                        <xsl:copy-of select="@*"/>
170                        <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
171                        <xsl:apply-templates/>
172                </a>
173        </xsl:template>
174
175</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.