From b6f5831d10deac25bb8f263d33f412923154920e Mon Sep 17 00:00:00 2001 From: Ales Lerch <13370338+axeII@users.noreply.github.com> Date: Mon, 13 May 2024 23:49:59 +0200 Subject: [PATCH] feat: adds hide summary sidebar option --- .env.example | 2 ++ Cargo.lock | 2 +- src/config.rs | 6 ++++++ src/settings.rs | 3 ++- src/utils.rs | 2 ++ templates/settings.html | 13 +++++++++---- templates/subreddit.html | 2 +- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 84f2ed2..b74e45c 100644 --- a/.env.example +++ b/.env.example @@ -38,6 +38,8 @@ REDLIB_DEFAULT_AUTOPLAY_VIDEOS=off REDLIB_DEFAULT_SUBSCRIPTIONS= # Hide awards by default REDLIB_DEFAULT_HIDE_AWARDS=off +# Hide sidebar and summary +REDLIB_DEFAULT_HIDE_SIDEBAR_AND_SUMMARY=off # Disable the confirmation before visiting Reddit REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION=off # Hide score by default diff --git a/Cargo.lock b/Cargo.lock index 3b357a1..5f8bd94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1047,7 +1047,7 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "redlib" -version = "0.31.0" +version = "0.31.2" dependencies = [ "askama", "base64", diff --git a/src/config.rs b/src/config.rs index 21a3adc..418d2f5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -68,6 +68,10 @@ pub struct Config { #[serde(alias = "LIBREDDIT_DEFAULT_HIDE_AWARDS")] pub(crate) default_hide_awards: Option, + #[serde(rename = "REDLIB_DEFAULT_HIDE_SIDEBAR_AND_SUMMARY")] + #[serde(alias = "LIBREDDIT_DEFAULT_HIDE_SIDEBAR_AND_SUMMARY")] + pub(crate) default_hide_sidebar_and_summary: Option, + #[serde(rename = "REDLIB_DEFAULT_HIDE_SCORE")] #[serde(alias = "LIBREDDIT_DEFAULT_HIDE_SCORE")] pub(crate) default_hide_score: Option, @@ -127,6 +131,7 @@ impl Config { default_use_hls: parse("REDLIB_DEFAULT_USE_HLS"), default_hide_hls_notification: parse("REDLIB_DEFAULT_HIDE_HLS"), default_hide_awards: parse("REDLIB_DEFAULT_HIDE_AWARDS"), + default_hide_sidebar_and_summary: parse("REDLIB_DEFAULT_HIDE_SIDEBAR_AND_SUMMARY"), default_hide_score: parse("REDLIB_DEFAULT_HIDE_SCORE"), default_subscriptions: parse("REDLIB_DEFAULT_SUBSCRIPTIONS"), default_disable_visit_reddit_confirmation: parse("REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"), @@ -151,6 +156,7 @@ fn get_setting_from_config(name: &str, config: &Config) -> Option { "REDLIB_DEFAULT_HIDE_HLS_NOTIFICATION" => config.default_hide_hls_notification.clone(), "REDLIB_DEFAULT_WIDE" => config.default_wide.clone(), "REDLIB_DEFAULT_HIDE_AWARDS" => config.default_hide_awards.clone(), + "REDLIB_DEFAULT_HIDE_SIDEBAR_AND_SUMMARY" => config.default_hide_awards.clone(), "REDLIB_DEFAULT_HIDE_SCORE" => config.default_hide_score.clone(), "REDLIB_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(), "REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(), diff --git a/src/settings.rs b/src/settings.rs index 6edb059..6964675 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -19,7 +19,7 @@ struct SettingsTemplate { // CONSTANTS -const PREFS: [&str; 15] = [ +const PREFS: [&str; 16] = [ "theme", "front_page", "layout", @@ -31,6 +31,7 @@ const PREFS: [&str; 15] = [ "use_hls", "hide_hls_notification", "autoplay_videos", + "hide_sidebar_and_summary", "fixed_navbar", "hide_awards", "hide_score", diff --git a/src/utils.rs b/src/utils.rs index 63e679d..cd4c4ae 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -577,6 +577,7 @@ pub struct Preferences { pub show_nsfw: String, pub blur_nsfw: String, pub hide_hls_notification: String, + pub hide_sidebar_and_summary: String, pub use_hls: String, pub autoplay_videos: String, pub fixed_navbar: String, @@ -611,6 +612,7 @@ impl Preferences { layout: setting(req, "layout"), wide: setting(req, "wide"), show_nsfw: setting(req, "show_nsfw"), + hide_sidebar_and_summary: setting(req, "hide_sidebar_and_summary"), blur_nsfw: setting(req, "blur_nsfw"), use_hls: setting(req, "use_hls"), hide_hls_notification: setting(req, "hide_hls_notification"), diff --git a/templates/settings.html b/templates/settings.html index e57d250..496b9b1 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -71,11 +71,16 @@ -
+
- - -
+ + +
+
+ + + +
diff --git a/templates/subreddit.html b/templates/subreddit.html index 0c27ed3..66afb87 100644 --- a/templates/subreddit.html +++ b/templates/subreddit.html @@ -82,7 +82,7 @@
{% endif %} - {% if is_filtered || (!sub.name.is_empty() && sub.name != "all" && sub.name != "popular" && !sub.name.contains("+")) %} + {% if is_filtered || (!sub.name.is_empty() && sub.name != "all" && sub.name != "popular" && !sub.name.contains("+")) && prefs.hide_sidebar_and_summary != "on" %}