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 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][not(parent::extra)])">
102 <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt][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]) + 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>
117 <xsl:apply-templates />
119 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
120 <xsl:if test="name()='pt'"> [przypis tłumacza]</xsl:if>
121 <xsl:if test="name()='pr'"> [przypis redakcyjny]</xsl:if>
122 <xsl:if test="name()='pe'"> [przypis edytorski]</xsl:if>
134 <!-- ============================================================================== -->
135 <!-- = MASTER TAG = -->
136 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
137 <!-- ============================================================================== -->
138 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
139 <xsl:apply-templates select="nota_red" mode="special" />
140 <xsl:if test="nazwa_utworu">
142 <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
143 <xsl:call-template name="translators" />
146 <xsl:apply-templates />
150 <!-- ==================================================================================== -->
151 <!-- = BLOCK TAGS = -->
152 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
153 <!-- ==================================================================================== -->
154 <xsl:template match="nota">
155 <div class="note"><xsl:apply-templates /></div>
158 <xsl:template match="lista_osob">
159 <xsl:call-template name="section-anchor"/>
160 <div class="person-list">
161 <h3><xsl:value-of select="naglowek_listy" /></h3>
163 <xsl:apply-templates select="lista_osoba" />
168 <xsl:template match="dedykacja">
169 <div class="dedication"><xsl:apply-templates /></div>
172 <xsl:template match="ramka">
173 <div class="frame"><xsl:apply-templates /></div>
176 <xsl:template match="kwestia">
177 <div class="kwestia">
178 <xsl:apply-templates select="strofa|akap|didaskalia" />
182 <xsl:template match="dlugi_cytat|poezja_cyt">
183 <blockquote><xsl:apply-templates /></blockquote>
186 <xsl:template match="motto">
187 <xsl:call-template name="section-anchor"/>
188 <div class="motto"><xsl:apply-templates /></div>
191 <xsl:template match="ilustr" mode="inline">
192 <xsl:apply-templates select="."/>
195 <xsl:template match="ilustr">
198 <xsl:attribute name="class">
199 <xsl:text>ilustr </xsl:text>
200 <xsl:value-of select="@wyrownanie"/>
201 <xsl:if test="@oblew">
202 <xsl:text> oblew</xsl:text>
207 <xsl:attribute name="src">
208 <xsl:value-of select="@src" />
210 <xsl:attribute name="srcset">
211 <xsl:value-of select="@srcset" />
213 <xsl:attribute name="sizes">
214 (min-width: 718px) 600px,
215 (min-width: 600px) calc(100vw - 118px),
216 (min-width: 320px) calc(100vw - 75px),
217 (min-width: 15em) calc(100wv - 60px),
220 <xsl:attribute name="alt">
221 <xsl:value-of select="@alt" />
223 <xsl:attribute name="title">
224 <xsl:value-of select="@alt" />
227 <xsl:if test="@szer">
228 <xsl:attribute name="style">
229 <xsl:text>width: </xsl:text>
230 <xsl:value-of select="@szer"/>
235 <div class="stop"></div>
239 <xsl:template match="animacja">
240 <div class="animacja cycle-slideshow" data-cycle-pause-on-hover="true" data-cycle-next="> img" data-cycle-fx="fadeout" data-cycle-paused="true">
241 <xsl:apply-templates/>
246 <!-- ========================================== -->
247 <!-- = PARAGRAPH TAGS = -->
248 <!-- = (can contain inline and special tags) = -->
249 <!-- ========================================== -->
251 <xsl:template match="autor_utworu" mode="header">
252 <span class="author"><xsl:apply-templates mode="inline" /></span>
255 <xsl:template match="nazwa_utworu" mode="header">
256 <span class="title"><xsl:apply-templates mode="inline" /></span>
259 <xsl:template match="dzielo_nadrzedne" mode="header">
260 <span class="collection"><xsl:apply-templates mode="inline" /></span>
263 <xsl:template match="podtytul" mode="header">
264 <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
267 <!-- Section headers (included in index)-->
268 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
269 <xsl:call-template name="section-anchor"/>
270 <h2><xsl:apply-templates mode="inline" /></h2>
273 <xsl:template match="podtytul_akt|podtytul_czesc">
274 <div class="subtitle2">
275 <xsl:apply-templates mode="inline" />
279 <xsl:template match="naglowek_scena|naglowek_rozdzial">
280 <xsl:call-template name="section-anchor"/>
281 <h3><xsl:apply-templates mode="inline" /></h3>
284 <xsl:template match="podtytul_scena|podtytul_rozdzial">
285 <div class="subtitle3">
286 <xsl:apply-templates mode="inline" />
290 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
291 <xsl:call-template name="section-anchor"/>
292 <h4><xsl:apply-templates mode="inline" /></h4>
295 <xsl:template match="podtytul_podrozdzial">
296 <div class="subtitle4">
297 <xsl:apply-templates mode="inline" />
301 <!-- Other paragraph tags -->
302 <xsl:template match="miejsce_czas">
303 <xsl:call-template name="section-anchor"/>
304 <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
307 <xsl:template match="didaskalia">
308 <xsl:call-template name="section-anchor"/>
309 <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
312 <xsl:template match="lista_osoba">
313 <li><xsl:apply-templates mode="inline" /></li>
316 <xsl:template match="akap|akap_dialog|akap_cd">
317 <p class="paragraph">
318 <xsl:call-template name="section-anchor"/>
319 <xsl:apply-templates mode="inline" />
323 <xsl:template match="strofa" mode="inline">
324 <xsl:apply-templates select="." />
327 <xsl:template match="strofa">
329 <xsl:call-template name="section-anchor"/>
331 <xsl:when test="count(br) > 0">
332 <xsl:call-template name="verse">
333 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
334 <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'][1]" />
336 <xsl:for-each select="br">
337 <!-- Each BR tag "consumes" text after it -->
338 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
339 <xsl:call-template name="verse">
340 <xsl:with-param name="verse-content"
341 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
342 <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')][1]" />
347 <xsl:call-template name="verse">
348 <xsl:with-param name="verse-content" select="text() | node()" />
349 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
356 <xsl:template name="verse">
357 <xsl:param name="verse-content" />
358 <xsl:param name="verse-type" />
361 <xsl:when test="name($verse-type) = 'wers_akap'">
362 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
364 <xsl:when test="name($verse-type) = 'wers_wciety'">
366 <xsl:when test="$verse-content/@typ">
367 <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
370 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
374 <xsl:when test="name($verse-type) = 'wers_cd'">
375 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
377 <xsl:when test="name($verse-type) = 'wers_do_prawej'">
378 <xsl:attribute name="style">text-align: right</xsl:attribute>
381 <xsl:apply-templates select="$verse-content" mode="inline" />
385 <xsl:template match="motto_podpis">
386 <xsl:call-template name="section-anchor"/>
387 <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
390 <xsl:template match="tabela|tabelka">
391 <xsl:call-template name="section-anchor"/>
393 <xsl:when test="@ramka = '1'">
394 <table class="border"><xsl:apply-templates /></table>
397 <table><xsl:apply-templates /></table>
401 <xsl:template match="wiersz">
402 <tr><xsl:apply-templates /></tr>
404 <xsl:template match="kol">
405 <td><xsl:apply-templates mode="inline" /></td>
408 <xsl:template match="mat">
409 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
413 <!-- ================================================ -->
414 <!-- = INLINE TAGS = -->
415 <!-- = (contain other inline tags and special tags) = -->
416 <!-- ================================================ -->
418 <xsl:template match="pa|pe|pr|pt" mode="inline">
419 <a name="{concat('anchor-', generate-id(.))}" />
420 <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>
423 <xsl:template match="ref" mode="inline">
424 <a class="reference" data-uri="">
425 <xsl:attribute name="data-uri">
426 <xsl:value-of select="@href"/>
431 <!-- Other inline tags -->
432 <xsl:template match="mat" mode="inline">
433 <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
436 <xsl:template match="didask_tekst" mode="inline">
437 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
440 <xsl:template match="slowo_obce" mode="inline">
441 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
444 <xsl:template match="tytul_dziela" mode="inline">
445 <em class="book-title">
446 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
450 <xsl:template match="wyroznienie" mode="inline">
451 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
454 <xsl:template match="wieksze_odstepy" mode="inline">
455 <em class="wieksze-odstepy"><xsl:apply-templates mode="inline" /></em>
458 <xsl:template match="indeks_dolny" mode="inline">
459 <sub><xsl:apply-templates mode="inline" /></sub>
462 <xsl:template match="osoba" mode="inline">
463 <em class="person"><xsl:apply-templates mode="inline" /></em>
467 <!-- ============================================== -->
468 <!-- = STANDALONE TAGS = -->
469 <!-- = (cannot contain any other tags) = -->
470 <!-- ============================================== -->
471 <xsl:template match="sekcja_swiatlo">
472 <hr class="spacer" />
475 <xsl:template match="sekcja_asterysk">
476 <p class="spacer-asterisk">*</p>
479 <xsl:template match="separator_linia">
480 <hr class="spacer-line" />
484 <!-- ================ -->
485 <!-- = SPECIAL TAGS = -->
486 <!-- ================ -->
488 <xsl:template match="begin" mode="inline">
489 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
490 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
491 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
495 <xsl:template match="end" mode="inline">
496 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
499 <xsl:template match="begin|end">
500 <xsl:apply-templates select='.' mode="inline" />
503 <xsl:template match="motyw" mode="inline" />
506 <xsl:template match="nota_red" mode="special">
508 <xsl:apply-templates />
513 <xsl:template name="translators">
514 <xsl:if test="//dc:contributor.translator">
515 <span class="translator">
516 <xsl:text>tłum. </xsl:text>
517 <xsl:for-each select="//dc:contributor.translator">
518 <xsl:if test="position() != 1">, </xsl:if>
519 <xsl:apply-templates mode="person" />
525 <xsl:template match="text()" mode="person">
526 <xsl:value-of select="wl:person_name(.)" />
530 <!-- ================ -->
531 <!-- = IGNORED TAGS = -->
532 <!-- ================ -->
533 <xsl:template match="extra|uwaga" />
534 <xsl:template match="extra|uwaga" mode="inline" />
536 <xsl:template match="nota_red" />
537 <xsl:template match="abstrakt" />
542 <xsl:template match="text()" />
543 <xsl:template match="text()" mode="inline">
544 <xsl:value-of select="wl:substitute_entities(.)" />
550 <xsl:template name="section-anchor">
552 this formula works as follows:
553 - get all ancestors including self
554 - choose the header (third one from root): utwor/book-type/header
555 - get all preceding siblings
557 - create an <a name="sec123"/> tag.
559 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />