From a2f8ee881d66601e9cb714069dc88d3ed9703db6 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 19 Jan 2011 16:47:33 +0100 Subject: [PATCH] #961: full info in all formats; epub: less-advertising flag some fixes --- librarian/epub.py | 8 ++- librarian/epub/style.css | 22 ++++++++ librarian/epub/xsltLast.xsl | 29 +++++++---- librarian/epub/xsltScheme.xsl | 4 +- librarian/epub/xsltTitle.xsl | 24 ++++++--- librarian/html.py | 1 + librarian/pdf.py | 20 +++---- librarian/pdf/wl.sty | 60 ++++++++++++++------- librarian/pdf/wl2tex.xslt | 98 +++++++++++++++++++++++++++-------- librarian/text.py | 25 ++++++--- librarian/xslt/book2html.xslt | 35 ++++++++++++- librarian/xslt/book2txt.xslt | 36 +++++++++---- scripts/book2partner | 3 +- 13 files changed, 275 insertions(+), 90 deletions(-) diff --git a/librarian/epub.py b/librarian/epub.py index ad84ab0..527d050 100644 --- a/librarian/epub.py +++ b/librarian/epub.py @@ -265,7 +265,8 @@ def transform_chunk(chunk_xml, chunk_no, annotations, empty=False, _empty_html_s return output_html, toc, chars -def transform(provider, slug=None, file_path=None, output_file=None, output_dir=None, make_dir=False, verbose=False, sample=None, cover_fn=None): +def transform(provider, slug=None, file_path=None, output_file=None, output_dir=None, make_dir=False, verbose=False, + sample=None, cover_fn=None, flags=None): """ produces a EPUB file provider: a DocProvider @@ -275,6 +276,7 @@ def transform(provider, slug=None, file_path=None, output_file=None, output_dir= make_dir: writes output to //.epub instead of /.epub sample=n: generate sample e-book (with at least n paragraphs) cover_fn: function(author, title) -> cover image + flags: less-advertising, """ def transform_file(input_xml, chunk_counter=1, first=True, sample=None): @@ -355,6 +357,10 @@ def transform(provider, slug=None, file_path=None, output_file=None, output_dir= raise ValueError('either slug or file_path should be specified') input_xml = etree.parse(provider[slug]) + if flags: + for flag in flags: + input_xml.getroot().set(flag, 'yes') + metadata = input_xml.find('.//'+RDFNS('Description')) if metadata is None: raise NoDublinCore('Document has no DublinCore - which is required.') diff --git a/librarian/epub/style.css b/librarian/epub/style.css index 55ac117..fd98f07 100644 --- a/librarian/epub/style.css +++ b/librarian/epub/style.css @@ -183,6 +183,28 @@ p margin-bottom: 0.25em; } +.intitle +{ + margin: 0; + text-align: center; + font-weight: bold; + + font-size: 1.5em; + line-height: 1.5em; + margin-bottom: 0.25em; +} + +.insubtitle +{ + margin: 0; + text-align: center; + font-weight: bold; + + font-size: 1em; + line-height: 1.5em; + margin-bottom: 0.25em; +} + .collection { margin: 0; diff --git a/librarian/epub/xsltLast.xsl b/librarian/epub/xsltLast.xsl index 6cb2748..3949878 100644 --- a/librarian/epub/xsltLast.xsl +++ b/librarian/epub/xsltLast.xsl @@ -33,12 +33,12 @@ Ten utwór nie jest chroniony prawem autorskim i znajduje się w domenie - publicznej, co oznacza, że możesz go swobodnie wykorzystywać, publikować + publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować i rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami - (przypisy, motywy literackie etc.) które podlegają prawu autorskiemu, to + (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to te dodatkowe materiały udostępnione są na licencji Creative Commons - Uznanie Autorstwa - Na Tych Samych Warunkach 3.0 PL. + Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL.

@@ -54,16 +54,15 @@

-

Na podstawie:

+

Tekst opracowany na podstawie:

- -

- Opracowanie redakcyjne i przypisy: - -

+ +

+ +

 

Plik wygenerowany dnia . @@ -78,6 +77,18 @@ + + +

+ Opracowanie redakcyjne i przypisy: + + , + + . +

