From: Radek Czajka Date: Wed, 27 Jan 2021 13:07:48 +0000 (+0100) Subject: Responsive images. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/5ac6f14db010bbfbcf39190d0b639a47ab1c89d3 Responsive images. --- diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 225b205de..bfa9a8cc9 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -45,7 +45,7 @@ mutagen>=1.31 sorl-thumbnail==12.5.0 # home-brewed & dependencies -librarian==1.12 +librarian==1.13 # celery tasks celery[redis]==4.4.7 diff --git a/src/catalogue/fields.py b/src/catalogue/fields.py index 4d49d3080..c3e2b356a 100644 --- a/src/catalogue/fields.py +++ b/src/catalogue/fields.py @@ -311,10 +311,13 @@ class BuildHtml(BuildEbook): from librarian import DCNS url_elem = wldoc.edoc.getroot().find('.//' + DCNS('identifier.url')) if url_elem is None: - gallery = '' + gal_url = '' + gal_path = '' else: - gallery = gallery_url(slug=url_elem.text.rstrip('/').rsplit('/', 1)[1]) - return wldoc.as_html(options={'gallery': "'%s'" % gallery}) + slug = url_elem.text.rstrip('/').rsplit('/', 1)[1] + gal_url = gallery_url(slug=slug) + gal_path = gallery_path(slug=slug) + return wldoc.as_html(gallery_path=gal_path, gallery_url=gal_url) class BuildCover(BuildEbook): diff --git a/src/catalogue/management/commands/importbooks.py b/src/catalogue/management/commands/importbooks.py index e5e7c89fa..e9b33642c 100644 --- a/src/catalogue/management/commands/importbooks.py +++ b/src/catalogue/management/commands/importbooks.py @@ -52,6 +52,7 @@ class Command(BaseCommand): dont_build=dont_build, search_index_tags=False, findable=options.get('findable'), + remote_gallery_url='file://' + os.path.dirname(os.path.abspath(file_base)) + '/img/' ) for ebook_format in Book.ebook_formats: if os.path.isfile(file_base + '.' + ebook_format): diff --git a/src/catalogue/templatetags/catalogue_tags.py b/src/catalogue/templatetags/catalogue_tags.py index 25976dbc6..b582f89c3 100644 --- a/src/catalogue/templatetags/catalogue_tags.py +++ b/src/catalogue/templatetags/catalogue_tags.py @@ -503,7 +503,7 @@ def content_warning(book): warnings_def = { 'wulgaryzmy': _('vulgar language'), } - warnings = book.get_extra_info_json().get('content_warnings') + warnings = book.get_extra_info_json().get('content_warnings', []) warnings = sorted( warnings_def.get(w, w) for w in warnings diff --git a/src/catalogue/utils.py b/src/catalogue/utils.py index d05657978..ca8ec0dc2 100644 --- a/src/catalogue/utils.py +++ b/src/catalogue/utils.py @@ -303,7 +303,7 @@ def delete_from_cache_by_language(cache, key_template): def gallery_path(slug): - return os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, slug) + return os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, slug) + '/' def gallery_url(slug): diff --git a/src/wolnelektury/static/css/new.book.css b/src/wolnelektury/static/css/new.book.css index 77f819756..e2d44b61c 100644 --- a/src/wolnelektury/static/css/new.book.css +++ b/src/wolnelektury/static/css/new.book.css @@ -13,6 +13,7 @@ a { img { max-width: 37.5rem; margin-top: 1em; + width: 100%; } .animacja { margin-top: 1em; diff --git a/src/wolnelektury/static/scss/book_text/const.scss b/src/wolnelektury/static/scss/book_text/const.scss index 154c69911..871a8b561 100644 --- a/src/wolnelektury/static/scss/book_text/const.scss +++ b/src/wolnelektury/static/scss/book_text/const.scss @@ -16,7 +16,7 @@ $W_NOTHEMES_TINY: 20px; $S_NOTHEMES_TINY_MAX: 240px; $W_NOTHEMES_SMALL: 30px; $S_NOTHEMES_SMALL_MAX: 320px; -$W_NOTHEMES: 44px; +$W_NOTHEMES: 45px; $S_THEMES: 600px; $S_THEMES_WOTHER: 1200px; $W_THEMES: 160px;