X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/1423b7f55cedaf4afdb0b8d6060e1ddae7b0c44a..245ee64cc85bfc2c1a27c30139d9e7c1268168d9:/librarian/cover.py?ds=sidebyside diff --git a/librarian/cover.py b/librarian/cover.py index bec59f3..29e24c8 100644 --- a/librarian/cover.py +++ b/librarian/cover.py @@ -369,7 +369,7 @@ class WLCover(Cover): dir_y = 1 if corner_y == 0 else -1 for offset in (-1, 0, 1): draw.line((corner_x, corner_y + dir_y * metr.bleed + offset, - corner_x + dir_x * metr.bleed * line_ratio, corner_y + dir_y * metr.bleed + offset), + corner_x + dir_x * metr.bleed * line_ratio, corner_y + dir_y * metr.bleed + offset), fill='black' if offset == 0 else 'white', width=1) draw.line((corner_x + dir_x * metr.bleed + offset, corner_y, corner_x + dir_x * metr.bleed + offset, corner_y + dir_y * metr.bleed * line_ratio), @@ -408,11 +408,16 @@ class WLCover(Cover): img = self.add_box(img) - img = self.add_cut_lines(img) + # img = self.add_cut_lines(img) return img +class WLNoBoxCover(WLCover): + def add_box(self, img): + return img + + class LogoWLCover(WLCover): gradient_height = 90 gradient_logo_height = 60 @@ -539,4 +544,48 @@ class GandalfCover(Cover): format = 'PNG' -DefaultEbookCover = LogoWLCover +class KMLUCover(LogoWLCover): + gradient_logo_height = 58 + gradient_logo_spacing = 25 + gradient_logos = [ + 'res/kmlu-logo-white.png', + 'res/wl-logo-white.png', + 'res/fnp-logo-white.png', + ] + + +class MPWCover(LogoWLCover): + gradient_logo_height = 58 + gradient_logo_spacing = 25 + gradient_logos = [ + 'res/mpw-logo-white.png', + 'res/wl-logo-white.png', + 'res/fnp-logo-white.png', + ] + + +class AtriumCover(LogoWLCover): + gradient_logo_height = 58 + gradient_logo_spacing = 25 + gradient_logos = [ + 'res/atrium-logo.png', + 'res/wl-logo-white.png', + 'res/fnp-logo-white.png', + ] + + +COVER_CLASSES = { + 'default': LogoWLCover, + 'kmlu': KMLUCover, + 'mpw': MPWCover, + 'atrium': AtriumCover, +} + + +def make_cover(book_info, *args, **kwargs): + if 'cover_class' in kwargs: + cover_class_name = kwargs.pop('cover_class') + else: + cover_class_name = book_info.cover_class + cover_class = COVER_CLASSES[cover_class_name] + return cover_class(book_info, *args, **kwargs)