XHTMLNS = XMLNamespace("http://www.w3.org/1999/xhtml")
NCXNS = XMLNamespace("http://www.daisy.org/z3986/2005/ncx/")
OPFNS = XMLNamespace("http://www.idpf.org/2007/opf")
+PLMETNS = XMLNamespace("http://dl.psnc.pl/schemas/plmet/")
WLNS = EmptyNamespace()
from librarian.util import roman_to_int
from librarian import (ValidationError, NoDublinCore, ParseError, DCNS, RDFNS,
- XMLNS, WLURI, WLNS)
+ XMLNS, WLURI, WLNS, PLMETNS)
import lxml.etree as etree # ElementTree API using libxml2
from lxml.etree import XMLSyntaxError
Field( DCNS('identifier.url'), 'url', WLURI, strict=as_wluri_strict),
Field( DCNS('rights.license'), 'license', required=False),
Field( DCNS('rights'), 'license_description'),
+
+ Field( PLMETNS('digitisationSponsor'), 'sponsors', multiple=True, default=[]),
+ Field( WLNS('digitisationSponsorNote'), 'sponsor_note', required=False),
)
@classmethod
from librarian import ParseError, DCNS, get_resource, OutputFile
from librarian import functions
from librarian.cover import DefaultEbookCover
+from .sponsor import sponsor_logo
functions.reg_substitute_entities()
style_filename = get_stylesheet("wl2tex")
style = etree.parse(style_filename)
- texml = document.transform(style)
-
# TeXML -> LaTeX
temp = mkdtemp('-wl2pdf')
+ for sponsor in book_info.sponsors:
+ ins = etree.Element("data-sponsor", name=sponsor)
+ logo = sponsor_logo(sponsor)
+ if logo:
+ fname = 'sponsor-%s' % os.path.basename(logo)
+ shutil.copy(logo, os.path.join(temp, fname))
+ ins.set('src', fname)
+ root.insert(0, ins)
+
+ if book_info.sponsor_note:
+ root.set("sponsor-note", book_info.sponsor_note)
+
+ texml = document.transform(style)
+
if cover:
with open(os.path.join(temp, 'cover.png'), 'w') as f:
bound_cover.save(f)
\pagestyle{plain}
\usepackage{fancyhdr}
+\usepackage{marginnote}
+
\makeatletter
\color{theme}
\noindent \rule{\linewidth}{0.4pt}
+ \ifdefined\sponsors
+ \marginnote{%
+ \centering%
+ \sponsors%
+ }
+ \fi
+
\rightsinfo
\vspace{.6em}
\def\funders{Publikację ufundowali i ufundowały:
<TeXML escape="1"><xsl:value-of select="@funders" /></TeXML>.}
</xsl:if>
+
+ <xsl:if test="@sponsor-note|data-sponsor">
+ \def\sponsors{
+ \scriptsize
+ <xsl:choose>
+ <xsl:when test="@sponsor-note">
+ <TeXML escape="1"><xsl:value-of select="@sponsor-note" /></TeXML>
+ </xsl:when>
+ <xsl:otherwise>
+ Sfinansowano ze~środków:
+ </xsl:otherwise>
+ </xsl:choose>
+
+ \vspace{1em}
+
+ <xsl:apply-templates select="data-sponsor" mode="sponsor" />
+ }
+ </xsl:if>
</TeXML>
<cmd name="editorialsection" />
</xsl:if>
</xsl:template>
+<xsl:template match="data-sponsor" mode="sponsor">
+ <cmd name="par"><parm>
+ <xsl:choose>
+ <xsl:when test="@src">
+ \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@name" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </parm></cmd>
+</xsl:template>
<!-- ============== -->
<!-- = ADDED TAGS = -->
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from librarian import get_resource
+
+def sponsor_logo(name):
+ return {
+ 'Narodowe Centrum Kultury': get_resource('res/sponsors/nck.png')
+ }.get(name.strip())
maintainer_email='radoslaw.czajka@nowoczesnapolska.org.pl',
url='http://github.com/fnp/librarian',
packages=['librarian'],
- package_data={'librarian': ['xslt/*.xslt', 'epub/*', 'mobi/*', 'pdf/*', 'fb2/*', 'fonts/*', 'res/*'] +
+ package_data={'librarian': ['xslt/*.xslt', 'epub/*', 'mobi/*', 'pdf/*', 'fb2/*', 'fonts/*'] +
+ whole_tree(os.path.join(os.path.dirname(__file__), 'librarian'), 'res') +
whole_tree(os.path.join(os.path.dirname(__file__), 'librarian'), 'font-optimizer')},
include_package_data=True,
install_requires=[