fnp
/
librarian.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
84b5391
)
Use cover with logos by default.
author
Radek Czajka
<radekczajka@nowoczesnapolska.org.pl>
Fri, 3 Jan 2014 16:01:23 +0000
(17:01 +0100)
committer
Radek Czajka
<radekczajka@nowoczesnapolska.org.pl>
Fri, 3 Jan 2014 16:01:23 +0000
(17:01 +0100)
librarian/book2anything.py
patch
|
blob
|
history
librarian/cover.py
patch
|
blob
|
history
librarian/epub.py
patch
|
blob
|
history
librarian/mobi.py
patch
|
blob
|
history
librarian/parser.py
patch
|
blob
|
history
librarian/pdf.py
patch
|
blob
|
history
diff --git
a/librarian/book2anything.py
b/librarian/book2anything.py
index
b8b8d27
..
9a246ae
100755
(executable)
--- a/
librarian/book2anything.py
+++ b/
librarian/book2anything.py
@@
-10,7
+10,7
@@
import optparse
from librarian import DirDocProvider, ParseError
from librarian.parser import WLDocument
from librarian import DirDocProvider, ParseError
from librarian.parser import WLDocument
-from librarian.cover import
WL
Cover
+from librarian.cover import
DefaultEbook
Cover
class Option(object):
class Option(object):
@@
-100,10
+100,10
@@
class Book2Anything(object):
if cls.uses_cover:
if options.image_cache:
def cover_class(*args, **kwargs):
if cls.uses_cover:
if options.image_cache:
def cover_class(*args, **kwargs):
- return
WL
Cover(image_cache=options.image_cache, *args, **kwargs)
+ return
DefaultEbook
Cover(image_cache=options.image_cache, *args, **kwargs)
transform_args['cover'] = cover_class
elif not cls.cover_optional or options.with_cover:
transform_args['cover'] = cover_class
elif not cls.cover_optional or options.with_cover:
- transform_args['cover'] =
WL
Cover
+ transform_args['cover'] =
DefaultEbook
Cover
# Do some real work
# Do some real work
diff --git
a/librarian/cover.py
b/librarian/cover.py
index
9b10ed1
..
d1b2cc0
100644
(file)
--- a/
librarian/cover.py
+++ b/
librarian/cover.py
@@
-125,6
+125,7
@@
class Cover(object):
format = 'JPEG'
scale = 1
format = 'JPEG'
scale = 1
+ scale_after = 1
exts = {
'JPEG': 'jpg',
exts = {
'JPEG': 'jpg',
@@
-142,8
+143,10
@@
class Cover(object):
if format is not None:
self.format = format
scale = max(float(width or 0) / self.width, float(height or 0) / self.height)
if format is not None:
self.format = format
scale = max(float(width or 0) / self.width, float(height or 0) / self.height)
- if scale:
+ if scale
>= 1
:
self.scale = scale
self.scale = scale
+ elif scale:
+ self.scale_after = scale
def pretty_author(self):
"""Allows for decorating author's name."""
def pretty_author(self):
"""Allows for decorating author's name."""
@@
-195,6
+198,15
@@
class Cover(object):
return img
return img
+ def final_image(self):
+ img = self.image()
+ if self.scale_after != 1:
+ img = img.resize((
+ int(round(img.size[0] * self.scale_after)),
+ int(round(img.size[1] * self.scale_after))),
+ Image.ANTIALIAS)
+ return img
+
def mime_type(self):
return self.mime_types[self.format]
def mime_type(self):
return self.mime_types[self.format]
@@
-202,7
+214,7
@@
class Cover(object):
return self.exts[self.format]
def save(self, *args, **kwargs):
return self.exts[self.format]
def save(self, *args, **kwargs):
- return self.image().save(format=self.format, quality=95, *args, **kwargs)
+ return self.
final_
image().save(format=self.format, quality=95, *args, **kwargs)
def output_file(self, *args, **kwargs):
imgstr = StringIO()
def output_file(self, *args, **kwargs):
imgstr = StringIO()
@@
-211,7
+223,7
@@
class Cover(object):
class WLCover(Cover):
class WLCover(Cover):
- """
Default Wolne Lektury cover generator
."""
+ """
Wolne Lektury cover without logos
."""
width = 600
height = 833
uses_dc_cover = True
width = 600
height = 833
uses_dc_cover = True
@@
-483,3
+495,7
@@
class GandalfCover(Cover):
logo_bottom = 25
logo_width = 250
format = 'PNG'
logo_bottom = 25
logo_width = 250
format = 'PNG'
+
+
+DefaultEbookCover = LogoWLCover
+
diff --git
a/librarian/epub.py
b/librarian/epub.py
index
bfd7570
..
2da6b31
100644
(file)
--- a/
librarian/epub.py
+++ b/
librarian/epub.py
@@
-17,7
+17,7
@@
from tempfile import mkdtemp, NamedTemporaryFile
from shutil import rmtree
from librarian import RDFNS, WLNS, NCXNS, OPFNS, XHTMLNS, OutputFile
from shutil import rmtree
from librarian import RDFNS, WLNS, NCXNS, OPFNS, XHTMLNS, OutputFile
-from librarian.cover import
WL
Cover
+from librarian.cover import
DefaultEbook
Cover
from librarian import functions, get_resource
from librarian import functions, get_resource
@@
-448,7
+448,7
@@
def transform(wldoc, verbose=False,
if cover:
if cover is True:
if cover:
if cover is True:
- cover =
WL
Cover
+ cover =
DefaultEbook
Cover
cover_file = StringIO()
bound_cover = cover(document.book_info)
cover_file = StringIO()
bound_cover = cover(document.book_info)
diff --git
a/librarian/mobi.py
b/librarian/mobi.py
index
d98b838
..
74018b3
100644
(file)
--- a/
librarian/mobi.py
+++ b/
librarian/mobi.py
@@
-9,7
+9,7
@@
import subprocess
from tempfile import NamedTemporaryFile
from librarian import OutputFile
from tempfile import NamedTemporaryFile
from librarian import OutputFile
-from librarian.cover import
WL
Cover
+from librarian.cover import
DefaultEbook
Cover
from librarian import get_resource
from librarian import get_resource
@@
-29,7
+29,7
@@
def transform(wldoc, verbose=False,
# provide a cover by default
if not cover:
# provide a cover by default
if not cover:
- cover =
WL
Cover
+ cover =
DefaultEbook
Cover
cover_file = NamedTemporaryFile(suffix='.png', delete=False)
bound_cover = cover(book_info)
bound_cover.save(cover_file)
cover_file = NamedTemporaryFile(suffix='.png', delete=False)
bound_cover = cover(book_info)
bound_cover.save(cover_file)
@@
-57,4
+57,4
@@
def transform(wldoc, verbose=False,
subprocess.check_call(['ebook-convert', epub.get_filename(), output_file.name,
'--no-inline-toc', '--cover=%s' % cover_file.name], **kwargs)
os.unlink(cover_file.name)
subprocess.check_call(['ebook-convert', epub.get_filename(), output_file.name,
'--no-inline-toc', '--cover=%s' % cover_file.name], **kwargs)
os.unlink(cover_file.name)
- return OutputFile.from_filename(output_file.name)
\ No newline at end of file
+ return OutputFile.from_filename(output_file.name)
diff --git
a/librarian/parser.py
b/librarian/parser.py
index
a9e8c65
..
e06c4d7
100644
(file)
--- a/
librarian/parser.py
+++ b/
librarian/parser.py
@@
-5,7
+5,7
@@
#
from librarian import ValidationError, NoDublinCore, ParseError, NoProvider
from librarian import RDFNS
#
from librarian import ValidationError, NoDublinCore, ParseError, NoProvider
from librarian import RDFNS
-from librarian.cover import
WL
Cover
+from librarian.cover import
DefaultEbook
Cover
from librarian import dcparser
from xml.parsers.expat import ExpatError
from librarian import dcparser
from xml.parsers.expat import ExpatError
@@
-208,7
+208,7
@@
class WLDocument(object):
def as_cover(self, cover_class=None, *args, **kwargs):
if cover_class is None:
def as_cover(self, cover_class=None, *args, **kwargs):
if cover_class is None:
- cover_class =
WL
Cover
+ cover_class =
DefaultEbook
Cover
return cover_class(self.book_info, *args, **kwargs).output_file()
def save_output_file(self, output_file, output_path=None,
return cover_class(self.book_info, *args, **kwargs).output_file()
def save_output_file(self, output_file, output_path=None,
diff --git
a/librarian/pdf.py
b/librarian/pdf.py
index
b4edfdb
..
2154985
100644
(file)
--- a/
librarian/pdf.py
+++ b/
librarian/pdf.py
@@
-27,7
+27,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.parser import WLDocument
from librarian import ParseError, DCNS, get_resource, OutputFile
from librarian import functions
-from librarian.cover import
WL
Cover
+from librarian.cover import
DefaultEbook
Cover
functions.reg_substitute_entities()
functions.reg_substitute_entities()
@@
-204,7
+204,7
@@
def transform(wldoc, verbose=False, save_tex=None, morefloats=None,
if cover:
if cover is True:
if cover:
if cover is True:
- cover =
WL
Cover
+ cover =
DefaultEbook
Cover
bound_cover = cover(book_info)
root.set('data-cover-width', str(bound_cover.width))
root.set('data-cover-height', str(bound_cover.height))
bound_cover = cover(book_info)
root.set('data-cover-width', str(bound_cover.width))
root.set('data-cover-height', str(bound_cover.height))