fnp
/
librarian.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c7734da
)
Change default cover.
author
Radek Czajka
<rczajka@rczajka.pl>
Thu, 22 Jun 2023 07:24:44 +0000
(09:24 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Thu, 22 Jun 2023 07:24:44 +0000
(09:24 +0200)
setup.py
patch
|
blob
|
history
src/librarian/cover.py
patch
|
blob
|
history
src/librarian/covers/utils/textbox.py
patch
|
blob
|
history
src/librarian/covers/widgets/author.py
patch
|
blob
|
history
src/librarian/covers/widgets/background.py
patch
|
blob
|
history
src/librarian/covers/widgets/base.py
patch
|
blob
|
history
diff --git
a/setup.py
b/setup.py
index
267195f
..
c300f27
100755
(executable)
--- a/
setup.py
+++ b/
setup.py
@@
-22,7
+22,7
@@
def whole_tree(prefix, path):
setup(
name='librarian',
setup(
name='librarian',
- version='2.
5.1
',
+ version='2.
6
',
description='Converter from WolneLektury.pl XML-based language to XHTML, TXT and other formats',
author="Marek Stępniowski",
author_email='marek@stepniowski.com',
description='Converter from WolneLektury.pl XML-based language to XHTML, TXT and other formats',
author="Marek Stępniowski",
author_email='marek@stepniowski.com',
diff --git
a/src/librarian/cover.py
b/src/librarian/cover.py
index
4fd3d45
..
0e9b079
100644
(file)
--- a/
src/librarian/cover.py
+++ b/
src/librarian/cover.py
@@
-989,7
+989,7
@@
class FactoryCover(LogoWLCover):
from librarian.covers.marquise import MarquiseCover, LabelMarquiseCover
COVER_CLASSES = {
from librarian.covers.marquise import MarquiseCover, LabelMarquiseCover
COVER_CLASSES = {
- '
default
': LogoWLCover,
+ '
legacy
': LogoWLCover,
'kmlu': KMLUCover,
'mpw': MPWCover,
'atrium': AtriumCover,
'kmlu': KMLUCover,
'mpw': MPWCover,
'atrium': AtriumCover,
@@
-1000,6
+1000,7
@@
COVER_CLASSES = {
'factory': FactoryCover,
'm': MarquiseCover,
'm-label': LabelMarquiseCover,
'factory': FactoryCover,
'm': MarquiseCover,
'm-label': LabelMarquiseCover,
+ 'default': MarquiseCover,
}
}
diff --git
a/src/librarian/covers/utils/textbox.py
b/src/librarian/covers/utils/textbox.py
index
a5097ed
..
cc9c501
100644
(file)
--- a/
src/librarian/covers/utils/textbox.py
+++ b/
src/librarian/covers/utils/textbox.py
@@
-80,6
+80,8
@@
class TextBox:
def find_grouping(self, groups, ngroups, glue):
best = None
best_var = None
def find_grouping(self, groups, ngroups, glue):
best = None
best_var = None
+ if not groups:
+ return []
mean = sum(g[0] for g in groups) + (len(groups) - ngroups) * glue
if mean > self.width * ngroups:
mean = sum(g[0] for g in groups) + (len(groups) - ngroups) * glue
if mean > self.width * ngroups:
diff --git
a/src/librarian/covers/widgets/author.py
b/src/librarian/covers/widgets/author.py
index
5fa3528
..
4060999
100644
(file)
--- a/
src/librarian/covers/widgets/author.py
+++ b/
src/librarian/covers/widgets/author.py
@@
-31,6
+31,7
@@
class AuthorBox(Widget):
authors = [a.readable() for a in self.cover.book_info.authors]
translators = [a.readable() for a in self.cover.book_info.translators]
authors = [a.readable() for a in self.cover.book_info.authors]
translators = [a.readable() for a in self.cover.book_info.translators]
+ self.textboxes = []
if authors and translators:
# Try with two boxes.
if authors and translators:
# Try with two boxes.
@@
-130,7
+131,8
@@
class AuthorBox(Widget):
self.textboxes = [author_box]
self.textboxes = [author_box]
- self.margin_top = self.textboxes[0].margin_top
+ if self.textboxes:
+ self.margin_top = self.textboxes[0].margin_top
def build(self, w, h):
img = PIL.Image.new('RGBA', (self.width, self.m.leading * 2))
def build(self, w, h):
img = PIL.Image.new('RGBA', (self.width, self.m.leading * 2))
diff --git
a/src/librarian/covers/widgets/background.py
b/src/librarian/covers/widgets/background.py
index
8c9e03b
..
7836b5c
100644
(file)
--- a/
src/librarian/covers/widgets/background.py
+++ b/
src/librarian/covers/widgets/background.py
@@
-9,6
+9,7
@@
class Background(Widget):
transparency = False
def setup(self):
transparency = False
def setup(self):
+ self.img = None
if self.cover.book_info.cover_url:
while True:
try:
if self.cover.book_info.cover_url:
while True:
try:
@@
-34,6
+35,8
@@
class Background(Widget):
self.img = img
def build(self, w, h):
self.img = img
def build(self, w, h):
+ if not self.img:
+ return
kwadrat = round(max(w, h))
img = self.img
img = self.img.resize((kwadrat, kwadrat))
kwadrat = round(max(w, h))
img = self.img
img = self.img.resize((kwadrat, kwadrat))
diff --git
a/src/librarian/covers/widgets/base.py
b/src/librarian/covers/widgets/base.py
index
15e4462
..
9c56693
100644
(file)
--- a/
src/librarian/covers/widgets/base.py
+++ b/
src/librarian/covers/widgets/base.py
@@
-14,8
+14,9
@@
class Widget:
def apply(self, img, x, y, w=None, h=None):
my_img = self.build(w, h)
def apply(self, img, x, y, w=None, h=None):
my_img = self.build(w, h)
- img.paste(
- my_img,
- (round(x), round(y - self.margin_top)),
- my_img if self.transparency else None
- )
+ if my_img is not None:
+ img.paste(
+ my_img,
+ (round(x), round(y - self.margin_top)),
+ my_img if self.transparency else None
+ )