From 15bfd31759c7454aaceaf7107ef07718e662724a Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Wed, 16 Mar 2016 10:22:15 +0100 Subject: [PATCH] images in epub/mobi --- .../catalogue/locale/pl/LC_MESSAGES/django.mo | Bin 7731 -> 7796 bytes .../catalogue/locale/pl/LC_MESSAGES/django.po | 47 +++++++++--------- .../templates/catalogue/book_detail.html | 1 + apps/catalogue/urls.py | 1 + apps/catalogue/views.py | 18 ++++++- lib/librarian | 2 +- 6 files changed, 44 insertions(+), 25 deletions(-) diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo index 17689b80911f5fcaae5ddb9b231a6e4c2d3ac7e6..8c88b6b0f57032ea8e4714db5e6b1d6715421fed 100644 GIT binary patch delta 2816 zcmX}tdrZ}39LMno;TUog4`y;PPJ}{S^dO3dOJRUqLIR4C)C?*}P%)5*MEtF&P5h(& zNLyR7)mHylmUL?UQEjeuvBuh{+;lcw%lSu1xz%Pkm%TsmJ^gmR=k+|#@A*CV-#Oum zzbm{8{+OeV>mZRqB*Zv(0&m>H7uU%+=a%6lF2~ati@#tr{)UV256l09@#JqU?|A8O{QsOMIr+FQ4T_1DbH?MAg#Y(UL$hgBRjM^FvCfSTbU%fE)| z;27$;NmK{lpa$~2`6KGNv#541dn8oxiuspSxQ-fFEC)j~N=DU7MJ-_fwe$tZWL*hr zi|UX^T^p+7Zd6CRP|x>U`LLCHqa@VenB8~<6Be-4xQ6n#m{tx>qw39~8uT$uZACn4 zAZe(j&PLS>VLH~JX54|Q*N5z`8%CP)+#wQr%_huGQ4O8LY@9)@fS;492GUV)$4b-y zf~fnIsKZu|jNNr&J`SP=^d@Qr-b1ZW7H#7DAr;<>ErAVJ{ljXM~AGeb)E#>o= ziW8^?KS4h32fl*%J8D1~RAOmeK58HvE#HV^VaMbu$DhPUGhT#HjyeiQXvGPBWPO;2b2wbZ#3)M67B;}NXD z)2O}m(W@RvGShJb`CQaec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QEAbQB;f?6OXa}k6hxaqkau&K(dFWXy#y*&^6PI=&QB9N){<~aD+)p$S z{vK>1Jai^IHf<%`K4;>fw-Bb+3BR0IEs*B*5~kvUn133V`u#sj#yxYEHxrXc{ucO| z+(|r0)DzDVb%g0fVl1(oSV7!JOeF3lOdE(9#9Rv`5ALdD?$!(YKbzsxrJ2#E z(Eale)e=t<9>7v!JkdxzKr|5Bh$+N6g6$2H3HN+GaclCE^bDDj{VyZqVY!*^i5U;1 z$&)>s;D<0QCOkl%e$(^4gw^;kQ9*2s_hb(74B-z@Gck@BLp)CKJ2fIaM5csTLOe!n sCQ^ywjt?@\n" "Language-Team: Fundacja Nowoczesna Polska {% trans "TXT version" %}
{% trans "PDF version" %}
{% trans "EPUB version" %}
+ {% trans "MOBI version" %}

{% if user.is_authenticated %} diff --git a/apps/catalogue/urls.py b/apps/catalogue/urls.py index 908144f1..a09dd120 100644 --- a/apps/catalogue/urls.py +++ b/apps/catalogue/urls.py @@ -40,6 +40,7 @@ urlpatterns = patterns('catalogue.views', url(r'^book/(?P[^/]+)/txt$', 'book_txt', name="catalogue_book_txt"), url(r'^book/(?P[^/]+)/html$', 'book_html', name="catalogue_book_html"), url(r'^book/(?P[^/]+)/epub$', 'book_epub', name="catalogue_book_epub"), + url(r'^book/(?P[^/]+)/mobi$', 'book_mobi', name="catalogue_book_mobi"), url(r'^book/(?P[^/]+)/pdf$', 'book_pdf', name="catalogue_book_pdf"), url(r'^chunk_add/(?P[^/]+)/(?P[^/]+)/$', diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 0eac8ded..84cc0972 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -274,13 +274,29 @@ def book_epub(request, slug): # TODO: move to celery doc = book.wldocument() # TODO: error handling - epub = doc.as_epub().get_string() + epub = doc.as_epub(ilustr_path=book.gallery_path()).get_string() response = HttpResponse(content_type='application/epub+zip') response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub' response.write(epub) return response +@never_cache +def book_mobi(request, slug): + book = get_object_or_404(Book, slug=slug) + if not book.accessible(request): + return HttpResponseForbidden("Not authorized.") + + # TODO: move to celery + doc = book.wldocument() + # TODO: error handling + mobi = doc.as_mobi(ilustr_path=book.gallery_path()).get_string() + response = HttpResponse(content_type='application/x-mobipocket-ebook') + response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.mobi' + response.write(mobi) + return response + + @never_cache def revision(request, slug, chunk=None): try: diff --git a/lib/librarian b/lib/librarian index 3acdb97e..3f616438 160000 --- a/lib/librarian +++ b/lib/librarian @@ -1 +1 @@ -Subproject commit 3acdb97ed96bb54a04c031e017c2059f86db57e4 +Subproject commit 3f6164384bfd12f173e5f38835ce8a5cfb8b282a -- 2.20.1