From a93f36adb5f1519069cea0ab8ff706ce74e0ef6a Mon Sep 17 00:00:00 2001 From: fdambrine Date: Wed, 4 Jul 2018 09:41:27 +0200 Subject: [PATCH] Fix epub building --- zds/tutorialv2/epub_utils.py | 4 +--- zds/tutorialv2/publication_utils.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/zds/tutorialv2/epub_utils.py b/zds/tutorialv2/epub_utils.py index 147ca3216a..e1d784d205 100644 --- a/zds/tutorialv2/epub_utils.py +++ b/zds/tutorialv2/epub_utils.py @@ -189,13 +189,11 @@ def _(html_code): final_path = splitted.path elif image_url.startswith(settings.MEDIA_URL): final_path = Path(image_url).name - elif Path(image_url).is_absolute(): + elif Path(image_url).is_absolute() and 'images' in image_url: root = Path(image_url) while root.name != 'images': root = root.parent final_path = str(Path(image_url).relative_to(root)) - if final_path.endswith('svg') or final_path.endswith('gif'): - final_path = final_path[:-3] + 'png' image_path_in_ebook = relative_path + '/images/' + str(final_path).replace('%20', '_') image['src'] = str(image_path_in_ebook) ids = {} diff --git a/zds/tutorialv2/publication_utils.py b/zds/tutorialv2/publication_utils.py index bde561ab2e..acaa20de06 100644 --- a/zds/tutorialv2/publication_utils.py +++ b/zds/tutorialv2/publication_utils.py @@ -486,13 +486,14 @@ def publish(self, md_file_path, base_name, **kwargs): try: published_content_entity = self.get_published_content_entity(md_file_path) epub_file_path = Path(base_name + '.epub') + logger.info('Start generating epub') build_ebook(published_content_entity, path.dirname(md_file_path), epub_file_path) except (IOError, OSError): raise FailureDuringPublication('Error while generating epub file.') else: - print(epub_file_path) + logger.info(epub_file_path) epub_path = Path(published_content_entity.get_extra_contents_directory(), Path(epub_file_path.name)) if epub_path.exists(): os.remove(str(epub_path))