+
+ +
diff --git a/librarian/epub/xsltScheme.xsl b/librarian/epub/xsltScheme.xsl index 8b384c3..1543268 100644 --- a/librarian/epub/xsltScheme.xsl +++ b/librarian/epub/xsltScheme.xsl @@ -94,7 +94,7 @@ -

+

@@ -102,7 +102,7 @@ -

+

diff --git a/librarian/epub/xsltTitle.xsl b/librarian/epub/xsltTitle.xsl index 347f038..53bbb1a 100644 --- a/librarian/epub/xsltTitle.xsl +++ b/librarian/epub/xsltTitle.xsl @@ -34,9 +34,10 @@

 

- + - +

+

- Utwór opracowany został w ramach projektu Wolne Lektury przez Fundację Nowoczesna Polska. + Utwór opracowany został w ramach projektu Wolne Lektury przez fundację Nowoczesna Polska.

- tłum. -

+ + +

+ tłum. + + , + + +

+
diff --git a/librarian/html.py b/librarian/html.py index 4e9abd0..1f0615f 100644 --- a/librarian/html.py +++ b/librarian/html.py @@ -16,6 +16,7 @@ from librarian import functions from lxml.etree import XMLSyntaxError, XSLTApplyError functions.reg_substitute_entities() +functions.reg_person_name() STYLESHEETS = { 'legacy': 'xslt/book2html.xslt', diff --git a/librarian/pdf.py b/librarian/pdf.py index baf7be4..f8a4d73 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -128,13 +128,15 @@ def hack_motifs(doc): def parse_creator(doc): - """ find all dc:creator tags and add dc:creator_parsed with forenames first """ - for creator in doc.findall('//'+DCNS('creator')): - p = Person.from_text(creator.text) - creator_parsed = deepcopy(creator) - creator_parsed.tag = DCNS('creator_parsed') - creator_parsed.text = ' '.join(p.first_names + (p.last_name,)) - creator.getparent().insert(0, creator_parsed) + """ find all dc:creator and dc.contributor tags and add *_parsed versions with forenames first """ + for person in doc.xpath("|".join('//dc:'+(tag) for tag in ( + 'creator', 'contributor.translator', 'contributor.editor', 'contributor.technical_editor')), + namespaces = {'dc': str(DCNS)})[::-1]: + p = Person.from_text(person.text) + person_parsed = deepcopy(person) + person_parsed.tag = person.tag + '_parsed' + person_parsed.text = p.readable() + person.getparent().insert(0, person_parsed) def get_stylesheet(name): @@ -286,9 +288,9 @@ def load_including_children(provider, slug=None, uri=None, file_path=None): parse_dublincore=True) f.close() - + print document.book_info for child_uri in document.book_info.parts: + print child_uri child = load_including_children(provider, uri=child_uri) document.edoc.getroot().append(child.edoc.getroot()) - return document diff --git a/librarian/pdf/wl.sty b/librarian/pdf/wl.sty index a7a97ba..3a8016f 100644 --- a/librarian/pdf/wl.sty +++ b/librarian/pdf/wl.sty @@ -111,36 +111,45 @@ Letters={SmallCaps,UppercaseSmallCaps} \href{http://www.wolnelektury.pl}{\xbox{\includegraphics[width=\textwidth]{wl-logo.png}}} \end{minipage} \begin{minipage}[t]{.65\textwidth}\vspace{0pt} - Na podstawie: \sourceinfo + \href{\bookurl}{Ta lektura}, podobnie jak tysiące innych, jest dostępna on-line na stronie + \href{http://www.wolnelektury.pl/}{wolnelektury.pl}. \vspace{.5em} - Wersja lektury on-line dostępna jest \href{\bookurl}{na stronie wolnelektury.pl}. - \vspace{.5em} - - \rightsinfo - - \vspace{.6em} + Utwór opracowany został w ramach projektu \href{http://www.wolnelektury.pl/}{Wolne Lektury} + przez \href{http://nowoczesnapolska.org.pl}{fundację Nowoczesna Polska}. \end{minipage} \noindent \rule{\linewidth}{0.4pt} \vspace{.6em} \color{black} + } +} + +\newcommand{\editorialsection}{ + \begin{figure}[b!] + { + \footnotesize + \color{theme} + \noindent \rule{\linewidth}{0.4pt} -% \begin{figure}[b!] -% \footnotesize -% \color{theme} -% \noindent \rule{\linewidth}{0.4pt} + \rightsinfo + \vspace{.6em} -% Szkolna biblioteka internetowa Wolne Lektury tworzona jest dzięki pracy Wolontariuszy, ale to osoby -% zatrudnione w~FNP będą musiały wymyślić, co powinno zostać napisane w~tym miejscu. Można zupełnie usunąć -% tę sekcję, ale autor konwertera chciał się popisać, że umie coś takiego zrobić. -% \color{black} -% \end{figure} - } + \sourceinfo + + \description + \vspace{.6em} + + Opracowanie redakcyjne i przypisy: \editors. + + \color{black} + } + \end{figure} } + \newcommand{\typosubsubsection}[1]{% {\textsc{#1}} } @@ -162,6 +171,12 @@ Letters={Uppercase} %{\addfontfeature{Scale=2.0, FakeStretch=0.98, LetterSpace=-2.0}\emph{#1}} } + +\newcommand{\tytul}[1]{% +#1% +\vspace{1em}% +} + \newcommand{\nazwapodutworu}[1]{% \section*{\typosection{#1}}% } @@ -170,14 +185,23 @@ Letters={Uppercase} \subsection*{\typosubsection{#1}}% } +\newcommand{\dzielonadrzedne}[1]{% +\subsection*{\typosubsubsection{#1}}% +} + \newcommand{\nazwautworu}[1]{% \section*{\typosection{#1}}% } \newcommand{\podtytul}[1]{% -\subsection*{\typosubsection{#1}}% +\subsection*{\typosubsubsection{#1}}% } +\newcommand{\translator}[1]{% +\subsection*{\typosubsubsection{tłum. #1}}% +} + + \newcommand{\powiesc}[1]{#1} \newcommand{\opowiadanie}[1]{#1} \newcommand{\lirykal}[1]{#1} diff --git a/librarian/pdf/wl2tex.xslt b/librarian/pdf/wl2tex.xslt index c3abdd6..4ca109e 100644 --- a/librarian/pdf/wl2tex.xslt +++ b/librarian/pdf/wl2tex.xslt @@ -46,35 +46,46 @@ - + + - + + + + + + - + + + - - + + + + - + + @@ -90,21 +101,33 @@ - - - - - - - \def\sourceinfo{} + \def\authors{} + \author{\authors} + \title{} + \def\translatorsline{} + \def\bookurl{} - \def\rightsinfo{Ten utwór nie jest chroniony prawem autorskim i~znajduje się w~domenie publicznej, - co oznacza, że możesz go swobodnie wykorzystywać, publikować i~rozpowszechniać.} + + \def\rightsinfo{Ten utwór nie jest chroniony prawem autorskim i~znajduje się w~domenie + publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować + i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami + (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to + te dodatkowe materiały udostępnione są na licencji + \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons + Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.} \def\rightsinfo{Ten utwór jest udostepniony na licencji \href{}{}.} + + \def\sourceinfo{ + + Tekst opracowany na podstawie: + \vspace{.6em} + } + \def\description{} + \def\editors{} @@ -129,12 +152,11 @@
- - - + + @@ -177,15 +199,20 @@ - - - - + + + + + + + + match="naglowek_akt|naglowek_czesc|srodtytul|naglowek_osoba|naglowek_podrozdzial|naglowek_scena|naglowek_rozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_dialog|akap_cd|motto_podpis|naglowek_listy"> @@ -305,6 +332,31 @@ + + + , + + + + + + + , + + + + + + + + + , + + + + + + diff --git a/librarian/text.py b/librarian/text.py index e1ca26b..64c956e 100644 --- a/librarian/text.py +++ b/librarian/text.py @@ -11,20 +11,23 @@ import os functions.reg_substitute_entities() functions.reg_wrap_words() functions.reg_strip() +functions.reg_person_name() TEMPLATE = u"""\ -Kodowanie znaków w dokumencie: UTF-8. ------ -%(description)s +%(text)s -%(license_description)s.%(source)s -Wersja lektury w opracowaniu merytorycznym i krytycznym (przypisy i motywy) dostępna jest na stronie %(url)s. ----- +Ta lektura, podobnie jak tysiące innych, dostępna jest na stronie wolnelektury.pl. +Wersja lektury w opracowaniu merytorycznym i krytycznym (przypisy i motywy) dostępna jest na stronie %(url)s. +Utwór opracowany został w ramach projektu Wolne Lektury przez fundację Nowoczesna Polska. +%(license_description)s.%(source)s -%(text)s +%(description)s + +Opracowanie redakcyjne i przypisy: %(contributors)s """ def transform(input_file, output_file, parse_dublincore=True, **options): @@ -40,28 +43,34 @@ def transform(input_file, output_file, parse_dublincore=True, **options): parsed_dc = dcparser.BookInfo.from_element(document.edoc) description = parsed_dc.description url = parsed_dc.url + license_description = parsed_dc.license_description license = parsed_dc.license if license: license_description = u"Ten utwór jest udostepniony na licencji %s: \n%s" % (license_description, license) else: - license_description = u"Ten utwór nie jest chroniony prawem autorskim i znajduje się w domenie publicznej, co oznacza, że możesz go swobodnie wykorzystywać, publikować i rozpowszechniać" + license_description = u"Ten utwór nie jest chroniony prawem autorskim i znajduje się w domenie publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować i rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to te dodatkowe materiały udostępnione są na licencji Creative Commons Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL (http://creativecommons.org/licenses/by-sa/3.0/)" + source = parsed_dc.source_name if source: - source = "\n\nNa podstawie: " + source + source = "\n\nTekst opracowany na podstawie: " + source else: source = '' + + contributors = ', '.join(person.readable() for person in (parsed_dc.technical_editors + parsed_dc.editors)) else: description = 'Publikacja zrealizowana w ramach projektu Wolne Lektury (http://wolnelektury.pl).' url = '*' * 10 license = "" license_description = "" source = "" + contributors = "" output_file.write((TEMPLATE % { 'description': description, 'url': url, 'license_description': license_description, 'text': unicode(result), 'source': source, + 'contributors': contributors, }).encode('utf-8')) diff --git a/librarian/xslt/book2html.xslt b/librarian/xslt/book2html.xslt index 0f9b665..682ed9b 100755 --- a/librarian/xslt/book2html.xslt +++ b/librarian/xslt/book2html.xslt @@ -6,7 +6,8 @@ --> + xmlns:wl="http://wolnelektury.pl/functions" + xmlns:dc="http://purl.org/dc/elements/1.1/" > @@ -100,7 +101,7 @@ } - #toc, #themes, #nota_red { + #toc, #themes, #nota_red, #info { position: fixed; left: 0em; top: 1.5em; @@ -148,6 +149,11 @@ position: inherit; } + #info p { + text-align: justify; + margin: 1.5em 0 0; + } + /* =================================================== */ /* = Common elements: headings, paragraphs and lines = */ /* =================================================== */ @@ -285,6 +291,13 @@ margin-top: -0.25em; } + span.translator { + font-size: 0.375em; + display: block; + line-height: 1.5em; + margin-top: 0.25em; + } + div.didaskalia { font-style: italic; margin: 0.5em 0 0 1.5em; @@ -426,6 +439,7 @@

