šablona/makra/odkazy.xsl
author František Kučera <franta-hg@frantovo.cz>
Sat, 07 Jan 2012 01:08:24 +0100
changeset 54 15c66c9048f2
parent 53 7403128a8e0a
child 56 24e50902b58e
permissions -rw-r--r--
Odkazy #16: podpora Wikipedie
coalesce :-)
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <xsl:stylesheet version="2.0"
     3 	xmlns="http://www.w3.org/1999/xhtml"
     4 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
     5 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     6 	exclude-result-prefixes="m">
     7 
     8 	<!--
     9 		Interní odkazy
    10 		**************
    11 		Slouží k vkládání odkazů na jiné stránky v rámci webu.
    12 		*
    13 		@href zadáváme jen název souboru bez přípony – s nezakódovanou češtinou a s mezerami
    14 		@typ nevyplňujeme
    15 	-->
    16 	<xsl:template match="m:a[not(@typ)]">
    17 		<a>
    18 			<xsl:copy-of select="@*"/>
    19 			<xsl:attribute name="href">
    20 				<xsl:value-of select="encode-for-uri(concat(@href, $výstupníPřípona))"/>
    21 			</xsl:attribute>
    22 			<xsl:apply-templates/>
    23 		</a>
    24 	</xsl:template>
    25 
    26 	<!--
    27 		Trac – wiki
    28 		***********
    29 		Odkazy na Trac našeho generátoru.
    30 		@href nečíselné parametry vedou do wiki
    31 	-->
    32 	<xsl:template match="m:a[@typ='trac' and not(number(@href))]">
    33 		<xsl:call-template name="vložOdkaz">
    34 			<xsl:with-param name="url" select="
    35 				concat(
    36 					'https://trac.frantovo.cz/xml-web-generator/wiki/', 
    37 					replace(encode-for-uri(@href), '%2F', '/')
    38 				)"/>
    39 		</xsl:call-template>		
    40 	</xsl:template>
    41 	
    42 	<!--
    43 		Trac – úkoly
    44 		************
    45 		Odkazy na Trac našeho generátoru.
    46 		@href číselné parametry vedou na úkoly
    47 	-->
    48 	<xsl:template match="m:a[@typ='trac' and number(@href)]">
    49 		<xsl:call-template name="vložOdkaz">
    50 			<xsl:with-param name="url" select="
    51 				concat(
    52 					'https://trac.frantovo.cz/xml-web-generator/ticket/', 
    53 					@href
    54 				)"/>
    55 		</xsl:call-template>
    56 	</xsl:template>
    57 
    58 	<!--
    59 		Wikipedia
    60 		************
    61 		Stránka v encyklopedii 
    62 		@href název stránky
    63 		@jazyk kód jazyka (výchozí je čeština)
    64 	-->
    65 	<xsl:template match="m:a[@typ='wiki']">
    66 		<xsl:call-template name="vložOdkaz">
    67 			<xsl:with-param name="url" select="
    68 				concat(
    69 					'https://secure.wikimedia.org/wikipedia/', (@jazyk,'cs')[1], '/wiki/', 
    70 					encode-for-uri(@href)
    71 				)"/>
    72 		</xsl:call-template>
    73 	</xsl:template>
    74 	
    75 	<!-- 
    76 		Seznam.cz
    77 		*********
    78 		Vyhledávání pomocí Seznamu
    79 		@href náš dotaz
    80 	-->
    81 	<xsl:template match="m:a[@typ='seznam']">
    82 		<xsl:call-template name="vložOdkaz">
    83 			<xsl:with-param name="url" select="
    84 				concat(
    85 					'http://search.seznam.cz/?q=', 
    86 					encode-for-uri(@href)
    87 				)"/>
    88 		</xsl:call-template>
    89 	</xsl:template>
    90 
    91 	<!-- 
    92 		Google.com
    93 		**********
    94 		Vyhledávání pomocí Googlu
    95 		@href náš dotaz
    96 	-->
    97 	<xsl:template match="m:a[@typ='google']">
    98 		<xsl:call-template name="vložOdkaz">
    99 			<xsl:with-param name="url" select="
   100 				concat(
   101 					'https://encrypted.google.com/search?q=', 
   102 					encode-for-uri(@href)
   103 				)"/>
   104 		</xsl:call-template>	
   105 	</xsl:template>
   106 	
   107 	<!-- 
   108 		Request for comments
   109 		********************
   110 		Internetové standardy – RFC
   111 		@href číslo RFCčka
   112 	-->
   113 	<xsl:template match="m:a[@typ='rfc']">
   114 		<xsl:call-template name="vložOdkaz">
   115 			<xsl:with-param name="url" select="
   116 				concat(
   117 					'https://tools.ietf.org/html/rfc',
   118 					@href
   119 				)"/>
   120 		</xsl:call-template>
   121 	</xsl:template>
   122 	
   123 	
   124 	<xsl:template name="vložOdkaz">
   125 		<xsl:param name="url"/>
   126 		<a>
   127 			<xsl:copy-of select="@*"/>
   128 			<xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
   129 			<xsl:apply-templates/>
   130 		</a>
   131 	</xsl:template>
   132 
   133 </xsl:stylesheet>