covers for riderĂ³
authorJan Szejko <janek37@gmail.com>
Wed, 26 Apr 2017 12:01:31 +0000 (14:01 +0200)
committerJan Szejko <janek37@gmail.com>
Wed, 26 Apr 2017 12:01:31 +0000 (14:01 +0200)
src/catalogue/management/commands/gencover.py
src/catalogue/urls.py
src/catalogue/views.py

index adb84ea..d4c8383 100644 (file)
@@ -12,10 +12,12 @@ class Command(BaseCommand):
     def add_arguments(self, parser):
         parser.add_argument('slug')
         parser.add_argument('size', type=int)
     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']
 
     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()
         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)
         cover.save('%s.jpg' % slug)
index 1d4051b..5f6f8e5 100644 (file)
@@ -81,6 +81,8 @@ urlpatterns += patterns(
     url(r'^lektura/(?P<slug>%s)/motyw/(?P<theme_slug>[a-zA-Z0-9-]+)/$' % SLUG,
         'book_fragments', name='book_fragments'),
 
     url(r'^lektura/(?P<slug>%s)/motyw/(?P<theme_slug>[a-zA-Z0-9-]+)/$' % SLUG,
         'book_fragments', name='book_fragments'),
 
+    url(r'^okladka-ridero/(?P<slug>%s).png$' % SLUG, 'ridero_cover'),
+
     # Includes.
     url(r'^b/(?P<pk>\d+)/mini\.(?P<lang>.+)\.html', 'book_mini', name='catalogue_book_mini'),
     url(r'^b/(?P<pk>\d+)/mini_nolink\.(?P<lang>.+)\.html', 'book_mini', {'with_link': False},
     # Includes.
     url(r'^b/(?P<pk>\d+)/mini\.(?P<lang>.+)\.html', 'book_mini', name='catalogue_book_mini'),
     url(r'^b/(?P<pk>\d+)/mini_nolink\.(?P<lang>.+)\.html', 'book_mini', {'with_link': False},
index 99e3c82..503b6f5 100644 (file)
@@ -785,3 +785,12 @@ def collections(request):
         'objects': objects,
         'best': best,
     })
         '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