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 Wolne Lektury. 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 charset="utf-8" />
21 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
22 <link rel="stylesheet" type="text/css">
23 <xsl:attribute name="href">
24 <xsl:value-of select="$css" />
47 .ilustr.oblew.lewo img {
50 .ilustr.oblew.prawo img {
56 min-width: 200px !important;
58 @media screen and (max-width: 320px) {
60 width: 100% !important;
61 min-width: auto !important;
69 .ilustr.oblew.prawo img {
72 .ilustr.oblew.lewo img{
83 <xsl:call-template name="book-text" />
85 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
86 <script src="http://malsup.github.io/min/jquery.cycle2.min.js"></script>
91 <xsl:call-template name="book-text" />
96 <xsl:template name="book-text">
98 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
99 <xsl:if test="count(descendant::*[self::pe or self::pa or self::pr or self::pt or self::ptrad][not(parent::extra)])">
102 <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt or self::ptrad][not(parent::extra)]">
104 <xsl:attribute name="class">fn-<xsl:value-of select="name()" /></xsl:attribute>
105 <a name="{concat('footnote-', generate-id(.))}" />
106 <a href="{concat('#anchor-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt or self::ptrad]) + 1" />]</a>
108 <xsl:when test="count(akap|akap_cd|strofa) = 0">
109 <p><xsl:apply-templates select="text()|*" mode="inline" />
110 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
111 <xsl:if test="name()='pt'"> [przypis tłumacza]</xsl:if>
112 <xsl:if test="name()='pr'"> [przypis redakcyjny]</xsl:if>
113 <xsl:if test="name()='pe'"> [przypis edytorski]</xsl:if>
114 <xsl:if test="name()='ptrad'"> [przypis tradycyjny]</xsl:if>
118 <xsl:apply-templates />
120 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
121 <xsl:if test="name()='pt'"> [przypis tłumacza]</xsl:if>
122 <xsl:if test="name()='pr'"> [przypis redakcyjny]</xsl:if>
123 <xsl:if test="name()='pe'"> [przypis edytorski]</xsl:if>
124 <xsl:if test="name()='ptrad'"> [przypis tradycyjny]</xsl:if>
136 <!-- ============================================================================== -->
137 <!-- = MASTER TAG = -->
138 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
139 <!-- ============================================================================== -->
140 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
141 <xsl:apply-templates select="nota_red" mode="special" />
142 <xsl:if test="nazwa_utworu">
144 <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
145 <xsl:call-template name="translators" />
148 <xsl:apply-templates />
152 <!-- ==================================================================================== -->
153 <!-- = BLOCK TAGS = -->
154 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
155 <!-- ==================================================================================== -->
156 <xsl:template match="nota">
157 <div class="note"><xsl:apply-templates /></div>
160 <xsl:template match="lista_osob">
161 <xsl:call-template name="section-anchor"/>
162 <div class="person-list">
163 <h3><xsl:value-of select="naglowek_listy" /></h3>
165 <xsl:apply-templates select="lista_osoba" />
170 <xsl:template match="dedykacja">
171 <div class="dedication"><xsl:apply-templates /></div>
174 <xsl:template match="ramka">
175 <div class="frame"><xsl:apply-templates /></div>
178 <xsl:template match="kwestia">
179 <div class="kwestia">
180 <xsl:apply-templates select="strofa|akap|didaskalia" />
184 <xsl:template match="dlugi_cytat|poezja_cyt">
185 <blockquote><xsl:apply-templates /></blockquote>
188 <xsl:template match="motto">
189 <xsl:call-template name="section-anchor"/>
191 <xsl:call-template name="block-args" />
192 <xsl:apply-templates />
196 <xsl:template match="ilustr" mode="inline">
197 <xsl:apply-templates select="."/>
200 <xsl:template match="ilustr">
202 <xsl:call-template name="block-args" />
204 <xsl:attribute name="class">
205 <xsl:text>ilustr </xsl:text>
206 <xsl:value-of select="@wyrownanie"/>
207 <xsl:if test="@oblew">
208 <xsl:text> oblew</xsl:text>
213 <xsl:attribute name="src">
214 <xsl:value-of select="@src" />
216 <xsl:attribute name="srcset">
217 <xsl:value-of select="@srcset" />
219 <xsl:attribute name="sizes">
220 (min-width: 718px) 600px,
221 (min-width: 600px) calc(100vw - 118px),
222 (min-width: 320px) calc(100vw - 75px),
223 (min-width: 15em) calc(100wv - 60px),
226 <xsl:attribute name="alt">
227 <xsl:value-of select="@alt" />
229 <xsl:attribute name="title">
230 <xsl:value-of select="@alt" />
233 <xsl:if test="@szer">
234 <xsl:attribute name="style">
235 <xsl:text>width: </xsl:text>
236 <xsl:value-of select="@szer"/>
241 <div class="stop"></div>
245 <xsl:template match="animacja">
246 <div class="animacja cycle-slideshow" data-cycle-pause-on-hover="true" data-cycle-next="> img" data-cycle-fx="fadeout" data-cycle-paused="true">
247 <xsl:call-template name="block-args" />
248 <xsl:apply-templates/>
253 <!-- ========================================== -->
254 <!-- = PARAGRAPH TAGS = -->
255 <!-- = (can contain inline and special tags) = -->
256 <!-- ========================================== -->
258 <xsl:template match="autor_utworu" mode="header">
259 <span class="author">
260 <xsl:call-template name="block-args" />
261 <xsl:apply-templates mode="inline" />
265 <xsl:template match="nazwa_utworu" mode="header">
267 <xsl:call-template name="block-args" />
268 <xsl:apply-templates mode="inline" />
272 <xsl:template match="dzielo_nadrzedne" mode="header">
273 <span class="collection">
274 <xsl:call-template name="block-args" />
275 <xsl:apply-templates mode="inline" />
279 <xsl:template match="podtytul" mode="header">
280 <span class="subtitle">
281 <xsl:call-template name="block-args" />
282 <xsl:apply-templates mode="inline" />
286 <!-- Section headers (included in index)-->
287 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
288 <xsl:call-template name="section-anchor"/>
290 <xsl:call-template name="block-args" />
291 <xsl:apply-templates mode="inline" />
295 <xsl:template match="podtytul_akt|podtytul_czesc">
296 <div class="subtitle2">
297 <xsl:call-template name="block-args" />
298 <xsl:apply-templates mode="inline" />
302 <xsl:template match="naglowek_scena|naglowek_rozdzial">
303 <xsl:call-template name="section-anchor"/>
305 <xsl:call-template name="block-args" />
306 <xsl:apply-templates mode="inline" />
310 <xsl:template match="podtytul_scena|podtytul_rozdzial">
311 <div class="subtitle3">
312 <xsl:call-template name="block-args" />
313 <xsl:apply-templates mode="inline" />
317 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
318 <xsl:call-template name="section-anchor"/>
320 <xsl:call-template name="block-args" />
321 <xsl:apply-templates mode="inline" />
325 <xsl:template match="podtytul_podrozdzial">
326 <div class="subtitle4">
327 <xsl:call-template name="block-args" />
328 <xsl:apply-templates mode="inline" />
332 <!-- Other paragraph tags -->
333 <xsl:template match="miejsce_czas">
334 <xsl:call-template name="section-anchor"/>
335 <p class="place-and-time">
336 <xsl:call-template name="block-args" />
337 <xsl:apply-templates mode="inline" />
341 <xsl:template match="didaskalia">
342 <xsl:call-template name="section-anchor"/>
343 <div class="didaskalia">
344 <xsl:call-template name="block-args" />
345 <xsl:apply-templates mode="inline" />
349 <xsl:template match="lista_osoba">
350 <li><xsl:apply-templates mode="inline" /></li>
353 <xsl:template match="akap|akap_dialog|akap_cd">
354 <p class="paragraph">
355 <xsl:call-template name="block-args" />
356 <xsl:call-template name="section-anchor"/>
357 <xsl:apply-templates mode="inline" />
361 <xsl:template match="strofa" mode="inline">
362 <xsl:apply-templates select="." />
365 <xsl:template match="strofa">
367 <xsl:call-template name="block-args" />
368 <xsl:call-template name="section-anchor"/>
370 <xsl:when test="count(br) > 0">
371 <xsl:call-template name="verse">
372 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
373 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd' or name() = 'wers_do_prawej' or name() = 'wers_srodek'][1]" />
375 <xsl:for-each select="br">
376 <!-- Each BR tag "consumes" text after it -->
377 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
378 <xsl:call-template name="verse">
379 <xsl:with-param name="verse-content"
380 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
381 <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' or name() = 'wers_do_prawej' or name() = 'wers_srodek')][1]" />
386 <xsl:call-template name="verse">
387 <xsl:with-param name="verse-content" select="text() | node()" />
388 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej|wers_srodek[1]" />
395 <xsl:template name="verse">
396 <xsl:param name="verse-content" />
397 <xsl:param name="verse-type" />
399 <xsl:attribute name="class">
400 <xsl:text>verse</xsl:text>
402 <xsl:when test="name($verse-type) = 'wers_akap'">
403 <xsl:text> verse-p</xsl:text>
405 <xsl:when test="name($verse-type) = 'wers_wciety'">
406 <xsl:text> verse-indent</xsl:text>
407 <xsl:if test="$verse-content/@typ">
408 <xsl:text> verse-indent-</xsl:text>
409 <xsl:value-of select="$verse-content/@typ" />
412 <xsl:when test="name($verse-type) = 'wers_cd'">
413 <xsl:text> verse-cont</xsl:text>
415 <xsl:when test="name($verse-type) = 'wers_do_prawej'">
416 <xsl:text> verse-right</xsl:text>
418 <xsl:when test="name($verse-type) = 'wers_srodek'">
419 <xsl:text> verse-center</xsl:text>
423 <xsl:apply-templates select="$verse-content" mode="inline" />
427 <xsl:template match="motto_podpis">
428 <xsl:call-template name="section-anchor"/>
429 <p class="motto_podpis">
430 <xsl:call-template name="block-args" />
431 <xsl:apply-templates mode="inline" />
435 <xsl:template match="tabela|tabelka">
436 <xsl:call-template name="section-anchor"/>
438 <xsl:when test="@ramka = '1'">
439 <table class="border">
440 <xsl:call-template name="block-args" />
441 <xsl:apply-templates />
446 <xsl:call-template name="block-args" />
447 <xsl:apply-templates />
452 <xsl:template match="wiersz">
453 <tr><xsl:apply-templates /></tr>
455 <xsl:template match="kol">
456 <td><xsl:apply-templates mode="inline" /></td>
459 <xsl:template match="mat">
460 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
464 <!-- ================================================ -->
465 <!-- = INLINE TAGS = -->
466 <!-- = (contain other inline tags and special tags) = -->
467 <!-- ================================================ -->
469 <xsl:template match="pa|pe|pr|pt|ptrad" mode="inline">
470 <a name="{concat('anchor-', generate-id(.))}" />
471 <a href="{concat('#footnote-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt or self::ptrad]) + 1" />]</a>
474 <xsl:template match="ref" mode="inline">
475 <a class="reference" data-uri="">
476 <xsl:attribute name="data-uri">
477 <xsl:value-of select="@href"/>
482 <!-- Other inline tags -->
483 <xsl:template match="mat" mode="inline">
484 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*|text()" /></math>
487 <xsl:template match="didask_tekst" mode="inline">
488 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
491 <xsl:template match="slowo_obce" mode="inline">
493 <xsl:attribute name="class">
494 <xsl:text>foreign-word</xsl:text>
495 <xsl:if test="@protect">
496 <xsl:text> foreign-word-protected</xsl:text>
499 <xsl:apply-templates mode="inline" />
503 <xsl:template match="tytul_dziela" mode="inline">
504 <em class="book-title">
505 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
509 <xsl:template match="wyroznienie" mode="inline">
510 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
513 <xsl:template match="wieksze_odstepy" mode="inline">
514 <em class="wieksze-odstepy"><xsl:apply-templates mode="inline" /></em>
517 <xsl:template match="indeks_dolny" mode="inline">
518 <sub><xsl:apply-templates mode="inline" /></sub>
521 <xsl:template match="osoba" mode="inline">
522 <em class="person"><xsl:apply-templates mode="inline" /></em>
525 <xsl:template match="www" mode="inline">
527 <xsl:attribute name="href">
528 <xsl:value-of select="text()"/>
530 <xsl:apply-templates mode="inline" />
534 <!-- ============================================== -->
535 <!-- = STANDALONE TAGS = -->
536 <!-- = (cannot contain any other tags) = -->
537 <!-- ============================================== -->
538 <xsl:template match="sekcja_swiatlo">
539 <hr class="spacer" />
542 <xsl:template match="sekcja_asterysk">
543 <p class="spacer-asterisk">*</p>
546 <xsl:template match="separator_linia">
547 <hr class="spacer-line" />
551 <!-- ================ -->
552 <!-- = SPECIAL TAGS = -->
553 <!-- ================ -->
555 <xsl:template match="begin" mode="inline">
556 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
557 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
558 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
562 <xsl:template match="end" mode="inline">
563 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
566 <xsl:template match="begin|end">
567 <xsl:apply-templates select='.' mode="inline" />
570 <xsl:template match="motyw" mode="inline" />
573 <xsl:template match="nota_red" mode="special">
575 <xsl:apply-templates />
580 <xsl:template name="translators">
581 <xsl:if test="//dc:contributor.translator">
582 <span class="translator">
583 <xsl:text>tłum. </xsl:text>
584 <xsl:for-each select="//dc:contributor.translator">
585 <xsl:if test="position() != 1">, </xsl:if>
586 <xsl:apply-templates mode="person" />
592 <xsl:template match="text()" mode="person">
593 <xsl:value-of select="wl:person_name(.)" />
596 <xsl:template match="rownolegle">
597 <xsl:apply-templates mode="rownolegle" />
599 <xsl:template match="*" mode="rownolegle">
602 <xsl:attribute name="class">
603 <xsl:text>rownolegly-blok</xsl:text>
604 <xsl:if test="not(following-sibling::*)">
605 <xsl:text> last</xsl:text>
607 <xsl:if test="not(preceding-sibling::*)">
608 <xsl:text> first</xsl:text>
611 <xsl:attribute name="style">
612 <xsl:text>border-left: 2px solid red; padding-left: .5em;</xsl:text>
613 <xsl:if test="not(following-sibling::*)">
614 <xsl:text> border-radius: 0 0 0 .75em;</xsl:text>
616 <xsl:if test="not(preceding-sibling::*)">
617 <xsl:text> border-radius: .75em 0 0 0;</xsl:text>
620 <xsl:apply-templates match="." />
624 <xsl:template match="tab" mode="inline">
627 <xsl:when test="@szer">
628 <xsl:attribute name="style">display: inline-block; width: <xsl:value-of select="@szer" />em</xsl:attribute>
631 <xsl:attribute name="style">display: inline-block; width: 1em</xsl:attribute>
638 <xsl:template match="werset">
639 <p class="werset paragraph">
640 <xsl:call-template name="block-args" />
641 <xsl:call-template name="section-anchor"/>
642 <xsl:apply-templates mode="inline" />
647 <!-- ================ -->
648 <!-- = IGNORED TAGS = -->
649 <!-- ================ -->
650 <xsl:template match="extra|uwaga" />
651 <xsl:template match="extra|uwaga" mode="inline" />
653 <xsl:template match="nota_red" />
654 <xsl:template match="abstrakt" />
659 <xsl:template match="text()" />
660 <xsl:template match="text()" mode="inline">
661 <xsl:value-of select="wl:substitute_entities(.)" />
667 <xsl:template name="section-anchor">
669 this formula works as follows:
670 - get all ancestors including self
671 - choose the header (third one from root): utwor/book-type/header
672 - get all preceding siblings
674 - create an <a name="sec123"/> tag.
676 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />
679 <xsl:template name="block-args">
681 <xsl:attribute name="id">
682 <xsl:text>wl-</xsl:text>
683 <xsl:value-of select="@id"/>
688 <xsl:template match="numeracja">
689 <span class="numeracja">
690 <xsl:attribute name="data-start">
691 <xsl:value-of select="@start" />
693 <xsl:attribute name="data-link">
694 <xsl:value-of select="@link" />