root/šablona/makra/odkazy.xsl @ 61:9503eb8377f1

Revision 61:9503eb8377f1, 4.0 KB (checked in by František Kučera <franta-hg@…>, 12 years ago)

Licence: informace o licenci v každém souboru.

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                Seznam.cz
97                *********
98                Vyhledávání pomocí Seznamu
99                *
100                @href náš dotaz
101        -->
102        <xsl:template match="m:a[@typ='seznam']">
103                <xsl:call-template name="vložOdkaz">
104                        <xsl:with-param name="url" select="
105                                concat(
106                                        'http://search.seznam.cz/?q=',
107                                        encode-for-uri(@href)
108                                )"/>
109                </xsl:call-template>
110        </xsl:template>
111
112        <!--
113                Google.com
114                **********
115                Vyhledávání pomocí Googlu
116                *
117                @href náš dotaz
118        -->
119        <xsl:template match="m:a[@typ='google']">
120                <xsl:call-template name="vložOdkaz">
121                        <xsl:with-param name="url" select="
122                                concat(
123                                        'https://encrypted.google.com/search?q=',
124                                        encode-for-uri(@href)
125                                )"/>
126                </xsl:call-template>   
127        </xsl:template>
128       
129        <!--
130                Request for comments
131                ********************
132                Internetové standardy – RFC
133                *
134                @href číslo RFCčka
135        -->
136        <xsl:template match="m:a[@typ='rfc' and number(@href)]">
137                <xsl:call-template name="vložOdkaz">
138                        <xsl:with-param name="url" select="
139                                concat(
140                                        'https://tools.ietf.org/html/rfc',
141                                        @href
142                                )"/>
143                </xsl:call-template>
144        </xsl:template>
145       
146       
147        <xsl:template name="vložOdkaz">
148                <xsl:param name="url"/>
149                <a>
150                        <xsl:copy-of select="@*"/>
151                        <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
152                        <xsl:apply-templates/>
153                </a>
154        </xsl:template>
155
156</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.