From c00343abfe439ed16327cd18e71a3ad9ef57b6a0 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Tue, 28 Mar 2023 14:22:38 -0400 Subject: [PATCH] First run at adding thumbnailing to images --- poetry.lock | 14 ++++- pyproject.toml | 1 + vrobbler/settings.py | 1 + vrobbler/templates/books/book_detail.html | 7 ++- vrobbler/templates/music/album_detail.html | 7 ++- vrobbler/templates/music/artist_detail.html | 7 ++- .../scrobbles/long_plays_in_progress.html | 17 ++++-- .../templates/scrobbles/scrobble_list.html | 59 ++++++++++--------- .../videogames/videogame_detail.html | 5 +- vrobbler/templates/videos/video_detail.html | 7 ++- 10 files changed, 84 insertions(+), 41 deletions(-) diff --git a/poetry.lock b/poetry.lock index b612f5e..31a44e3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1580,6 +1580,14 @@ category = "main" optional = false python-versions = ">=3.7" +[[package]] +name = "sorl-thumbnail" +version = "12.9.0" +description = "Thumbnails for Django" +category = "main" +optional = false +python-versions = ">=3.7" + [[package]] name = "sortedcontainers" version = "2.4.0" @@ -1885,7 +1893,7 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "2076d7c876e5086dfa822014940f0921879f505f38f9175a77320082b4439430" +content-hash = "b355c69693f7e45bf42429bcb195dceae3f2057e0b46fd937188cb649f972a24" [metadata.files] aiohttp = [ @@ -3144,6 +3152,10 @@ sniffio = [ {file = "sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"}, {file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, ] +sorl-thumbnail = [ + {file = "sorl-thumbnail-12.9.0.tar.gz", hash = "sha256:0cbc2f52152e7f2266e3c2cb4ae5d83afd2e96fd5e1c42e5667362baaa3d2db3"}, + {file = "sorl_thumbnail-12.9.0-py3-none-any.whl", hash = "sha256:ec586724bea7dc8c53561ce18335ea641fcd0e560d6387b2353a2afdd06705a4"}, +] sortedcontainers = [ {file = "sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"}, {file = "sortedcontainers-2.4.0.tar.gz", hash = "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88"}, diff --git a/pyproject.toml b/pyproject.toml index 8a3e608..845d771 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ beautifulsoup4 = "^4.11.2" django-storages = "^1.13.2" boto3 = "^1.26.98" stream-sqlite = "^0.0.41" +sorl-thumbnail = "^12.9.0" [tool.poetry.dev-dependencies] Werkzeug = "2.0.3" diff --git a/vrobbler/settings.py b/vrobbler/settings.py index 7ec30bb..0b23c60 100644 --- a/vrobbler/settings.py +++ b/vrobbler/settings.py @@ -101,6 +101,7 @@ INSTALLED_APPS = [ "django.contrib.humanize", "django_filters", "django_extensions", + "sorl.thumbnail", "storages", "taggit", "rest_framework.authtoken", diff --git a/vrobbler/templates/books/book_detail.html b/vrobbler/templates/books/book_detail.html index 095a0ce..1005179 100644 --- a/vrobbler/templates/books/book_detail.html +++ b/vrobbler/templates/books/book_detail.html @@ -2,6 +2,7 @@ {% load mathfilters %} {% load static %} {% load naturalduration %} +{% load thumbnail %} {% block title %}{{object.title}}{% endblock %} @@ -10,9 +11,11 @@
{% if object.cover%} -

- + {% thumbnail object.cover "400" as im %} +

+

+ {% endthumbnail %} {% endif %}
{% if object.summary %} diff --git a/vrobbler/templates/music/album_detail.html b/vrobbler/templates/music/album_detail.html index 4ecb263..740e34d 100644 --- a/vrobbler/templates/music/album_detail.html +++ b/vrobbler/templates/music/album_detail.html @@ -1,6 +1,7 @@ {% extends "base_list.html" %} {% load mathfilters %} {% load static %} +{% load thumbnail %} {% block title %}{{object.name}}{% endblock %} @@ -9,9 +10,11 @@
{% if object.cover_image %} -

- + {% thumbnail object.cover_image "300x300" as im %} +

+

+ {% endthumbnail %} {% endif %}
{% if object.theaudiodb_description %} diff --git a/vrobbler/templates/music/artist_detail.html b/vrobbler/templates/music/artist_detail.html index 1d75a70..0198af0 100644 --- a/vrobbler/templates/music/artist_detail.html +++ b/vrobbler/templates/music/artist_detail.html @@ -1,6 +1,7 @@ {% extends "base_list.html" %} {% load mathfilters %} {% load static %} +{% load thumbnail %} {% block title %}{{object.name}}{% endblock %} @@ -8,9 +9,11 @@
{% if object.thumbnail %} -

- + {% thumbnail object.thumbnail "300x300" as im %} +

+

+ {% endthumbnail %} {% else %} {% if object.album_set.first.cover_image %}

diff --git a/vrobbler/templates/scrobbles/long_plays_in_progress.html b/vrobbler/templates/scrobbles/long_plays_in_progress.html index ce276e6..e57d348 100644 --- a/vrobbler/templates/scrobbles/long_plays_in_progress.html +++ b/vrobbler/templates/scrobbles/long_plays_in_progress.html @@ -1,4 +1,5 @@ {% extends "base_list.html" %} +{% load thumbnail %} {% block title %}Long Plays{% endblock %} @@ -23,9 +24,13 @@

{{media.title}}
{% if media.hltb_cover %} -
+ {% thumbnail media.hltb_cover "200" as im %} +
+ {% endthumbnail %} {% else %} -
+ {% thumbnail media.cover "200" as im %} +
+ {% endthumbnail %} {% endif %}
{% if media.is_long_play_in_progress %}Playing{% else %}Resume{% endif %} @@ -72,12 +77,16 @@ {% for media in completed %} {% if media.hltb_cover %}
-
+ {% thumbnail media.hltb_cover "200" as im %} +
+ {% endthumbnail %}
{{media.title}}
{% elif media.cover %}
-
+ {% thumbnail media.cover "200" as im %} +
+ {% endthumbnail %}
{{media.title}}
{% endif %} diff --git a/vrobbler/templates/scrobbles/scrobble_list.html b/vrobbler/templates/scrobbles/scrobble_list.html index 8d12e01..1b620aa 100644 --- a/vrobbler/templates/scrobbles/scrobble_list.html +++ b/vrobbler/templates/scrobbles/scrobble_list.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load humanize %} {% load static %} +{% load thumbnail %} {% block head_extra %}