From 95561a312cc1a94d166c7468fc214e2ece047ad1 Mon Sep 17 00:00:00 2001 From: "Hristos N. Triantafillou" Date: Sun, 14 Feb 2021 15:34:18 -0600 Subject: [PATCH] Showing errors in the UI is optional, default: off (#143) --- mousikofidi/mousikofidi.py | 10 ++++++++++ mousikofidi/templates/playlist.html | 2 +- test_mousikofidi.py | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mousikofidi/mousikofidi.py b/mousikofidi/mousikofidi.py index 09a9ec5..41d4970 100644 --- a/mousikofidi/mousikofidi.py +++ b/mousikofidi/mousikofidi.py @@ -96,6 +96,9 @@ logo_path = "/fidi.png" # Should MousikóFídi try and display cover art? show_cover_art = true +# Show errors e.g. when a playlist has a bad entry in the UI? +show_errors = false + # The name of your MousikóFídi instance; this is what will # display on the main page of the application. site_name = "MousikóFídi - Your Music Cloud" @@ -496,6 +499,7 @@ def request_context(config_data: dict) -> dict: "playlist_save": config_data["playlists"]["allow_save"], "playlists": playlists, "secret_key": config_data["other"]["secret_key"], + "show_errors": config_data["ui"]["show_errors"], "site_name": config_data["ui"]["site_name"], "queue": queue, "theme": theme, @@ -811,6 +815,12 @@ def init( ) c["ui"]["site_name"] = "MousikóFídi - Your Music Cloud" + if "show_errors" not in c["ui"].keys(): + wrn( + "No 'ui.show_errors' value was found in the configuration file! Defaulting to off..." + ) + c["ui"]["show_errors"] = False + if "theme" in c["ui"].keys(): theme = c["ui"]["theme"].lower() if theme in THEMES.keys(): diff --git a/mousikofidi/templates/playlist.html b/mousikofidi/templates/playlist.html index 83471f7..d8f6311 100644 --- a/mousikofidi/templates/playlist.html +++ b/mousikofidi/templates/playlist.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block content %} - {% if bunk_tracks %} + {% if bunk_tracks and show_errors %}

Oh no!

{% if audio_list == [] and video_list == [] %}All{% else %}Some{% endif %} tracks on this playlist failed to load.

diff --git a/test_mousikofidi.py b/test_mousikofidi.py index 475ffa5..9271b8b 100644 --- a/test_mousikofidi.py +++ b/test_mousikofidi.py @@ -462,6 +462,7 @@ def test_browse_dir(): "debug": False, "favicon_path": favicon, "show_cover_art": True, + "show_errors": False, "icons": False, "keyboard_controls": True, "logo_path": logo, @@ -599,6 +600,7 @@ def test_browse_file(): "secret_key": True, "site_name": "MousikóFídi - Your Music Cloud", "show_cover_art": True, + "show_errors": False, "queue": [], "theme": "light", "username": None, @@ -741,6 +743,7 @@ def test_request_context(): "playlists": [], "secret_key": True, "show_cover_art": True, + "show_errors": False, "site_name": "MousikóFídi - Your Music Cloud", "queue": [], "theme": "light", @@ -985,6 +988,7 @@ def test_init(): "icons": False, "logo_path": "/fidi.png", "show_cover_art": True, + "show_errors": False, "site_name": "MousikóFídi - Your Music Cloud", "theme": "light", }, @@ -2282,6 +2286,7 @@ def test_playlist_detail_real_with_bad(client): app.fidiConfig["library"]["dirs"] = [mdir] app.fidiConfig["playlists"]["dir"] = pdir + app.fidiConfig["ui"]["show_errors"] = True app.fidiConfig["ui"]["site_name"] = "Pdir Test" with app.test_client() as tc: -- 2.38.5