foc-specific changes foc
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 4 Jun 2012 09:57:36 +0000 (11:57 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 4 Jun 2012 09:57:53 +0000 (11:57 +0200)
17 files changed:
librarian/cover.py
librarian/dcparser.py
librarian/epub.py
librarian/epub/cover.html
librarian/epub/toc.html
librarian/epub/xsltChunkTitle.xsl
librarian/epub/xsltContent.xsl
librarian/epub/xsltLast.xsl
librarian/epub/xsltScheme-FoC.xsl [new file with mode: 0755]
librarian/epub/xsltScheme.xsl
librarian/epub/xsltTitle.xsl
librarian/functions.py
librarian/mobi.py
librarian/pdf.py
librarian/pdf/wl.cls
librarian/pdf/wl2tex.xslt
scripts/book2pdf

index 46990fd..741436a 100644 (file)
@@ -120,7 +120,7 @@ class Cover(object):
         }
 
     def __init__(self, book_info):
-        self.author = ", ".join(auth.readable() for auth in book_info.authors)
+        #self.author = ", ".join(auth.readable() for auth in book_info.authors)
         self.title = book_info.title
 
     def pretty_author(self):
@@ -216,6 +216,7 @@ class WLCover(Cover):
         super(WLCover, self).__init__(book_info)
         self.kind = book_info.kind
         self.epoch = book_info.epoch
+        print book_info.cover_url
         if book_info.cover_url:
             from urllib2 import urlopen
             from StringIO import StringIO
@@ -369,3 +370,13 @@ class GandalfCover(Cover):
     logo_bottom = 25
     logo_width = 250
     format = 'PNG'
+
+class ImageCover(WLCover):
+    format = 'JPEG'
+    def __init__(self, *args, **kwargs):
+        super(ImageCover, self).__init__(*args, **kwargs)
+        self.im = Image.open(self.background_img)
+        self.width, self.height = self.im.size
+
+    def image(self):
+        return self.im
index 5a571ec..d4bdc67 100644 (file)
@@ -152,7 +152,7 @@ class WorkInfo(object):
     __metaclass__ = DCInfo
 
     FIELDS = (
-        Field( DCNS('creator'), 'authors', as_person, salias='author', multiple=True),
+        Field( DCNS('creator'), 'authors', as_person, salias='author', multiple=True, required=False),
         Field( DCNS('title'), 'title'),
         Field( DCNS('type'), 'type', required=False, multiple=True),
 
@@ -170,7 +170,7 @@ class WorkInfo(object):
 
         Field( DCNS('source'), 'source_name', required=False),
         Field( DCNS('source.URL'), 'source_url', required=False),
-        Field( DCNS('identifier.url'), 'url', WLURI, strict=as_wluri_strict),
+        Field( DCNS('identifier.url'), 'url', WLURI, strict=as_wluri_strict, required=False),
         Field( DCNS('rights.license'), 'license', required=False),
         Field( DCNS('rights'), 'license_description'),
     )
index 5481516..034d82d 100644 (file)
@@ -16,7 +16,7 @@ from tempfile import mkdtemp, NamedTemporaryFile
 from shutil import rmtree
 
 from librarian import RDFNS, WLNS, NCXNS, OPFNS, XHTMLNS, OutputFile
-from librarian.cover import WLCover
+from librarian.cover import ImageCover as WLCover
 
 from librarian import functions, get_resource
 
@@ -79,7 +79,7 @@ def replace_characters(node):
         return text.replace(u"\ufeff", u"")\
                    .replace("---", u"\u2014")\
                    .replace("--", u"\u2013")\
-                   .replace(",,", u"\u201E")\
+                   .replace(",,", u"")\
                    .replace('"', u"\u201D")\
                    .replace("'", u"\u2019")
     if node.tag in ('uwaga', 'extra'):
@@ -248,14 +248,15 @@ def chop(main_text):
     last_node_part = False
     for one_part in main_text:
         name = one_part.tag
-        if name == 'naglowek_czesc':
-            yield part_xml
-            last_node_part = True
-            main_xml_part[:] = [deepcopy(one_part)]
-        elif not last_node_part and name in ("naglowek_rozdzial", "naglowek_akt", "srodtytul"):
-            yield part_xml
-            main_xml_part[:] = [deepcopy(one_part)]
-        else:
+        #if name == 'naglowek_czesc':
+        #    yield part_xml
+        #    last_node_part = True
+        #    main_xml_part[:] = [deepcopy(one_part)]
+        #elif not last_node_part and name in ("naglowek_rozdzial", "naglowek_akt", "srodtytul"):
+        #    yield part_xml
+        #    main_xml_part[:] = [deepcopy(one_part)]
+        #else:
+        if True:
             main_xml_part.append(deepcopy(one_part))
             last_node_part = False
     yield part_xml
