Responsive images.
authorRadek Czajka <rczajka@rczajka.pl>
Wed, 27 Jan 2021 13:07:48 +0000 (14:07 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Wed, 27 Jan 2021 13:07:48 +0000 (14:07 +0100)
requirements/requirements.txt
src/catalogue/fields.py
src/catalogue/management/commands/importbooks.py
src/catalogue/templatetags/catalogue_tags.py
src/catalogue/utils.py
src/wolnelektury/static/css/new.book.css
src/wolnelektury/static/scss/book_text/const.scss

index 225b205..bfa9a8c 100644 (file)
@@ -45,7 +45,7 @@ mutagen>=1.31
 sorl-thumbnail==12.5.0
 
 # home-brewed & dependencies
 sorl-thumbnail==12.5.0
 
 # home-brewed & dependencies
-librarian==1.12
+librarian==1.13
 
 # celery tasks
 celery[redis]==4.4.7
 
 # celery tasks
 celery[redis]==4.4.7
index 4d49d30..c3e2b35 100644 (file)
@@ -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:
         from librarian import DCNS
         url_elem = wldoc.edoc.getroot().find('.//' + DCNS('identifier.url'))
         if url_elem is None:
-            gallery = ''
+            gal_url = ''
+            gal_path = ''
         else:
         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):
 
 
 class BuildCover(BuildEbook):
index e5e7c89..e9b3364 100644 (file)
@@ -52,6 +52,7 @@ class Command(BaseCommand):
                                   dont_build=dont_build,
                                   search_index_tags=False,
                                   findable=options.get('findable'),
                                   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):
                                   )
         for ebook_format in Book.ebook_formats:
             if os.path.isfile(file_base + '.' + ebook_format):
index 25976db..b582f89 100644 (file)
@@ -503,7 +503,7 @@ def content_warning(book):
     warnings_def = {
         'wulgaryzmy': _('vulgar language'),
     }
     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
     warnings = sorted(
         warnings_def.get(w, w)
         for w in warnings
index d056579..ca8ec0d 100644 (file)
@@ -303,7 +303,7 @@ def delete_from_cache_by_language(cache, key_template):
 
 
 def gallery_path(slug):
 
 
 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):
 
 
 def gallery_url(slug):
index 77f8197..e2d44b6 100644 (file)
@@ -13,6 +13,7 @@ a {
 img {
     max-width: 37.5rem;
     margin-top: 1em;
 img {
     max-width: 37.5rem;
     margin-top: 1em;
+    width: 100%;
 }
 .animacja {
     margin-top: 1em;
 }
 .animacja {
     margin-top: 1em;
index 154c699..871a8b5 100644 (file)
@@ -16,7 +16,7 @@ $W_NOTHEMES_TINY: 20px;
 $S_NOTHEMES_TINY_MAX: 240px;
 $W_NOTHEMES_SMALL: 30px;
 $S_NOTHEMES_SMALL_MAX: 320px;
 $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;
 $S_THEMES: 600px;
 $S_THEMES_WOTHER: 1200px;
 $W_THEMES: 160px;