Changeset 54:15c66c9048f2

Show
Ignore:
Timestamp:
01/07/12 01:08:24 (12 years ago)
Author:
František Kučera <franta-hg@…>
Branch:
default
Message:

Odkazy #16: podpora Wikipedie
coalesce :-)

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • vstup/odkazy.xml

    r53 r54  
    77        <text xmlns="http://www.w3.org/1999/xhtml"> 
    88                 
    9                 <p>Tady jsou nějaké naše odkazy. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mi nisl, tincidunt in viverra vitae, pharetra nec urna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer gravida gravida convallis. Phasellus erat ligula, vestibulum vel commodo ac, fringilla quis lorem. Morbi a massa a ligula tincidunt mattis et et felis. Vivamus a quam nulla, at vulputate nisi. Duis gravida placerat luctus. Phasellus vehicula lobortis arcu vitae hendrerit. Maecenas ut molestie elit. Aliquam erat volutpat. Curabitur sed euismod nisl. Mauris molestie tristique nulla, eu pellentesque sem tincidunt non.</p> 
     9                <p>Tady jsou nějaké naše odkazy. Lorem ipsum dolor sit amet, consectetur adipiscing elit<m:a href="16" typ="trac" style="text-decoration: none;">.</m:a> Sed mi nisl, tincidunt in viverra vitae, pharetra nec urna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer gravida gravida convallis. Phasellus erat ligula, vestibulum vel commodo ac, fringilla quis lorem. Morbi a massa a ligula tincidunt mattis et et felis. Vivamus a quam nulla, at vulputate nisi. Duis gravida placerat luctus. Phasellus vehicula lobortis arcu vitae hendrerit. Maecenas ut molestie elit. Aliquam erat volutpat. Curabitur sed euismod nisl. Mauris molestie tristique nulla, eu pellentesque sem tincidunt non.</p> 
    1010                 
    1111                <ul> 
     
    1414                        <li><m:a href="GNU/Linux a tučňák Tux" typ="google"><abbr title="GNU's Not Unix! – GNU Není Unix!">GNU</abbr>/Linux a tučňák Tux</m:a> – vyhledávání pomocí Googlu</li> 
    1515                        <li><m:a href="1855" typ="rfc"><em>Net</em>iketa</m:a> – internetový standard <abbr title="request for comments">RFC</abbr></li> 
     16                        <li><m:a href="Linus Torvalds" typ="wiki">Linus Torvalds</m:a> – encyklopedie Wikipedia – česky</li> 
     17                        <li><m:a href="Richard Stallman" typ="wiki" jazyk="en">Richard Stallman</m:a> – encyklopedie Wikipedia – anglicky</li> 
    1618                </ul> 
    1719                 
     
    2527<m:a href="GNU/Linux a tučňák Tux" typ="google">GNU/Linux a tučňák Tux</m:a> 
    2628<m:a href="1855" typ="rfc">Netiketa</m:a> 
     29<m:a href="Linus Torvalds" typ="wiki">Linus Torvalds</m:a> 
     30<m:a href="Richard Stallman" typ="wiki" jazyk="en">Richard Stallman</m:a> 
    2731]]></m:pre> 
    2832 
  • šablona/makra/odkazy.xsl

    r53 r54  
    77 
    88        <!-- 
    9                 Odkazy 
    10                 ****** 
    11                 Slouží hlavně k vkládání odkazů na jiné stránky v rámci webu. 
     9                Interní odkazy 
     10                ************** 
     11                Slouží k vkládání odkazů na jiné stránky v rámci webu. 
    1212                * 
    1313                @href zadáváme jen název souboru bez přípony – s nezakódovanou češtinou a s mezerami 
    14                 @typ jiné typy odkazů (výchozí jsou interní odkazy v rámci webu) 
     14                @typ nevyplňujeme 
    1515        --> 
    16         <xsl:template match="m:a"> 
     16        <xsl:template match="m:a[not(@typ)]"> 
    1717                <a> 
    1818                        <xsl:copy-of select="@*"/> 
     
    5656        </xsl:template> 
    5757 
     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         
    5875        <!--  
    5976                Seznam.cz 
    6077                ********* 
    6178                Vyhledávání pomocí Seznamu 
     79                @href náš dotaz 
    6280        --> 
    6381        <xsl:template match="m:a[@typ='seznam']"> 
    6482                <xsl:call-template name="vložOdkaz"> 
    65                         <xsl:with-param name="url" select="concat('http://search.seznam.cz/?q=', encode-for-uri(@href))"/> 
     83                        <xsl:with-param name="url" select=" 
     84                                concat( 
     85                                        'http://search.seznam.cz/?q=',  
     86                                        encode-for-uri(@href) 
     87                                )"/> 
    6688                </xsl:call-template> 
    6789        </xsl:template> 
     
    7193                ********** 
    7294                Vyhledávání pomocí Googlu 
     95                @href náš dotaz 
    7396        --> 
    7497        <xsl:template match="m:a[@typ='google']"> 
    7598                <xsl:call-template name="vložOdkaz"> 
    76                         <xsl:with-param name="url" select="concat('https://encrypted.google.com/search?q=', encode-for-uri(@href))"/> 
     99                        <xsl:with-param name="url" select=" 
     100                                concat( 
     101                                        'https://encrypted.google.com/search?q=',  
     102                                        encode-for-uri(@href) 
     103                                )"/> 
    77104                </xsl:call-template>     
    78105        </xsl:template> 
     
    82109                ******************** 
    83110                Internetové standardy – RFC 
     111                @href číslo RFCčka 
    84112        --> 
    85113        <xsl:template match="m:a[@typ='rfc']"> 
    86114                <xsl:call-template name="vložOdkaz"> 
    87                         <xsl:with-param name="url" select="concat('https://tools.ietf.org/html/rfc', @href)"/> 
     115                        <xsl:with-param name="url" select=" 
     116                                concat( 
     117                                        'https://tools.ietf.org/html/rfc', 
     118                                        @href 
     119                                )"/> 
    88120                </xsl:call-template> 
    89121        </xsl:template> 
     
    96128                        <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute> 
    97129                        <xsl:apply-templates/> 
    98                 </a>             
     130                </a> 
    99131        </xsl:template> 
    100132