@@ -265,21 +266,24 @@ def transform_chunk(chunk_xml, chunk_no, annotations, empty=False, _empty_html_s
     """ transforms one chunk, returns a HTML string, a TOC object and a set of used characters """
 
     toc = TOC()
-    for element in chunk_xml[0]:
-        if element.tag in ("naglowek_czesc", "naglowek_rozdzial", "naglowek_akt", "srodtytul"):
-            toc.add(node_name(element), "part%d.html" % chunk_no)
-        elif element.tag in ('naglowek_podrozdzial', 'naglowek_scena'):
-            subnumber = toc.add(node_name(element), "part%d.html" % chunk_no, level=1, is_part=False)
-            element.set('sub', str(subnumber))
+    #for element in chunk_xml[0]:
+    #    if element.tag in ("naglowek_czesc", "naglowek_rozdzial", "naglowek_akt", "srodtytul"):
+    #        toc.add(node_name(element), "part%d.html" % chunk_no)
+    #    elif element.tag in ('naglowek_podrozdzial', 'naglowek_scena'):
+    #        subnumber = toc.add(node_name(element), "part%d.html" % chunk_no, level=1, is_part=False)
+    #        element.set('sub', str(subnumber))
     if empty:
         if not _empty_html_static:
             _empty_html_static.append(open(get_resource('epub/emptyChunk.html')).read())
         chars = set()
         output_html = _empty_html_static[0]
     else:
-        find_annotations(annotations, chunk_xml, chunk_no)
-        replace_by_verse(chunk_xml)
-        html_tree = xslt(chunk_xml, get_resource('epub/xsltScheme.xsl'))
+        if chunk_no == 1:
+            html_tree = xslt(chunk_xml, get_resource('epub/xsltScheme-FoC.xsl'))
+        else:
+            find_annotations(annotations, chunk_xml, chunk_no)
+            replace_by_verse(chunk_xml)
+            html_tree = xslt(chunk_xml, get_resource('epub/xsltScheme.xsl'))
         chars = used_chars(html_tree.getroot())
         output_html = etree.tostring(html_tree, method="html", pretty_print=True)
     return output_html, toc, chars
@@ -302,7 +306,16 @@ def transform(wldoc, verbose=False,
 
         # every input file will have a TOC entry,
         # pointing to starting chunk
-        toc = TOC(wldoc.book_info.title, "part%d.html" % chunk_counter)
+
+        # hack for FoC:
+        if wldoc.book_info.author is not None:
+            toc_title = "%s, %s" % (wldoc.book_info.author.readable(), wldoc.book_info.title)
+            note = wldoc.edoc.find('//dzielo_nadrzedne')
+            if note is not None:
+                toc_title += " (%s)" % note.text
+        else:
+            toc_title = wldoc.book_info.title
+        toc = TOC(toc_title, "part%d.html" % chunk_counter)
         chars = set()
         if first:
             # write book title page
@@ -311,7 +324,8 @@ 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"Strona tytułowa", "title.html")
+            toc.add(u"Title page", "title.html")
+            toc.add(u"Dear readers!", "part1.html")
         elif wldoc.book_info.parts:
             # write title page for every parent
             if sample is not None and sample <= 0:
@@ -387,8 +401,9 @@ def transform(wldoc, verbose=False,
                        '<rootfiles><rootfile full-path="OPS/content.opf" ' \
                        'media-type="application/oebps-package+xml" />' \
                        '</rootfiles></container>')
-    zip.write(get_resource('res/wl-logo-small.png'), os.path.join('OPS', 'logo_wolnelektury.png'))
-    zip.write(get_resource('res/jedenprocent.png'), os.path.join('OPS', 'jedenprocent.png'))
+    #zip.write(get_resource('res/wl-logo-small.png'), os.path.join('OPS', 'logo_wolnelektury.png'))
+    #zip.write(get_resource('res/jedenprocent.png'), os.path.join('OPS', 'jedenprocent.png'))
+    zip.write('logo.png', os.path.join('OPS', 'logo.png'))
     if not style:
         style = get_resource('epub/style.css')
     zip.write(style, os.path.join('OPS', 'style.css'))
@@ -404,6 +419,9 @@ def transform(wldoc, verbose=False,
 
         cover_file = StringIO()
         c = cover(document.book_info)
+        import Image
+        c.im = Image.open('cover.jpg')
+        c.ext = lambda: 'jpg'
         c.save(cover_file)
         c_name = 'cover.%s' % c.ext()
         zip.writestr(os.path.join('OPS', c_name), cover_file.getvalue())
@@ -437,7 +455,7 @@ def transform(wldoc, verbose=False,
             '<item id="html_toc" href="toc.html" media-type="application/xhtml+xml" />'))
         spine.append(etree.fromstring(
             '<itemref idref="html_toc" />'))
-        guide.append(etree.fromstring('<reference href="toc.html" type="toc" title="Spis treści"/>'))
+        guide.append(etree.fromstring('<reference href="toc.html" type="toc" title="Table of Contents"/>'))
 
     toc, chunk_counter, chars, sample = transform_file(document, sample=sample)
 
@@ -457,7 +475,7 @@ def transform(wldoc, verbose=False,
         zip.writestr('OPS/annotations.html', etree.tostring(
                             html_tree, method="html", pretty_print=True))
 
-    toc.add("Strona redakcyjna", "last.html")
+    toc.add("Editorial page", "last.html")
     manifest.append(etree.fromstring(
         '<item id="last" href="last.html" media-type="application/xhtml+xml" />'))
     spine.append(etree.fromstring(
@@ -501,7 +519,7 @@ def transform(wldoc, verbose=False,
 
     # write TOC
     if html_toc:
-        toc.add(u"Spis treści", "toc.html", index=1)
+        toc.add(u"Table of Contents", "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 784067c..3233201 100644 (file)
@@ -2,12 +2,12 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
-    <title>Okładka</title>
+    <title>Cover</title>
     <style type="text/css"> img { max-width: 100%; } </style>
   </head>
   <body style="oeb-column-number: 1;">
     <div id="cover-image">
-      <img alt="Okładka" />
+      <img alt="Cover" />
     </div>
   </body>
 </html>
\ No newline at end of file
index 69d8724..1c2887d 100755 (executable)
@@ -2,10 +2,10 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
         <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
-        <title>WolneLektury.pl</title>
+        <title>Future of Copyright</title>
     </head>
     <body>
-        <h1>Spis treści</h1>
+        <h1>Table of Contents</h1>
         %s
     </body>
 </html>
index 8c0e09a..1a997b6 100644 (file)
       <body>
         <div id="book-text" xmlns="http://www.w3.org/1999/xhtml">
           <div class='title-page'>
-            <xsl:apply-templates select="//dc:title" mode="poczatek"/>
+            <xsl:apply-templates select="//dzielo_nadrzedne"  mode="poczatek"/>
+            <xsl:apply-templates select="//autor_utworu"  mode="poczatek"/>
+            <xsl:apply-templates select="//nazwa_utworu"  mode="poczatek"/>
+            <!--xsl:apply-templates select="//dc:title" mode="poczatek"/-->
           </div>
         </div>
       </body>
     </h1>
   </xsl:template>
 
+  <xsl:template match="autor_utworu" mode="poczatek">
+    <h2 class="author" >
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="dzielo_nadrzedne" mode="poczatek">
+    <h2 class="collection" >
+      <xsl:apply-templates />
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="nazwa_utworu" mode="poczatek" >
+    <h1 class="title" >
+      <xsl:apply-templates />
+    </h1>
+  </xsl:template>
+
+
+
 </xsl:stylesheet>
index 83eb376..eb14524 100644 (file)
@@ -15,9 +15,9 @@
         <dc:subject>
           <xsl:apply-templates select="//dc:identifier.url" />
         </dc:subject>
-        <dc:creator>
+        <!--dc:creator>
           <xsl:apply-templates select="//dc:creator" />
-        </dc:creator>
+        </dc:creator-->
         <dc:publisher>
           <xsl:apply-templates select="//dc:publisher" />
         </dc:publisher>
         </dc:date>
       </metadata>
       <manifest>
+        <item id="logo" href="logo.png" media-type="image/png" />
         <item id="toc" href="toc.ncx" media-type="application/x-dtbncx+xml" />
         <item id="style" href="style.css" media-type="text/css" />
         <item id="titlePage" href="title.html" media-type="application/xhtml+xml" />
-        <item id="logo_wolnelektury" href="logo_wolnelektury.png" media-type="image/png" />
-        <item id="jedenprocent" href="jedenprocent.png" media-type="image/png" />
       </manifest>
       <spine toc="toc">
         <itemref idref="titlePage" />
index 751f97a..09dbc15 100644 (file)
@@ -15,7 +15,7 @@
         <link rel="stylesheet" href="style.css" type="text/css" />
         <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
         <title>
-          <xsl:text>Strona redakcyjna</xsl:text>
+          <xsl:text>Editorial page</xsl:text>
         </title>
       </head>
       <body>
           <p class="info">
               <xsl:choose>
                   <xsl:when test="//dc:rights.license">
-                      Ten utwór jest udostepniony na licencji
+                      This book is available under the terms of
                       <a>
                           <xsl:attribute name="href">
                               <xsl:value-of select="//dc:rights.license" />
                           </xsl:attribute>
                           <xsl:value-of select="//dc:rights" />
-                      </a>
+                      </a>.
                   </xsl:when>
                   <xsl:otherwise>
                     Ten utwór nie jest chroniony prawem autorskim i znajduje się w domenie
               </xsl:choose>
           </p>
 
-          <p class="info">Źródło: <a>
-              <xsl:attribute name="href">
-                  <xsl:value-of select="//dc:identifier.url" />
-              </xsl:attribute>
-              <xsl:attribute name="title">
-                  <xsl:value-of select="wl:person_name(//dc:creator/text())" />, <xsl:value-of select="//dc:title" />
-              </xsl:attribute>
-              <xsl:value-of select="//dc:identifier.url" />
-          </a></p>
-
-          <xsl:if test="//dc:source" >
-            <p class="info">Tekst opracowany na podstawie: <xsl:value-of select="//dc:source" /></p>
-          </xsl:if>
-
-          <xsl:if test="//dc:description" >
-            <p class="info"><xsl:value-of select="//dc:description" /></p>
-          </xsl:if>
+          <p class="info">Published by <a href="http://nowoczesnapolska.org.pl">Modern Poland Foundation</a>, 2012.</p>
 
           <xsl:call-template name="editors" />
 
           <xsl:if test="@data-cover-by">
-            <p class="info">Okładka na podstawie: 
+            <p class="info">Cover image: 
             <xsl:choose>
             <xsl:when test="@data-cover-source">
                 <a>
             </xsl:choose>
             </p>
           </xsl:if>
-
-          <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">
-              Plik wygenerowany dnia <span id="file_date"><xsl:value-of select="substring(date:date(), 1, 10)" /></span>.
-          </p>
-
         </div>
       </body>
     </html>
   <xsl:template name="editors">
     <xsl:if test="//dc:contributor.editor[text()]|//dc:contributor.technical_editor[text()]">
         <p class="info">
-            <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
+            <xsl:text>Technical editors: </xsl:text>
             <xsl:for-each select="//dc:contributor.editor[text()]|//dc:contributor.technical_editor[text() and not(//dc:contributor.editor/text()=text())]">
                 <xsl:sort />
                 <xsl:if test="position() != 1">, </xsl:if>
diff --git a/librarian/epub/xsltScheme-FoC.xsl b/librarian/epub/xsltScheme-FoC.xsl
new file mode 100755 (executable)
index 0000000..e5c36e3
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <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" />
+
+  <xsl:template match="/" >
+    <xsl:element name="html" xmlns="http://www.w3.org/1999/xhtml">
+      <xsl:element name="head">
+        <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
+        </title>
+      </xsl:element>
+      <xsl:element name="body" xmlns="http://www.w3.org/1999/xhtml">
+        <xsl:element name="div" xmlns="http://www.w3.org/1999/xhtml">
+          <xsl:attribute name="id">book-text</xsl:attribute>
+
+<h2 xmlns="http://www.w3.org/1999/xhtml" class="intitle">Dear readers!</h2>
+
+<p xmlns="http://www.w3.org/1999/xhtml" class="paragraph">It is our great pleasure to present you the “Future of Copyright 
+Anthology”, a collection of 10 best short stories sent in for the “Future 
+of Copyright” contest organized by Modern Poland Foundation. These works 
+have been selected by our jury – Prof. Michael Geist, Piotr Czerski and 
+Jarosław Lipszyc.</p>
+
+<p xmlns="http://www.w3.org/1999/xhtml" class="paragraph">The main prize in this contest was founded by you, the readers, on the 
+Indiegogo crowdfunding platform. We are proud to announce that this 
+prize goes to Aymeric Mansoux, author of “Morphology of a copyright 
+tale”, in appreciation of the originality, power and the strong message 
+of this work. Moreover, the jury decided to grant an honorable mention 
+to Togi, author of the work “Give”.</p>
+
+<p xmlns="http://www.w3.org/1999/xhtml" class="paragraph">We would like to thank you for your crowdfunding support and a high
+standard of the submitted works. We were pleasantly surprised by the
+interest shown in the competition, and we have decided to hold
+its second edition next 
+year. We hope that with your help it will be even more successful and 
+the collected works will provide a strong voice in the debate on the future 
+of copyright law and system.</p>
+
+<p xmlns="http://www.w3.org/1999/xhtml" class="paragraph">Modern Poland Foundation Team</p>
+
+<p xmlns="http://www.w3.org/1999/xhtml" class="paragraph">
+<img xmlns="http://www.w3.org/1999/xhtml" alt="Modern Poland Foundation" src="logo.png" />
+</p>
+
+<p xmlns="http://www.w3.org/1999/xhtml" class="paragraph"><a xmlns="http://www.w3.org/1999/xhtml" href="http://nowoczesnapolska.org.pl">http://nowoczesnapolska.org.pl</a></p>
+
+        </xsl:element>
+      </xsl:element>
+    </xsl:element>
+  </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
index 3ddcf97..e8a5af6 100644 (file)
@@ -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>
-          WolneLektury.pl
+          Future of Copyright
         </title>
       </xsl:element>
       <xsl:element name="body" xmlns="http://www.w3.org/1999/xhtml">
           <xsl:attribute name="id">book-text</xsl:attribute>
           <xsl:if test="//nazwa_utworu">
             <!--h1 xmlns="http://www.w3.org/1999/xhtml"-->
-              <xsl:apply-templates select=" //nazwa_utworu" mode="poczatek"/>
-              <xsl:apply-templates select=" //podtytul" mode="poczatek"/>
+              <xsl:apply-templates select="//dzielo_nadrzedne" mode="poczatek"/>
+              <xsl:apply-templates select="//autor_utworu" mode="poczatek"/>
+              <xsl:apply-templates select="//nazwa_utworu" mode="poczatek"/>
+              <xsl:apply-templates select="//podtytul" mode="poczatek"/>
             <!--/h1-->
           </xsl:if>
           <xsl:apply-templates />
   </xsl:template>
 
   <xsl:template match="naglowek_scena">
-    <a id="sub{@sub}" xmlns="http://www.w3.org/1999/xhtml"></a>
+    <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 id="sub{@sub}" xmlns="http://www.w3.org/1999/xhtml"></a>
+    <a xmlns="http://www.w3.org/1999/xhtml"></a>
     <h2 class="h4" xmlns="http://www.w3.org/1999/xhtml">
       <xsl:apply-templates />
     </h2>
index 17739a8..cc006f2 100644 (file)
@@ -14,7 +14,7 @@
         <link rel="stylesheet" href="style.css" type="text/css" />
         <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
         <title>
-          <xsl:text>Strona tytułowa</xsl:text>
+          <xsl:text>Title page</xsl:text>
         </title>
       </head>
       <body>
@@ -40,7 +40,7 @@
             <p class="info">[Kopia robocza]</p>
           </xsl:if>
 
-          <xsl:if test="not(utwor/@less-advertising)">
+          <!--xsl:if test="not(utwor/@less-advertising)">
             <p class="info">
               <a>
                   <xsl:attribute name="href">
               podobnie jak tysiące innych, jest dostępna on-line na stronie
               <a href="http://www.wolnelektury.pl/">wolnelektury.pl</a>.
             </p>
-          </xsl:if>
+          </xsl:if-->
 
           <p class="info">
+          <xsl:choose>
+          <xsl:when test="//dc:contributor">Thank you for your contribution, <xsl:value-of select="//dc:contributor"/>!</xsl:when>
+          <xsl:otherwise>Thank you for all your contributions!</xsl:otherwise>
+          </xsl:choose>
+          <br/>You made this book possible.
+          </p>
+
+
+          <!--p class="info">
             Utwór opracowany został w&#160;ramach projektu<a href="http://www.wolnelektury.pl/"> Wolne Lektury</a> przez<a href="http://www.nowoczesnapolska.org.pl/"> fundację Nowoczesna Polska</a>.
           </p>
 
           <p class="footer info">
             <a href="http://www.wolnelektury.pl/"><img src="logo_wolnelektury.png" alt="WolneLektury.pl" /></a>
-          </p>
+          </p-->
         </div>
       </body>
     </html>
index 523b3d5..e8758f0 100644 (file)
@@ -19,7 +19,8 @@ def reg_substitute_entities():
         (u'---', u'—'),
         (u'--', u'–'),
         (u'...', u'…'),
-        (u',,', u'„'),
+        #(u',,', u'„'),
+        (u',,', u'“'),
         (u'"', u'”'),
     ]
 
index 1e7569b..6de72b3 100755 (executable)
@@ -9,7 +9,7 @@ import subprocess
 from tempfile import NamedTemporaryFile
 
 from librarian import OutputFile
-from librarian.cover import WLCover
+from librarian.cover import ImageCover as WLCover
 from librarian import get_resource
 
 
@@ -30,8 +30,11 @@ def transform(wldoc, verbose=False,
     # provide a cover by default
     if not cover:
         cover = WLCover
-    cover_file = NamedTemporaryFile(suffix='.png', delete=False)
     c = cover(book_info)
+    import Image
+    c.im = Image.open('cover.jpg')
+    c.ext = lambda: 'jpg'
+    cover_file = NamedTemporaryFile(suffix='.' + c.ext(), delete=False)
     c.save(cover_file)
 
     if cover.uses_dc_cover:
index cb65311..ca18f70 100644 (file)
@@ -21,7 +21,7 @@ from librarian.dcparser import Person
 from librarian.parser import WLDocument
 from librarian import ParseError, DCNS, get_resource, OutputFile
 from librarian import functions
-from librarian.cover import WLCover
+from librarian.cover import ImageCover as WLCover
 
 
 functions.reg_substitute_entities()
@@ -193,9 +193,10 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
         if cover:
             if cover is True:
                 cover = WLCover
-            document.edoc.getroot().set('data-cover-width', str(cover.width))
-            document.edoc.getroot().set('data-cover-height', str(cover.height))
-            if cover.uses_dc_cover:
+            the_cover = cover(document.book_info)
+            document.edoc.getroot().set('data-cover-width', str(the_cover.width))
+            document.edoc.getroot().set('data-cover-height', str(the_cover.height))
+            if the_cover.uses_dc_cover:
                 if document.book_info.cover_by:
                     document.edoc.getroot().set('data-cover-by', document.book_info.cover_by)
                 if document.book_info.cover_source:
@@ -215,10 +216,11 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
             document.edoc.getroot().set('customizations', u','.join(customizations))
 
         # hack the tree
-        move_motifs_inside(document.edoc)
-        hack_motifs(document.edoc)
+        #move_motifs_inside(document.edoc)
+        #hack_motifs(document.edoc)
         parse_creator(document.edoc)
-        substitute_hyphens(document.edoc)
+        if document.book_info.language == 'pol':
+            substitute_hyphens(document.edoc)
         fix_hanging(document.edoc)
 
         # wl -> TeXML
@@ -231,9 +233,8 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
         temp = mkdtemp('-wl2pdf')
 
         if cover:
-            c = cover(document.book_info)
-            with open(os.path.join(temp, 'cover.png'), 'w') as f:
-                c.save(f)
+            with open(os.path.join(temp, 'cover.jpg'), 'w') as f:
+                the_cover.save(f)
 
         del document # no longer needed large object :)
 
@@ -249,6 +250,7 @@ def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
         # LaTeX -> PDF
         shutil.copy(get_resource('pdf/wl.cls'), temp)
         shutil.copy(get_resource('res/wl-logo.png'), temp)
+        shutil.copy('logo.eps', temp)
 
         cwd = os.getcwd()
         os.chdir(temp)
index c387b03..2ddcc71 100644 (file)
 
 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
 \ProcessOptions\relax
-\LoadClass[a4paper,oneside]{book}
+\LoadClass[a4paper]{book}
 
 
 \usepackage{trace}
 
-\usepackage[MeX]{polski}
+%\usepackage[MeX]{polski}
 
 \usepackage[xetex]{graphicx}
 \usepackage{fontspec}
@@ -138,7 +138,8 @@ Letters={SmallCaps,UppercaseSmallCaps}
 
 \setlength{\marginparsep}{2em}
 \setlength{\marginparwidth}{8.5em}
-\setlength{\oddsidemargin}{0pt}
+\setlength{\oddsidemargin}{36mm}
+\setlength{\evensidemargin}{0pt}
 \setlength{\voffset}{0pt}
 \setlength{\topmargin}{0pt}
 \setlength{\headheight}{0pt}
@@ -149,9 +150,11 @@ Letters={SmallCaps,UppercaseSmallCaps}
 \fancyhf{}
 \renewcommand{\headrulewidth}{0pt}
 \renewcommand{\footrulewidth}{0pt}
-\lfoot{{\footnotesize \textsc{\@author} \emph{\@title}}}
+%\lfoot{{\footnotesize \textsc{\@author} \emph{\@title}}}
 \cfoot{}
-\rfoot{{\footnotesize \thepage}}
+%\rfoot{{\footnotesize \thepage}}
+\fancyfoot[LO,RE]{{\footnotesize \textsc{\@author} \emph{\@title}}}
+\fancyfoot[LE,RO]{{\footnotesize \thepage}}
 
 \clubpenalty=100000
 \widowpenalty=100000
@@ -169,8 +172,9 @@ Letters={SmallCaps,UppercaseSmallCaps}
 \raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\usebox{\xglyphbox}}}}
 
 \newcommand{\makecover}[2]{
-        \pdfpagewidth=#1
-        \pdfpageheight=#2
+
+        %\pdfpagewidth=#1
+        %\pdfpageheight=#2
 
         \thispagestyle{empty}
         \newlength{\PictHOffset}
@@ -185,15 +189,34 @@ Letters={SmallCaps,UppercaseSmallCaps}
         \addtolength{\PictVOffset}{\headheight}
         \addtolength{\PictVOffset}{\headsep}
         \addtolength{\PictVOffset}{\topskip}
-        \addtolength{\PictVOffset}{-\pdfpageheight}
+        \addtolength{\PictVOffset}{-#2}
 
         \noindent\hspace*{-\PictHOffset}%
         \raisebox{\PictVOffset}[0pt][0pt]{\makebox[0pt][l]{%
-            \includegraphics[height=\pdfpageheight,width=\pdfpagewidth]{cover.png}}}
-        \clearpage
+            \includegraphics[height=#2,width=#1]{cover.jpg}}}
+        %\clearpage
+        \vspace{#2}
+
+        \hspace{-36mm}\parbox{16cm}{
+        {\addfontfeature{LetterSpace=-4.0}\emph{\scalefont{4}%
+            \noindent Future of Copyright Anthology
+        }}
+
+        \vspace{2em}
+        {\addfontfeature{LetterSpace=-4.0}{\scalefont{1.5}%
+            A collection of texts from a crowd-funded contest.
+        }}
+
+
+        \vspace{8em}
 
-        \setlength{\pdfpagewidth}{210mm}
-        \setlength{\pdfpageheight}{297mm}
+\emph{\thankyou}\\
+\indent\emph{You made this book possible.}
+        }
+
+
+        %\setlength{\pdfpagewidth}{210mm}
+        %\setlength{\pdfpageheight}{297mm}
 }
 
 
@@ -226,7 +249,53 @@ Letters={SmallCaps,UppercaseSmallCaps}
     }
 }
 
+\usepackage{printlen}
+
 \newcommand{\editorialsection}{
+\clearpage
+
+%\set\textwidth=450pt
+%\printlength\textwidth
+
+
+{\scalefont{1.5}Dear readers!}
+
+
+
+\vspace{1em}
+It is our great pleasure to present you the “Future of Copyright 
+Anthology”, a collection of 10 best short stories sent in for the “Future 
+of Copyright” contest organized by Modern Poland Foundation. These works 
+have been selected by our jury – Prof. Michael Geist, Piotr Czerski and 
+Jarosław Lipszyc.
+
+The main prize in this contest was founded by you, the readers, on the 
+Indiegogo crowdfunding platform. We are proud to announce that this 
+prize goes to Aymeric Mansoux, author of “Morphology of a copyright 
+tale”, in appreciation of the originality, power and the strong message 
+of this work. Moreover, the jury decided to grant an honorable mention 
+to Togi, author of the work “Give”.
+
+We would like to thank you for your crowdfunding support and a high
+standard of the submitted works. We were pleasantly surprised by the
+interest shown in the competition, and we have decided to hold
+its second edition next 
+year. We hope that with your help it will be even more successful and 
+the collected works will provide a strong voice in the debate on the future 
+of copyright law and system.
+
+\vspace{1em}
+Modern Poland Foundation Team
+
+\vspace{4em}
+\includegraphics[scale=.2]{logo.eps}
+\vspace{1em}
+
+\href{http://nowoczesnapolska.org.pl/}{http://nowoczesnapolska.org.pl/}
+
+%\vspace{4em}
+%\box{\tableofcontents}
+
   \begin{figure}[b!]
   {
     \footnotesize
@@ -236,17 +305,19 @@ Letters={SmallCaps,UppercaseSmallCaps}
     \rightsinfo
     \vspace{.6em}
 
-    Źródło: \href{\bookurl}{\bookurl}
+    %Źródło: \href{\bookurl}{\bookurl}
 
-    \vspace{.6em}
-    \sourceinfo
+    %\vspace{.6em}
+    %\sourceinfo
 
-    \description
-    \vspace{.6em}
+    %\description
+    %\vspace{.6em}
+
+    Published by \href{http://nowoczesnapolska.org.pl}{Modern Poland Foundation}, 2012.
 
     \editors
 
-    \vspace{.6em}
+    %\vspace{.6em}
     \coverby
 
     \color{black}
@@ -276,10 +347,13 @@ Letters={Uppercase}
 %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}}
 }
 
-
 \newcommand{\tytul}[1]{%
 #1%
-\vspace{1em}%
+%\vspace{1em}%
+}
+
+\newcommand{\autorpodutworu}[1]{%
+\section*{\typosection{#1}}%
 }
 
 \newcommand{\nazwapodutworu}[1]{%
@@ -287,6 +361,7 @@ Letters={Uppercase}
 }
 
 \newcommand{\autorutworu}[1]{%
+\addcontentsline{toc}{part}{???}
 \subsection*{\typosubsection{#1}}%
 }
 
@@ -302,11 +377,14 @@ Letters={Uppercase}
 \subsection*{\typosubsubsection{#1}}%
 }
 
+\newcommand{\podtytulpodutworu}[1]{%
+\subsection*{\typosubsubsection{#1}}%
+}
+
 \newcommand{\translator}[1]{%
 \subsection*{\typosubsubsection{tłum. #1}}%
 }
 
-
 \newcommand{\powiesc}[1]{#1}
 \newcommand{\opowiadanie}[1]{#1}
 \newcommand{\lirykal}[1]{#1}
@@ -316,7 +394,9 @@ Letters={Uppercase}
 \newcommand{\dramatwspolczesny}[1]{#1}
 
 \newcommand{\nota}[1]{%
-\par{#1}%
+\begin{quotation}%
+#1%
+\end{quotation}%
 }
 
 \newcommand{\dedykacja}[1]{%
@@ -367,7 +447,7 @@ Letters={Uppercase}
 \subsection*{\typosubsection{#1}}%
 }
 \newcommand{\naglowekczesc}[1]{%
-\pagebreak
+%\pagebreak
 \subsection*{\typosubsection{#1}}%
 }
 \newcommand{\srodtytul}[1]{%
@@ -469,6 +549,7 @@ Letters={Uppercase}
 \begin{center}%
 \par{*}%
 \end{center}%
+\noindent%
 }
 
 \newcommand{\separatorlinia}{%
index 1a675ba..5b58d61 100644 (file)
         <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
 
         <env name="document">
+            <TeXML escape="0">
+                \def\thankyou{%
+                <xsl:choose>
+                <xsl:when test="//dc:contributor">Thank you for your contribution, <xsl:value-of select="//dc:contributor"/>!</xsl:when>
+                <xsl:otherwise>Thank you for all your contributions!</xsl:otherwise>
+                </xsl:choose>
+                }
+            </TeXML>
+
             <xsl:if test="@data-cover-width">
                 <cmd name="makecover">
-                    <parm><xsl:value-of select="210 * @data-cover-width div @data-cover-height" />mm</parm>
                     <parm>210mm</parm>
+                    <parm><xsl:value-of select="210 * @data-cover-height div @data-cover-width" />mm</parm>
                 </cmd>
             </xsl:if>
-            <cmd name="maketitle" />
+            <!--cmd name="maketitle" /-->
 
-            <cmd name="tytul"><parm>
+            <!--cmd name="tytul"><parm>
               <xsl:choose>
                 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
-                    <!-- title in master -->
+                    <!- title in master ->
                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
-                    <!-- dc in master or not -->
+                    <!- dc in master or not ->
                     <cmd name="translatorsline" />
                 </xsl:when>
                 <xsl:otherwise>
-                    <!-- look for author title in dc -->
+                    <!- look for author title in dc ->
                     <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
                     <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
                 </xsl:otherwise>
               </xsl:choose>
-            </parm></cmd>
-            <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
-            <xsl:apply-templates select="utwor" mode="part" />
+            </parm></cmd-->
 
             <TeXML escape="0">
                 \def\coverby{
-                <xsl:if test="@data-cover-by">Okładka na podstawie: 
+                <xsl:if test="@data-cover-by">Cover image:
                     <xsl:choose>
                     <xsl:when test="@data-cover-source">
-                        \href{\datacoversource}{\datacoverby}
+                        \href{\datacoversource}{\datacoverby}.
                     </xsl:when>
                     <xsl:otherwise>
-                        \datacoverby{}
+                        \datacoverby{}.
                     </xsl:otherwise>
                     </xsl:choose>
                 </xsl:if>
             </TeXML>
 
             <cmd name="editorialsection" />
+
+            <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
+            <xsl:apply-templates select="utwor" mode="part" />
         </env>
     </TeXML>
 </xsl:template>
 
 <xsl:template match="utwor" mode="part">
+    <cmd name="newpage" />
     <cmd name="tytul"><parm>
+
+    <!-- Dirty! -->
+    <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/motyw" mode="inline"/>
+
       <xsl:choose>
         <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
             <!-- title in master -->
+            <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
+            <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
         </xsl:when>
             \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
             Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
         <xsl:if test=".//dc:rights.license">
-            \def\rightsinfo{Ten utwór jest udostepniony na licencji
+            \def\rightsinfo{This book is available under the terms of
             \href{<xsl:value-of select=".//dc:rights.license" />}{<xsl:value-of select=".//dc:rights" />}.}
         </xsl:if>
 
 </xsl:template>
 
 <xsl:template name="editors">
-    <xsl:if test="//dc:contributor.editor_parsed|//dc:contributor.technical_editor_parsed">
-        <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
-        <xsl:for-each select="//dc:contributor.editor_parsed|//dc:contributor.technical_editor_parsed[not(//dc:contributor.editor_parsed/text()=text())]">
-            <xsl:sort select="@sortkey" />
+    <xsl:if test=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed">
+        <xsl:text>Technical editors: </xsl:text>
+        <xsl:for-each select=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed[not(.//dc:contributor.editor_parsed/text()=text())]">
+            <!--xsl:sort select="@sortkey" /-->
             <xsl:if test="position() != 1">, </xsl:if>
             <xsl:apply-templates mode="inline" />
         </xsl:for-each>.
index 258c20d..37fcb17 100755 (executable)
@@ -52,7 +52,7 @@ if __name__ == '__main__':
             doc = WLDocument.from_file(main_input, provider=provider)
             pdf = doc.as_pdf(save_tex=options.save_tex,
                         cover=options.with_cover,
-                        morefloats=options.morefloats)
+                        morefloats=options.morefloats, verbose=options.verbose)
 
             doc.save_output_file(pdf,
                 output_file, options.output_dir, options.make_dir, 'pdf')