1 <?xml version="1.0" encoding="utf-8"?>
 
   4    This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
 
   5    Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 
   8 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
   9     xmlns:wl="http://wolnelektury.pl/functions"
 
  10     xmlns:dc="http://purl.org/dc/elements/1.1/" >
 
  12 <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" version="2.0" />
 
  13 <xsl:strip-space  elements="opowiadanie powiesc dramat_wierszowany_l dramat_wierszowany_lp dramat_wspolczesny liryka_l liryka_lp wywiad"/>
 
  14 <xsl:template match="utwor">
 
  16         <xsl:when test="@full-page">
 
  19                 <title>Książka z serwisu WolneLektury.pl</title>
 
  20                 <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
 
  25                     font: Georgia, "Times New Roman", serif;
 
  32                     text-decoration: none;
 
  40                 /* ================================== */
 
  41                 /* = Header with logo and menu      = */
 
  42                 /* ================================== */
 
  44                     margin: 3.4em 0 0 1.4em;
 
  80                 #menu li a:hover, #menu li a:active {
 
  82                     background: #FFF url(/static/img/arrow-down.png) no-repeat center right;
 
  87                     background: #FFF url(/static/img/arrow-up.png) no-repeat center right;
 
 105                 #toc, #themes, #nota_red, #info {
 
 112                     border-bottom: 0.25em solid #DDD;
 
 113                     border-right: 0.25em solid #DDD;
 
 122                 #toc ol, #themes ol {
 
 133                     padding: 0 0 1.5em 1.5em;
 
 158                 /* =================================================== */
 
 159                 /* = Common elements: headings, paragraphs and lines = */
 
 160                 /* =================================================== */
 
 193                 /* ======================== */
 
 194                 /* = Footnotes and themes = */
 
 195                 /* ======================== */
 
 197                     border-left: 0.1em solid #DDDDDD;
 
 204                     font-variant: normal;
 
 206                     text-transform: none;
 
 207                     text-decoration: none;
 
 211                     margin-right: -9.5em;
 
 212                     margin-bottom: 0.5em;
 
 228                 #footnotes .annotation {
 
 256                     margin: -0.25em -0.5em;
 
 262                     padding: 0.25em 0.5em;
 
 266                 .anchor:hover, #book-text .anchor:active {
 
 268                     background-color: #CCC;
 
 271                 /* =================== */
 
 272                 /* = Custom elements = */
 
 273                 /* =================== */
 
 278                     margin-bottom: 0.25em;
 
 285                     margin-bottom: -0.25em;
 
 304                     margin: 0.5em 0 0 1.5em;
 
 315                 div.kwestia div.stanza {
 
 336                     border-bottom: 0.1em solid #999;
 
 337                     padding-bottom: 1.5em;
 
 340                 div.note p, div.dedication p, div.note p.paragraph, div.dedication p.paragraph {
 
 353                     border-bottom: 0.1em solid #000;
 
 364                     padding: 0 0 0 1.5em;
 
 371                 em.math, em.foreign-word, em.book-title, em.didaskalia {
 
 376                     letter-spacing: 0.1em;
 
 381                     font-variant: small-caps;
 
 389                 /* =================================== */
 
 390                 /* = Hide some elements for printing = */
 
 391                 /* =================================== */
 
 394                     #menu {display: none;}
 
 398                 <xsl:call-template name="book-text" />
 
 403             <xsl:call-template name="book-text" />
 
 408 <xsl:template name="book-text">
 
 410         <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
 
 411         <xsl:if test="count(descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)])">
 
 414                 <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)]">
 
 416                         <a name="{concat('footnote-', generate-id(.))}" />
 
 417                         <a href="{concat('#anchor-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
 
 419                             <xsl:when test="count(akap|akap_cd|strofa) = 0">
 
 420                                 <p><xsl:apply-templates select="text()|*" mode="inline" />
 
 421                                 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
 
 425                                 <xsl:apply-templates select="text()|*" mode="inline" />
 
 436 <!-- ============================================================================== -->
 
 437 <!-- = MASTER TAG                                                                 = -->
 
 438 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
 
 439 <!-- ============================================================================== -->
 
 440 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
 
 441     <xsl:apply-templates select="nota_red" mode="special" />
 
 442     <xsl:if test="nazwa_utworu">
 
 444             <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
 
 445             <xsl:call-template name="translators" />
 
 448     <xsl:apply-templates />
 
 452 <!-- ==================================================================================== -->
 
 453 <!-- = BLOCK TAGS                                                                       = -->
 
 454 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
 
 455 <!-- ==================================================================================== -->
 
 456 <xsl:template match="nota">
 
 457     <div class="note"><xsl:apply-templates /></div>
 
 460 <xsl:template match="lista_osob">
 
 461     <div class="person-list">
 
 462         <h3><xsl:value-of select="naglowek_listy" /></h3>
 
 464             <xsl:apply-templates select="lista_osoba" />
 
 469 <xsl:template match="dedykacja">
 
 470     <div class="dedication"><xsl:apply-templates /></div>
 
 473 <xsl:template match="kwestia">
 
 474     <div class="kwestia">
 
 475         <xsl:apply-templates select="strofa|akap|didaskalia" />
 
 479 <xsl:template match="dlugi_cytat|poezja_cyt">
 
 480     <blockquote><xsl:apply-templates /></blockquote>
 
 483 <xsl:template match="motto">
 
 484     <div class="motto"><xsl:apply-templates mode="inline" /></div>
 
 488 <xsl:template match="tabela">
 
 489     <table><xsl:apply-templates /></table>
 
 491 <xsl:template match="wiersz">
 
 492     <tr><xsl:apply-templates /></tr>
 
 494 <xsl:template match="kol">
 
 495     <td><xsl:apply-templates mode="inline" /></td>
 
 498 <xsl:template match="ilustr" mode="inline">
 
 499     <xsl:apply-templates select="."/>
 
 502 <xsl:template match="ilustr">
 
 504         <xsl:attribute name="src">
 
 505             <xsl:value-of select="@src" />
 
 507                 <xsl:attribute name="alt">
 
 508                             <xsl:value-of select="@alt" />
 
 510                                 <xsl:attribute name="title">
 
 511                                                             <xsl:value-of select="@alt" />
 
 517 <xsl:template match="lista[@typ='num']">
 
 518     <ol><xsl:apply-templates /></ol>
 
 520 <xsl:template match="lista[@typ='punkt']">
 
 521     <ul><xsl:apply-templates /></ul>
 
 523 <xsl:template match="punkt">
 
 524     <li><xsl:apply-templates mode="inline" /></li>
 
 531 <!-- ========================================== -->
 
 532 <!-- = PARAGRAPH TAGS                         = -->
 
 533 <!-- = (can contain inline and special tags)  = -->
 
 534 <!-- ========================================== -->
 
 536 <xsl:template match="autor_utworu" mode="header">
 
 537     <span class="author"><xsl:apply-templates mode="inline" /></span>
 
 540 <xsl:template match="nazwa_utworu" mode="header">
 
 541     <span class="title"><xsl:apply-templates mode="inline" /></span>
 
 544 <xsl:template match="dzielo_nadrzedne" mode="header">
 
 545     <span class="collection"><xsl:apply-templates mode="inline" /></span>
 
 548 <xsl:template match="podtytul" mode="header">
 
 549     <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
 
 552 <!-- Section headers (included in index)-->
 
 553 <xsl:template match="naglowek_akt|naglowek_czesc">
 
 554   <xsl:call-template name="section-anchor"/>
 
 556         <xsl:apply-templates mode="inline" /></h2>
 
 559 <xsl:template match="naglowek_scena|naglowek_rozdzial">
 
 560     <xsl:call-template name="section-anchor"/>
 
 561     <h3><xsl:apply-templates mode="inline" /></h3>
 
 564 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
 
 565       <xsl:call-template name="section-anchor"/>
 
 566     <h4><xsl:apply-templates mode="inline" /></h4>
 
 569 <xsl:template match="srodtytul">
 
 570   <xsl:call-template name="section-anchor"/>
 
 572                                           <xsl:apply-templates mode="inline" /></h5>
 
 576 <!-- Other paragraph tags -->
 
 577 <xsl:template match="miejsce_czas">
 
 578       <xsl:call-template name="section-anchor"/>
 
 579     <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
 
 582 <xsl:template match="didaskalia">
 
 583       <xsl:call-template name="section-anchor"/>
 
 584     <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
 
 587 <xsl:template match="lista_osoba">
 
 588     <li><xsl:apply-templates mode="inline" /></li>
 
 591 <xsl:template match="akap|akap_dialog|akap_cd">
 
 592     <p class="paragraph">
 
 593       <xsl:call-template name="section-anchor"/>
 
 594         <xsl:apply-templates mode="inline" />
 
 598 <xsl:template match="strofa">
 
 600       <xsl:call-template name="section-anchor"/>
 
 602             <xsl:when test="count(br) > 0">
 
 603                 <xsl:call-template name="verse">
 
 604                     <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
 
 605                     <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
 
 607                 <xsl:for-each select="br">              
 
 608                                 <!-- Each BR tag "consumes" text after it -->
 
 609                     <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
 
 610                     <xsl:call-template name="verse">
 
 611                         <xsl:with-param name="verse-content"
 
 612                             select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
 
 613                         <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
 
 618                 <xsl:call-template name="verse">
 
 619                     <xsl:with-param name="verse-content" select="text() | node()" />
 
 620                     <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
 
 627 <xsl:template name="verse">
 
 628     <xsl:param name="verse-content" />
 
 629     <xsl:param name="verse-type" />
 
 632             <xsl:when test="name($verse-type) = 'wers_akap'">
 
 633                 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
 
 635             <xsl:when test="name($verse-type) = 'wers_wciety'">
 
 637                     <xsl:when test="$verse-content/@typ">
 
 638                         <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
 
 641                         <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
 
 645             <xsl:when test="name($verse-type) = 'wers_cd'">
 
 646                 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
 
 649         <xsl:apply-templates select="$verse-content" mode="inline" />
 
 653 <xsl:template match="motto_podpis">
 
 654     <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
 
 658 <!-- ================================================ -->
 
 659 <!-- = INLINE TAGS                                  = -->
 
 660 <!-- = (contain other inline tags and special tags) = -->
 
 661 <!-- ================================================ -->
 
 663 <xsl:template match="pa|pe|pr|pt" mode="inline">
 
 664     <a name="{concat('anchor-', generate-id(.))}" />
 
 665     <a href="{concat('#footnote-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
 
 668 <!-- Other inline tags -->
 
 669 <xsl:template match="mat" mode="inline">
 
 670     <em class="math"><xsl:apply-templates mode="inline" /></em>
 
 673 <xsl:template match="didask_tekst" mode="inline">
 
 674     <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
 
 677 <xsl:template match="slowo_obce" mode="inline">
 
 678     <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
 
 681 <xsl:template match="tytul_dziela" mode="inline">
 
 682     <em class="book-title">
 
 683         <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
 
 687 <xsl:template match="wyroznienie" mode="inline">
 
 688     <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
 
 691 <xsl:template match="osoba" mode="inline">
 
 692     <em class="person"><xsl:apply-templates mode="inline" /></em>
 
 695 <xsl:template match="www" mode="inline">
 
 697         <xsl:attribute name="href">
 
 698             <xsl:value-of select="text()"/>
 
 700         <xsl:value-of select="text()"/>
 
 704 <!-- ============================================== -->
 
 705 <!-- = STANDALONE TAGS                            = -->
 
 706 <!-- = (cannot contain any other tags)            = -->
 
 707 <!-- ============================================== -->
 
 708 <xsl:template match="sekcja_swiatlo">
 
 709     <hr class="spacer" />
 
 712 <xsl:template match="sekcja_asterysk">
 
 713     <p class="spacer-asterisk">*</p>
 
 716 <xsl:template match="separator_linia">
 
 717     <hr class="spacer-line" />
 
 721 <!-- ================ -->
 
 722 <!-- = SPECIAL TAGS = -->
 
 723 <!-- ================ -->
 
 725 <xsl:template match="begin" mode="inline">
 
 726     <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
 
 727     <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
 
 728         <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
 
 732 <xsl:template match="end" mode="inline">
 
 733     <span class="theme-end" fid="{substring(@id, 2)}"> </span>
 
 736 <xsl:template match="begin|end">
 
 737     <xsl:apply-templates select='.' mode="inline" />
 
 740 <xsl:template match="motyw" mode="inline" />
 
 743 <xsl:template match="nota_red" mode="special">
 
 745         <xsl:apply-templates />
 
 750 <xsl:template name="translators">
 
 751     <xsl:if test="//dc:contributor.translator">
 
 752         <span class="translator">
 
 753             <xsl:text>tłum. </xsl:text>
 
 754             <xsl:for-each select="//dc:contributor.translator">
 
 755                 <xsl:if test="position() != 1">, </xsl:if>
 
 756                 <xsl:apply-templates mode="person" />
 
 762 <xsl:template match="text()" mode="person">
 
 763     <xsl:value-of select="wl:person_name(.)" />
 
 767 <!-- ================ -->
 
 768 <!-- = IGNORED TAGS = -->
 
 769 <!-- ================ -->
 
 770 <xsl:template match="extra|uwaga" />
 
 771 <xsl:template match="extra|uwaga" mode="inline" />
 
 773 <xsl:template match="nota_red" />
 
 778 <xsl:template match="text()" />
 
 779 <xsl:template match="text()" mode="inline">
 
 780     <xsl:value-of select="wl:substitute_entities(.)" />
 
 786 <xsl:template name="section-anchor">
 
 788        this formula works as follows:
 
 789        - get all ancestors including self
 
 790        - choose the header (third one from root): utwor/book-type/header
 
 791        - get all preceding siblings
 
 793        - create an <a name="sec123"/> tag.
 
 795         <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />