epub changes
authorMarcin Koziej <marcinkoziej@nowoczesnapolska.org.pl>
Mon, 14 Oct 2013 11:59:37 +0000 (13:59 +0200)
committerMarcin Koziej <marcinkoziej@nowoczesnapolska.org.pl>
Mon, 14 Oct 2013 11:59:37 +0000 (13:59 +0200)
12 files changed:
librarian/book2anything.py
librarian/cover.py
librarian/epub.py
librarian/epub/style.css
librarian/epub/toc.html
librarian/epub/xsltContent.xsl
librarian/epub/xsltLast.xsl
librarian/epub/xsltScheme.xsl
librarian/pdf.py
librarian/pdf/wl.cls
scripts/book2epub
scripts/book2pdf

index cf3c49d..d76177c 100755 (executable)
@@ -10,7 +10,7 @@ import optparse
 
 from librarian import DirDocProvider, ParseError
 from librarian.parser import WLDocument
-from librarian.cover import WLCover, FutureOfCopyrightCover
+from librarian.cover import WLCover, FutureOfCopyrightCover, CoverFromFile
 
 
 class Option(object):
@@ -102,6 +102,10 @@ class Book2Anything(object):
                 def cover_class(*args, **kwargs):
                     return FutureOfCopyrightCover(image_cache=options.image_cache, *args, **kwargs)
                 transform_args['cover'] = cover_class
+            elif options.cover_file:
+                def cover_class(*args, **kwargs):
+                    return CoverFromFile(options.cover_file, *args, **kwargs)
+                transform_args['cover'] = cover_class
             elif not cls.cover_optional or options.with_cover:
                 transform_args['cover'] = FutureOfCopyrightCover
 
index ff01841..efb2974 100644 (file)
@@ -7,7 +7,7 @@ import re
 from PIL import Image, ImageFont, ImageDraw, ImageFilter, ImageEnhance
 from StringIO import StringIO
 from librarian import get_resource, OutputFile, URLOpener
-
+from os import path
 
 class Metric(object):
     """Gets metrics from an object, scaling it by a factor."""
@@ -437,10 +437,25 @@ class GandalfCover(Cover):
     format = 'PNG'
 
 class FutureOfCopyrightCover(Cover):
-    width = 420
+    width = 402
     height = 595
     background_img = 'cover.png'
     format = 'PNG'
     
     def save(self, dest):
         dest.write(open(self.background_img).read())
+
+
+class CoverFromFile(Cover):
+    def __init__(self, filename, *args, **kwargs):
+        super(CoverFromFile, self).__init__(*args, **kwargs)
+
+        self.background_img = filename
+
+        self.img = Image.open(filename)
+        (self.width, self.height) = self.img.size
+
+        self.format = path.splitext(filename)[-1][1:].upper()
+        
+    def image(self):
+        return self.img
index 841b7c5..43eb295 100644 (file)
@@ -15,6 +15,7 @@ from lxml import etree
 import zipfile
 from tempfile import mkdtemp, NamedTemporaryFile
 from shutil import rmtree
+from mimetypes import guess_type
 
 from librarian import RDFNS, WLNS, NCXNS, OPFNS, XHTMLNS, OutputFile
 from librarian.cover import WLCover, FutureOfCopyrightCover
@@ -331,7 +332,8 @@ def transform_chunk(chunk_xml, chunk_no, annotations, empty=False, _empty_html_s
 
 def transform(wldoc, verbose=False,
               style=None, html_toc=False,
-              sample=None, cover=None, flags=None, resources=None):
+              sample=None, cover=None, flags=None, resources=None,
+              intro_file=None, cover_file=None):
     """ produces a EPUB file
 
     sample=n: generate sample e-book (with at least n paragraphs)
@@ -355,7 +357,7 @@ def transform(wldoc, verbose=False,
             zip.writestr('OPS/title.html',
                  etree.tostring(html_tree, method="html", pretty_print=True))
             # add a title page TOC entry
-            toc.add(u"Title", "title.html")
+            toc.add(u"Tytuł", "title.html")
         elif wldoc.book_info.parts:
             # write title page for every parent
             if sample is not None and sample <= 0:
@@ -448,6 +450,9 @@ def transform(wldoc, verbose=False,
                     fpath  = os.path.join(dp, fname)
                     if os.path.isfile(fpath):
                         zip.write(fpath, os.path.join('OPS', fname))
+                        manifest.append(etree.fromstring(
+                                '<item id="%s" href="%s" media-type="%s" />' % (os.path.splitext(fname)[0], fname, guess_type(fpath)[0])))
+
         else:
             print "resources path %s is not directory" % resources
                 
@@ -494,10 +499,20 @@ def transform(wldoc, verbose=False,
     nav_map = toc_file[-1]
 
     manifest.append(etree.fromstring(
-        '<item id="intro" href="intro.html" media-type="application/xhtml+xml" />'))
+        '<item id="first" href="first.html" media-type="application/xhtml+xml" />'))
     spine.append(etree.fromstring(
-        '<itemref idref="intro" />'))
-    zip.writestr('OPS/intro.html', open(get_resource('epub/intro.html')).read())
+        '<itemref idref="first" />'))
+    html_tree = xslt(document.edoc, get_resource('epub/xsltFirst.xsl'))
+#    chars.update(used_chars(html_tree.getroot()))
+    zip.writestr('OPS/first.html', etree.tostring(
+                        html_tree, method="html", pretty_print=True))
+
+    if intro_file:
+        manifest.append(etree.fromstring(
+                '<item id="intro" href="intro.html" media-type="application/xhtml+xml" />'))
+        spine.append(etree.fromstring(
+                '<itemref idref="intro" />'))
+        zip.writestr('OPS/intro.html', open(intro_file or get_resource('epub/intro.html')).read())
 
 
     if html_toc:
@@ -509,12 +524,14 @@ def transform(wldoc, verbose=False,
 
     toc, chunk_counter, chars, sample = transform_file(document, sample=sample)
 
+    toc.add("Informacje redakcyjne", "first.html", index=0)
+
     if len(toc.children) < 2:
-        toc.add(u"Beginning of the book", "part1.html")
+        toc.add(u"Początek książki", "part1.html")
 
     # Last modifications in container files and EPUB creation
     if len(annotations) > 0:
-        toc.add("Footnotes", "annotations.html")
+        toc.add("Przypisy", "annotations.html")
         manifest.append(etree.fromstring(
             '<item id="annotations" href="annotations.html" media-type="application/xhtml+xml" />'))
         spine.append(etree.fromstring(
@@ -534,7 +551,7 @@ def transform(wldoc, verbose=False,
     # chars.update(used_chars(etree.fromstring(html_string)))
     # zip.writestr('OPS/support.html', html_string)
 
-    toc.add("Editors", "last.html")
+    toc.add("Informacje redakcyjne", "last.html")
     manifest.append(etree.fromstring(
         '<item id="last" href="last.html" media-type="application/xhtml+xml" />'))
     spine.append(etree.fromstring(
@@ -582,7 +599,7 @@ def transform(wldoc, verbose=False,
 
     # write TOC
     if html_toc:
-        toc.add(u"Table of Contents", "toc.html", index=1)
+        toc.add(u"Spis treści", "toc.html", index=1)
         zip.writestr('OPS/toc.html', toc.html().encode('utf-8'))
     toc.write_to_xml(nav_map)
     zip.writestr('OPS/toc.ncx', etree.tostring(toc_file, pretty_print=True))
index 622c8da..a27c5cf 100644 (file)
@@ -75,10 +75,10 @@ a img {
 
 .h4
 {
-       font-size: 1em;
+    font-size: 1em;
     margin: 0;
     margin-top: 1.5em;
-       line-height: 1.5em;
+    line-height: 1.5em;
 }
 
 p
@@ -370,3 +370,4 @@ p.minor {
 p.footer {
     margin-top: 2em;
 }
+
index 1c2887d..ae004c2 100755 (executable)
@@ -2,7 +2,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
         <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
-        <title>Future of Copyright</title>
+        <title>Table of Contents</title>
     </head>
     <body>
         <h1>Table of Contents</h1>
index eb14524..cd99add 100644 (file)
@@ -12,6 +12,9 @@
         <dc:identifier id="BookId" opf:scheme="URI">
           <xsl:apply-templates select="//dc:identifier.url" />
         </dc:identifier>
+        <dc:identifier id="BookId" opf:scheme="ISBN">
+          <xsl:apply-templates select="//dc:source.ISBN" />
+        </dc:identifier>
         <dc:subject>
           <xsl:apply-templates select="//dc:identifier.url" />
         </dc:subject>
index bb83777..7c62d80 100644 (file)
         <link rel="stylesheet" href="style.css" type="text/css" />
         <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
         <title>
-          <xsl:text>Credits</xsl:text>
+          <xsl:text>Informacje redakcyjne</xsl:text>
         </title>
       </head>
       <body>
         <div id="book-text" >
-         
-
-<p>The Future of Copyright 2.0 Contest is a~part of Future of Copyright Project supported by Trust for Civil Society in Central and Eastern Europe</p>
-
-<!-- \includegraphics[scale=.2]<p>trust.eps} -->
-
-<p>This book is available under the terms of Creative Commons Attribution-ShareAlike 3.0 Unported License (read more:
-<a href="http://creativecommons.org/licenses/by-sa/3.0/">http://creativecommons.org/licenses/by-sa/3.0/</a>) <br/>
-Published by Modern Poland Foundation, Warsaw 2013 </p>
-
-<p>Technical editor: Paulina Choromańska <br/>
-Book design: Jakub Waluchowski<br/>
-Typography: Marcin Koziej </p>
-
-<p>Modern Poland Fundation <br/>
-Marszalkowska St. 84/92 app. 125 <br/>
-00-514 Warsaw <br/>
-tel/fax: +48 22 621-30-17 <br/>
-email: fundacja@nowoczesnapolska.org.pl <br/> 
-</p>
-
-<p>If you wish to support our projects, feel free to make a~donation via our secure online payment service: 
-<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=L2CLCXHZCWYJN">PLN</a> or <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=XVC8XD7DBGV6N">USD</a>
- or direct payment account number: 59 1030 0019 0109 8530 0040 5685 </p>
-
-<p> Thank you for your support.</p>
-
-
-
-
-
-<!--          <div class="info">
-          <img src="jedenprocent.png" alt="Logo 1%" />
-          <div>Przekaż 1% podatku na rozwój Wolnych Lektur.</div>
-          <div>Nazwa organizacji: Fundacja Nowoczesna Polska</div>
-          <div>KRS 0000070056</div>
-          </div>-->
-
-          <p class="info">&#160;</p>
-          <p class="minor info">
-              Generated on <span id="file_date"><xsl:value-of select="substring(date:date(), 1, 10)" /></span>.
-          </p>
-
+         <xsl:for-each select="//nota[@typ='redk']/*">
+           <div class="info">
+             <xsl:apply-templates select="."/>
+           </div>
+         </xsl:for-each>
         </div>
       </body>
     </html>
@@ -88,4 +49,341 @@ email: fundacja@nowoczesnapolska.org.pl <br/>
   <xsl:template match="text()" mode="person">
     <xsl:value-of select="wl:person_name(.)" />
   </xsl:template>
+
+<!-- copied from xsltScheme.xsl -->
+
+  <!--===========================================================-->
+  <!-- Tagi BLOKOWE -->
+  <!--===========================================================-->
+
+  <xsl:template match="nota">
+    <div class="note" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="lista_osob" >
+    <div class="person-list" xmlns="http://www.w3.org/1999/xhtml">
+      <div class="h3" xmlns="http://www.w3.org/1999/xhtml">
+        <xsl:apply-templates select="child::naglowek_listy" />
+      </div>
+      <ol xmlns="http://www.w3.org/1999/xhtml">
+        <xsl:apply-templates select="lista_osoba" />
+      </ol>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="dedykacja">
+    <div class="dedication" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="kwestia">
+    <div class="kwestia" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates select="strofa|akapit|didaskalia|akap " />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="dlugi_cytat|poezja_cyt">
+    <div class="block" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="motto">
+    <div class="motto" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </div>
+  </xsl:template>
+
+  <!--===========================================================-->
+  <!-- Tagi PARAGRAFOWE -->
+  <!--===========================================================-->
+
+  <xsl:template match="autor_utworu" mode="poczatek">
+    <h2 class="author" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="autor_utworu" />
+  <xsl:template match="autor_rozdzialu">
+      <xsl:apply-templates />
+  </xsl:template>
+
+  <xsl:template match="dzielo_nadrzedne" mode="poczatek">
+    <h2 class="collection" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="dzielo_nadrzedne" />
+
+  <xsl:template match="nazwa_utworu" mode="poczatek" >
+    <h2 class="intitle" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="nazwa_utworu" />
+
+  <xsl:template match="podtytul" mode="poczatek">
+    <h2 class="insubtitle" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="podtytul" />
+
+  <xsl:template match="naglowek_czesc|srodtytul">
+    <h2 class="h2" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="naglowek_akt">
+    <h2 class="h2" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="naglowek_scena">
+    <a xmlns="http://www.w3.org/1999/xhtml"></a>
+    <h2 class="h3" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="naglowek_podrozdzial">
+    <a xmlns="http://www.w3.org/1999/xhtml"></a>
+    <h2 class="h4" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+  
+  <xsl:template match="autor_rozdzialu">
+  </xsl:template>
+
+  <xsl:template match="naglowek_rozdzial">
+    <h2 class="h3" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:if test="name(following-sibling::*[1])='autor_rozdzialu'">
+       <xsl:value-of select="following-sibling::*[1]/text()"/> -
+      </xsl:if>
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="naglowek_osoba">
+    <h2 class="h4" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="miejsce_czas">
+    <div class="place-and-time" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="didaskalia">
+    <div class="didaskalia" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="akap|akap_dialog|akap_cd">
+    <p class="paragraph" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </p>
+  </xsl:template>
+
+  <xsl:template match="strofa">
+    <div class="stanza" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </div><div class='stanza-spacer' xmlns="http://www.w3.org/1999/xhtml">&#160;</div>
+  </xsl:template>
+
+  <xsl:template match="wers_normalny">
+    <div class="verse" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    &#160;</div>
+  </xsl:template>
+
+  <xsl:template match="wers_akap">
+    <div class="verse" style="margin-left: 1em;" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    &#160;</div>
+  </xsl:template>
+
+  <xsl:template match="wers_wciety">
+    <div class="verse" style='margin-left:1em;' xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    &#160;</div>
+  </xsl:template>
+
+  <xsl:template match="wers_wciety[@typ!='']">
+    <div class="verse" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:attribute name="style">
+          margin-left: <xsl:value-of select="@typ" />em;
+      </xsl:attribute>
+      <xsl:apply-templates />
+    &#160;</div>
+  </xsl:template>
+
+  <xsl:template match="wers_cd">
+    <div class="verse" style="margin-left: 12em;" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    &#160;</div>
+  </xsl:template>
+
+  <xsl:template match="motto_podpis">
+    <div class="motto_podpis" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="lista">
+    <ul>
+      <xsl:apply-templates />
+    </ul>
+  </xsl:template>
+
+  <xsl:template match="punkt">
+    <li><xsl:apply-templates /></li>
+  </xsl:template>
+
+  <xsl:template match="www">
+    <a>
+      <xsl:attribute name="href">
+       <xsl:value-of select="text()"/>
+      </xsl:attribute>
+      <xsl:value-of select="text()"/>
+    </a>
+  </xsl:template>
+
+  <xsl:template match="link">
+    <a>
+      <xsl:attribute name="href">
+       <xsl:value-of select="@url"/>
+      </xsl:attribute>
+      <xsl:value-of select="text()"/>
+    </a>
+  </xsl:template>
+
+
+  <!--===========================================================-->
+  <!-- Tagi LINIOWE -->
+  <!--===========================================================-->
+
+  <xsl:template match="slowo_obce">
+    <em class="foreign-word" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </em>
+  </xsl:template>
+
+  <xsl:template match="mat" >
+    <em class="math" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </em>
+  </xsl:template>
+
+  <xsl:template match="didask_tekst" >
+    <em class="didaskalia" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </em>
+  </xsl:template>
+
+  <xsl:template match="tytul_dziela" >
+    <em class="book-title" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:if test="@typ = '1'" >„</xsl:if>
+      <xsl:apply-templates />
+      <xsl:if test="@typ = '1'">”</xsl:if>
+    </em>
+  </xsl:template>
+
+  <xsl:template match="wyroznienie" >
+    <em class="author-emphasis" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </em>
+  </xsl:template>
+
+  <xsl:template match="osoba" >
+    <em class="person" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </em>
+  </xsl:template>
+
+  <xsl:template match="naglowek_listy"  >
+    <xsl:apply-templates />
+  </xsl:template>
+
+  <xsl:template match="lista_osoba" >
+    <li xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </li>
+  </xsl:template>
+
+  <!--===========================================================-->
+  <!-- Tagi STANDALONE -->
+  <!--===========================================================-->
+
+  <xsl:template match="sekcja_swiatlo">
+    <p class="spacer" xmlns="http://www.w3.org/1999/xhtml">&#160;</p>
+  </xsl:template>
+
+  <xsl:template match="sekcja_asterysk">
+    <p class="spacer-asterisk" xmlns="http://www.w3.org/1999/xhtml">*</p>
+  </xsl:template>
+
+  <xsl:template match="separator_linia">
+    <hr class="spacer-line" xmlns="http://www.w3.org/1999/xhtml"></hr>
+  </xsl:template>
+
+  <!--===========================================================-->
+  <!-- Tagi SPECJALNE -->
+  <!--===========================================================-->
+
+  <xsl:template match="motyw" />
+
+  <!--===========================================================-->
+  <!-- Tagi IGNOROWANE -->
+  <!--===========================================================-->
+
+  <xsl:template match="extra" />
+
+  <xsl:template match="pe|pa|pr|pt" >
+    <a id="anchor-{.}" class="anchor" href="annotations.html#annotation-{.}"
+       xmlns="http://www.w3.org/1999/xhtml">[<xsl:apply-templates />]</a>
+  </xsl:template>
+
+  <xsl:template match="uwaga" />
+
+  <xsl:template match="nota_red" />
+
+  <!--pominięcie tych metadanych-->
+  <xsl:template match="rdf:RDF" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />
+
+  <xsl:template match="latex" />
+
+  <!--===========================================================-->
+  <!-- Tagi TEKSTOWE -->
+  <!--===========================================================-->
+
+  <xsl:template match="text()"  >
+    <xsl:value-of select="." />
+  </xsl:template>
+
+
+  <!--===========================================================-->
+  <!-- Tagi ILUSTRACJE -->
+  <!--===========================================================-->
+  <xsl:template match="ilustr" >
+    <img>
+      <xsl:attribute name="src"><xsl:value-of select="@src"/>.<xsl:choose><xsl:when test="@extbitmap"><xsl:value-of select="@extbitmap"/></xsl:when><xsl:otherwise><xsl:value-of select="@ext"/></xsl:otherwise></xsl:choose></xsl:attribute>
+    </img>
+  </xsl:template>
+  
+
+
 </xsl:stylesheet>
index c3eb9fe..4060d62 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/">
   <xsl:output method="html" version="1.0" encoding="utf-8" />
   <xsl:output doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" />
   <xsl:output doctype-public="-//W3C//DTD XHTML 1.1//EN" />
@@ -10,7 +10,7 @@
         <link rel="stylesheet" href="style.css" type="text/css" />
         <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
         <title>
-          Future of Copyright
+         <xsl:value-of select="//dc:title"/>
         </title>
       </xsl:element>
       <xsl:element name="body" xmlns="http://www.w3.org/1999/xhtml">
   <!--===========================================================-->
 
   <xsl:template match="nota">
-    <div class="note" xmlns="http://www.w3.org/1999/xhtml">
-      <xsl:apply-templates />
-    </div>
+    <xsl:if test="not(@typ!='redp' or @typ!='redk')">
+      <div class="note" xmlns="http://www.w3.org/1999/xhtml">
+       <xsl:apply-templates />
+      </div>
+    </xsl:if>
   </xsl:template>
 
   <xsl:template match="lista_osob" >
@@ -87,9 +89,7 @@
   </xsl:template>
 
   <xsl:template match="autor_utworu" />
-  <xsl:template match="autor_rozdzialu">
-      <xsl:apply-templates />
-  </xsl:template>
+  <xsl:template match="autor_rozdzialu"/>
 
   <xsl:template match="dzielo_nadrzedne" mode="poczatek">
     <h2 class="collection" xmlns="http://www.w3.org/1999/xhtml">
       <xsl:apply-templates />
     </h2>
   </xsl:template>
+
+  <xsl:template match="naglowek_podpodrozdzial">
+    <a xmlns="http://www.w3.org/1999/xhtml"></a>
+    <div class="p" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:apply-templates />
+    </div>
+  </xsl:template>
+
   
   <xsl:template match="autor_rozdzialu">
   </xsl:template>
 
   <xsl:template match="naglowek_rozdzial">
-    <h2 class="h3" xmlns="http://www.w3.org/1999/xhtml">
-      <xsl:if test="name(following-sibling::*[1])='autor_rozdzialu'">
-       <xsl:value-of select="following-sibling::*[1]/text()"/> -
-      </xsl:if>
+    <h2 class="h2" xmlns="http://www.w3.org/1999/xhtml">
       <xsl:apply-templates />
     </h2>
+    <div class="info" xmlns="http://www.w3.org/1999/xhtml">    
+      <xsl:if test="name(following-sibling::*[1])='autor_rozdzialu'">
+       <xsl:value-of select="following-sibling::*[1]/text()"/>
+      </xsl:if>
+    </div>
   </xsl:template>
 
   <xsl:template match="naglowek_osoba">
   <!--pominięcie tych metadanych-->
   <xsl:template match="rdf:RDF" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />
 
+  <xsl:template match="latex" />
+
   <!--===========================================================-->
   <!-- Tagi TEKSTOWE -->
   <!--===========================================================-->
     <xsl:value-of select="." />
   </xsl:template>
 
+  <!--===========================================================-->
+  <!-- Tagi ILUSTRACJE -->
+  <!--===========================================================-->
+  <xsl:template match="ilustr" >
+    <img>
+      <xsl:attribute name="src"><xsl:value-of select="@src"/>.<xsl:choose><xsl:when test="@extbitmap"><xsl:value-of select="@extbitmap"/></xsl:when><xsl:otherwise><xsl:value-of select="@ext"/></xsl:otherwise></xsl:choose></xsl:attribute>
+    </img>
+  </xsl:template>
+  
+
 </xsl:stylesheet>
index eb3f942..ead91be 100644 (file)
@@ -185,7 +185,7 @@ def package_available(package, args='', verbose=False):
 
 
 def transform(wldoc, verbose=False, save_tex=None, save_texml=None, morefloats=None,
-              cover=None, flags=None, customizations=None, documentclass='wl', resources=None):
+              cover=None, cover_file=None, flags=None, customizations=None, documentclass='wl', resources=None):
     """ produces a PDF file with XeLaTeX
 
     wldoc: a WLDocument
index 05f2aba..55813dc 100644 (file)
@@ -648,3 +648,11 @@ Mapping=tex-text
 \fi
 }
 
+\newcommand{\spistresci}{
+  \tableofcontents
+  \newpage
+}
+
+\newcommand{\link}[2]{\href{#1}{\uline{#2}\footnote{#1}}}
+
+\newcommand{\www}[1]{{\normalfont\href{#1}{#1}}}
index ff2c668..f87bf05 100755 (executable)
@@ -16,8 +16,14 @@ class Book2Epub(Book2Anything):
         Option('-w', '--working-copy', dest='working-copy',
                 action='store_true', default=False,
                 help='mark the output as a working copy'),
+        ]
+    transform_options = [
         Option('-R', '--resources', dest='resources', metavar='DIR',
                 help='a directory with additional resources'),
+        Option('-I', '--intro', dest='intro_file', metavar='FILE',
+                help='HTML file containing intro'),
+        Option('-e', '--cover-file', dest='cover_file', metavar='FILE',
+               help='Cover image file'),
         ]
 
 
index 87afc1e..cda7381 100755 (executable)
@@ -26,8 +26,9 @@ class Book2Pdf(Book2Anything):
         Option('-D', '--documentclass', dest='documentclass', 
                help='LaTeX document class, defaults to "wl"'),
         Option('-s', '--customizations', dest='customizations', action='append', 
-               help='LaTeX document class options')
-
+               help='LaTeX document class options'),
+        Option('-e', '--cover-file', dest='cover_file', metavar='FILE',
+               help='Cover image file'),
     ]