+

@@ -662,6 +676,23 @@
+ + + + tłum. + + , + + + + + + + + + + + diff --git a/librarian/xslt/book2txt.xslt b/librarian/xslt/book2txt.xslt index 15438a5..604b8bd 100755 --- a/librarian/xslt/book2txt.xslt +++ b/librarian/xslt/book2txt.xslt @@ -6,7 +6,8 @@ --> + xmlns:wl="http://wolnelektury.pl/functions" + xmlns:dc="http://purl.org/dc/elements/1.1/" > @@ -17,11 +18,16 @@ - + + + + + + + - @@ -79,30 +85,28 @@ + - + - - + - - + - @@ -298,6 +302,20 @@ + + + tłum. + + + , + + + + + + + + diff --git a/scripts/book2partner b/scripts/book2partner index 6f2beac..786c2c2 100755 --- a/scripts/book2partner +++ b/scripts/book2partner @@ -101,7 +101,8 @@ def asbis(filenames, output_dir, verbose): except: pass outfile = os.path.join(output_dir, slug + '.epub') - epub.transform(provider, file_path=main_input, output_file=outfile, cover_fn=cover.asbis_cover) + epub.transform(provider, file_path=main_input, output_file=outfile, + cover_fn=cover.asbis_cover, flags=('less-advertising',)) except ParseError, e: print '%(file)s:%(name)s:%(message)s' % { 'file': main_input, -- 2.20.1