From: Jan Szejko Date: Tue, 15 Mar 2016 17:02:36 +0000 (+0100) Subject: publish HTML with images X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/5e225c00376442bb28231d98472935a79dc9c9a5?hp=c3fc1fa1087b5c12e287f6a7194d7a98fc27817e publish HTML with images --- diff --git a/src/catalogue/fields.py b/src/catalogue/fields.py index bc05aa35c..1a3a3b5d7 100644 --- a/src/catalogue/fields.py +++ b/src/catalogue/fields.py @@ -8,7 +8,7 @@ from django.db import models from django.db.models.fields.files import FieldFile from catalogue import app_settings from catalogue.constants import LANGUAGES_3TO2 -from catalogue.utils import remove_zip, truncate_html_words, gallery_path +from catalogue.utils import remove_zip, truncate_html_words, gallery_path, gallery_url from celery.task import Task, task from celery.utils.log import get_task_logger from waiter.utils import clear_cache @@ -145,9 +145,7 @@ class BuildHtml(BuildEbook): book = fieldfile.instance - html_output = self.transform( - book.wldocument(parse_dublincore=False), - fieldfile) + html_output = self.transform(book.wldocument(), fieldfile) # Delete old fragments, create from scratch if necessary. book.fragments.all().delete() @@ -211,6 +209,10 @@ class BuildHtml(BuildEbook): return True return False + @staticmethod + def transform(wldoc, fieldfile): + return wldoc.as_html(options={'gallery': "'%s'" % gallery_url(wldoc.book_info.url.slug)}) + @BuildEbook.register('cover_thumb') @task(ignore_result=True) diff --git a/src/catalogue/forms.py b/src/catalogue/forms.py index 1b034551f..ea732db58 100644 --- a/src/catalogue/forms.py +++ b/src/catalogue/forms.py @@ -2,9 +2,6 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -import urllib -import os.path - from django import forms from django.utils.translation import ugettext_lazy as _ @@ -13,7 +10,6 @@ from waiter.models import WaitedFile from django.core.exceptions import ValidationError from catalogue.utils import get_customized_pdf_path from catalogue.tasks import build_custom_pdf -from wolnelektury.utils import makedirs class BookImportForm(forms.Form):