From: Jan Szejko Date: Wed, 26 Apr 2017 12:01:31 +0000 (+0200) Subject: covers for riderĂ³ X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/327e9cecd8cd2a8795a874dcb4e88a50d7c972fe covers for riderĂ³ --- 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