From 3be04d3edc3996d8ad67897633e432ee147b5c43 Mon Sep 17 00:00:00 2001 From: FuzzyGrim Date: Tue, 21 Jan 2025 10:28:51 +0100 Subject: [PATCH] add lazyload images with a default placeholder --- src/app/models.py | 1 + src/static/css/main.css | 62 +++++++++++++++++---------- src/templates/app/home.html | 10 ++--- src/templates/app/media_details.html | 5 ++- src/templates/app/media_grid.html | 5 +-- src/templates/app/media_list.html | 5 +-- src/templates/app/search.html | 11 +++-- src/templates/app/season_details.html | 17 +++----- src/templates/app/statistics.html | 15 ++++--- src/templates/base.html | 1 + src/templates/lists/list_detail.html | 4 +- 11 files changed, 76 insertions(+), 60 deletions(-) diff --git a/src/app/models.py b/src/app/models.py index fa3f0253..a5344af9 100644 --- a/src/app/models.py +++ b/src/app/models.py @@ -272,6 +272,7 @@ def get_score_distribution(self, user_media): "title": media.item.title, "image": media.item.image, "score": media.score, + "url": media.item.url, } # Use negative score for max heap (heapq implements min heap) diff --git a/src/static/css/main.css b/src/static/css/main.css index df2c2ae1..2df16b0c 100644 --- a/src/static/css/main.css +++ b/src/static/css/main.css @@ -152,7 +152,9 @@ debug, info, success, warning, error */ cursor: pointer; } - .image-not-found, .lazyload { + .image-not-found, + .lazyload, + .lazyloading { width: 100%; aspect-ratio: 2/3; object-fit: contain; @@ -387,28 +389,44 @@ debug, info, success, warning, error */ background-color: var(--bg-foreground); } -.episode-img-none { - background-image: url(https://www.themoviedb.org/assets/2/v4/glyphicons/basic/glyphicons-basic-38-picture-grey-c2ebdbb057f2a7614185931650f8cee23fa137b93812ccb132b9df511df1cfac.svg); - background-color: var(--bg-img-none); - background-position: center; - background-repeat: no-repeat; -} +.episode-card { + .episode-img { + border-top-left-radius: var(--bs-border-radius); + border-bottom-left-radius: var(--bs-border-radius); + height: 100%; + width: 100%; + aspect-ratio: 16/10; + object-fit: cover; + } -.description { - /* show only 2 lines of text */ - overflow: hidden; - display: -webkit-box; - -webkit-line-clamp: 2; - line-clamp: 2; - -webkit-box-orient: vertical; -} + .episode-img-none, + .lazyload, + .lazyloading { + border-top-left-radius: var(--bs-border-radius); + border-bottom-left-radius: var(--bs-border-radius); + height: 100%; + width: 100%; + aspect-ratio: 16/10; + object-fit: contain; + background-color: var(--bg-img-none); + } + + .description { + /* show only 2 lines of text */ + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 2; + line-clamp: 2; + -webkit-box-orient: vertical; + } -.date-btn-group { - .btn { - border-color: #495057; + .date-btn-group { + .btn { + border-color: #495057; - &:hover { - color: white; + &:hover { + color: white; + } } } } @@ -560,6 +578,6 @@ debug, info, success, warning, error */ } /* disable clicking on column header */ -.column-header-cell{ +.column-header-cell { pointer-events: none; -} \ No newline at end of file +} diff --git a/src/templates/app/home.html b/src/templates/app/home.html index cd379af2..b9d6ecde 100644 --- a/src/templates/app/home.html +++ b/src/templates/app/home.html @@ -13,9 +13,9 @@

{{ media_type|capfirst }} in Progress

{% for media in media_list %}
- {{ media }} @@ -39,7 +39,3 @@

You don't have any media in progress.

{% endfor %} {% endblock container %} - -{% block js %} - -{% endblock js %} diff --git a/src/templates/app/media_details.html b/src/templates/app/media_details.html index cb010967..0d853a81 100644 --- a/src/templates/app/media_details.html +++ b/src/templates/app/media_details.html @@ -28,8 +28,9 @@

{{ name|no_underscore|title }}

{% for related in related_items %}
- {{ related.title }} diff --git a/src/templates/app/media_grid.html b/src/templates/app/media_grid.html index f010fe6f..fa9b1aad 100644 --- a/src/templates/app/media_grid.html +++ b/src/templates/app/media_grid.html @@ -40,6 +40,7 @@ {% endif %} {% endblock container %} - -{% block js %} - -{% endblock js %} diff --git a/src/templates/app/media_list.html b/src/templates/app/media_list.html index 5a253146..b4771aac 100644 --- a/src/templates/app/media_list.html +++ b/src/templates/app/media_list.html @@ -54,6 +54,7 @@
{% endif %} {% endblock container %} - -{% block js %} - -{% endblock js %} diff --git a/src/templates/app/search.html b/src/templates/app/search.html index ec36d986..d44eee1b 100644 --- a/src/templates/app/search.html +++ b/src/templates/app/search.html @@ -22,7 +22,7 @@

No results found!

aria-label="Basic radio toggle button group">
MyAnimeList - + MangaUpdates @@ -32,8 +32,10 @@

No results found!

{% for media in query_list %}
- {{ media.title }} @@ -51,5 +53,6 @@

No results found!

{% endblock container %} {% block js %} - + {% endblock js %} diff --git a/src/templates/app/season_details.html b/src/templates/app/season_details.html index 9c9386b3..6b355c56 100644 --- a/src/templates/app/season_details.html +++ b/src/templates/app/season_details.html @@ -39,18 +39,15 @@
{% for episode in season.episodes %} -
+
- {% if episode.image == IMG_NONE %} -
- {% else %} -
- E{{ episode.episode_number }} -
- {% endif %} +
+ E{{ episode.episode_number }} +
diff --git a/src/templates/app/statistics.html b/src/templates/app/statistics.html index 229acc04..b5b526c3 100644 --- a/src/templates/app/statistics.html +++ b/src/templates/app/statistics.html @@ -35,8 +35,10 @@
Select Date Range

- - + +
@@ -254,9 +256,12 @@
Highest Rated Media
{% for media in score_distribution.top_rated %}
- {{ media.title }} + + {{ media.title }} +
{{ media.score }}
diff --git a/src/templates/base.html b/src/templates/base.html index fe8484b6..8a8d391d 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -242,6 +242,7 @@
+ {% block js %} {% endblock js %} {% endblock body %} diff --git a/src/templates/lists/list_detail.html b/src/templates/lists/list_detail.html index 988fbaae..f43c490c 100644 --- a/src/templates/lists/list_detail.html +++ b/src/templates/lists/list_detail.html @@ -89,8 +89,8 @@

Edit {{ custom_list }}

{% for item in items.all %}