From 1fcba941fa54f5a7128af5b15a357c000a5030e5 Mon Sep 17 00:00:00 2001 From: krateng Date: Sat, 1 Apr 2023 17:35:44 +0200 Subject: [PATCH] Added placeholder images --- maloja/images.py | 22 +++++++++++++------- maloja/pkg_global/conf.py | 1 + maloja/web/static/svg/LICENSE | 21 +++++++++++++++++++ maloja/web/static/svg/placeholder_album.svg | 1 + maloja/web/static/svg/placeholder_artist.svg | 1 + maloja/web/static/svg/placeholder_track.svg | 1 + 6 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 maloja/web/static/svg/LICENSE create mode 100644 maloja/web/static/svg/placeholder_album.svg create mode 100644 maloja/web/static/svg/placeholder_artist.svg create mode 100644 maloja/web/static/svg/placeholder_track.svg diff --git a/maloja/images.py b/maloja/images.py index ca0e783..e576c84 100644 --- a/maloja/images.py +++ b/maloja/images.py @@ -278,13 +278,21 @@ def image_request(artist_id=None,track_id=None,album_id=None): # we got an entry, even if it's that there is no image (value None) if result['value'] is None: # use placeholder - placeholder_url = "https://generative-placeholders.glitch.me/image?width=300&height=300&style=" - if artist_id: - result['value'] = placeholder_url + f"tiles&colors={artist_id % 100}" - if track_id: - result['value'] = placeholder_url + f"triangles&colors={track_id % 100}" - if album_id: - result['value'] = placeholder_url + f"joy-division&colors={album_id % 100}" + if malojaconfig["FANCY_PLACEHOLDER_ART"]: + placeholder_url = "https://generative-placeholders.glitch.me/image?width=300&height=300&style=" + if artist_id: + result['value'] = placeholder_url + f"tiles&colors={artist_id % 100}" + if track_id: + result['value'] = placeholder_url + f"triangles&colors={track_id % 100}" + if album_id: + result['value'] = placeholder_url + f"joy-division&colors={album_id % 100}" + else: + if artist_id: + result['value'] = "/static/svg/placeholder_artist.svg" + if track_id: + result['value'] = "/static/svg/placeholder_track.svg" + if album_id: + result['value'] = "/static/svg/placeholder_album.svg" return result time.sleep(1) diff --git a/maloja/pkg_global/conf.py b/maloja/pkg_global/conf.py index a9be47b..e6dac70 100644 --- a/maloja/pkg_global/conf.py +++ b/maloja/pkg_global/conf.py @@ -197,6 +197,7 @@ malojaconfig = Configuration( "display_art_icons":(tp.Boolean(), "Display Album/Artist Icons", True), "default_album_artist":(tp.String(), "Default Albumartist", "Various Artists"), "use_album_artwork_for_tracks":(tp.Boolean(), "Use Album Artwork for tracks", True), + "fancy_placeholder_art":(tp.Boolean(), "Use fancy placeholder artwork",True), "discourage_cpu_heavy_stats":(tp.Boolean(), "Discourage CPU-heavy stats", False, "Prevent visitors from mindlessly clicking on CPU-heavy options. Does not actually disable them for malicious actors!"), "use_local_images":(tp.Boolean(), "Use Local Images", True), #"local_image_rotate":(tp.Integer(), "Local Image Rotate", 3600), diff --git a/maloja/web/static/svg/LICENSE b/maloja/web/static/svg/LICENSE new file mode 100644 index 0000000..6be4c3e --- /dev/null +++ b/maloja/web/static/svg/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015-present Ionic (http://ionic.io/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/maloja/web/static/svg/placeholder_album.svg b/maloja/web/static/svg/placeholder_album.svg new file mode 100644 index 0000000..751e22a --- /dev/null +++ b/maloja/web/static/svg/placeholder_album.svg @@ -0,0 +1 @@ + diff --git a/maloja/web/static/svg/placeholder_artist.svg b/maloja/web/static/svg/placeholder_artist.svg new file mode 100644 index 0000000..f7e6b85 --- /dev/null +++ b/maloja/web/static/svg/placeholder_artist.svg @@ -0,0 +1 @@ + diff --git a/maloja/web/static/svg/placeholder_track.svg b/maloja/web/static/svg/placeholder_track.svg new file mode 100644 index 0000000..a6e6efb --- /dev/null +++ b/maloja/web/static/svg/placeholder_track.svg @@ -0,0 +1 @@ +