From 327e9cecd8cd2a8795a874dcb4e88a50d7c972fe Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Wed, 26 Apr 2017 14:01:31 +0200 Subject: [PATCH] =?utf8?q?covers=20for=20rider=C3=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/catalogue/management/commands/gencover.py | 4 +++- src/catalogue/urls.py | 2 ++ src/catalogue/views.py | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/catalogue/management/commands/gencover.py b/src/catalogue/management/commands/gencover.py index adb84ea00..d4c838351 100644 --- a/src/catalogue/management/commands/gencover.py +++ b/src/catalogue/management/commands/gencover.py @@ -12,10 +12,12 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('slug') parser.add_argument('size', type=int) + parser.add_argument('--bleed', action='store_true') def handle(self, *args, **options): slug = options['slug'] size = options['size'] + bleed = 20 if options['bleed'] else 0 wldoc = Book.objects.get(slug=slug).wldocument() - cover = DefaultEbookCover(wldoc.book_info, width=size) + cover = DefaultEbookCover(wldoc.book_info, width=size, bleed=bleed) cover.save('%s.jpg' % slug) diff --git a/src/catalogue/urls.py b/src/catalogue/urls.py index 1d4051b27..5f6f8e5a5 100644 --- a/src/catalogue/urls.py +++ b/src/catalogue/urls.py @@ -81,6 +81,8 @@ urlpatterns += patterns( url(r'^lektura/(?P%s)/motyw/(?P[a-zA-Z0-9-]+)/$' % SLUG, 'book_fragments', name='book_fragments'), + url(r'^okladka-ridero/(?P%s).png$' % SLUG, 'ridero_cover'), + # Includes. url(r'^b/(?P\d+)/mini\.(?P.+)\.html', 'book_mini', name='catalogue_book_mini'), url(r'^b/(?P\d+)/mini_nolink\.(?P.+)\.html', 'book_mini', {'with_link': False}, diff --git a/src/catalogue/views.py b/src/catalogue/views.py index 99e3c8244..503b6f533 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -785,3 +785,12 @@ def collections(request): 'objects': objects, 'best': best, }) + + +def ridero_cover(request, slug): + from librarian.cover import DefaultEbookCover + wldoc = Book.objects.get(slug=slug).wldocument() + cover = DefaultEbookCover(wldoc.book_info, width=980, bleed=20, format='PNG') + response = HttpResponse(content_type="image/png") + cover.save(response) + return response -- 2.20.1