diff --git a/README.md b/README.md index 92dcef8..f0a7338 100644 --- a/README.md +++ b/README.md @@ -224,23 +224,23 @@ Assign a default value for each instance-specific setting by passing environment Assign a default value for each user-modifiable setting by passing environment variables to Libreddit in the format `LIBREDDIT_DEFAULT_{Y}`. Replace `{Y}` with the setting name (see list below) in capital letters. -| Name | Possible values | Default value | -|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|---------------| -| `THEME` | `["system", "light", "dark", "black", "dracula", "nord", "laserwave", "violet", "gold", "rosebox", "gruvboxdark", "gruvboxlight"]` | `system` | -| `FRONT_PAGE` | `["default", "popular", "all"]` | `default` | -| `LAYOUT` | `["card", "clean", "compact"]` | `card` | -| `WIDE` | `["on", "off"]` | `off` | -| `POST_SORT` | `["hot", "new", "top", "rising", "controversial"]` | `hot` | -| `COMMENT_SORT` | `["confidence", "top", "new", "controversial", "old"]` | `confidence` | -| `SHOW_NSFW` | `["on", "off"]` | `off` | -| `BLUR_NSFW` | `["on", "off"]` | `off` | -| `USE_HLS` | `["on", "off"]` | `off` | -| `HIDE_HLS_NOTIFICATION` | `["on", "off"]` | `off` | -| `AUTOPLAY_VIDEOS` | `["on", "off"]` | `off` | -| `SUBSCRIPTIONS` | `+`-delimited list of subreddits (`sub1+sub2+sub3+...`) | _(none)_ | -| `HIDE_AWARDS` | `["on", "off"]` | `off` | -| `DISABLE_VISIT_REDDIT_CONFIRMATION` | `["on", "off"]` | `off` | -| `DISABLE_STATS_COLLECTION | Any string to disable | _(none)_ | +| Name | Possible values | Default value | +|-------------------------|-----------------------------------------------------------------------------------------------------|---------------| +| `THEME` | `["system", "light", "dark", "black", "dracula", "nord", "laserwave", "violet", "gold", "rosebox", "gruvboxdark", "gruvboxlight"]` | `system` | +| `FRONT_PAGE` | `["default", "popular", "all"]` | `default` | +| `LAYOUT` | `["card", "clean", "compact"]` | `card` | +| `WIDE` | `["on", "off"]` | `off` | +| `POST_SORT` | `["hot", "new", "top", "rising", "controversial"]` | `hot` | +| `COMMENT_SORT` | `["confidence", "top", "new", "controversial", "old"]` | `confidence` | +| `SHOW_NSFW` | `["on", "off"]` | `off` | +| `BLUR_NSFW` | `["on", "off"]` | `off` | +| `USE_HLS` | `["on", "off"]` | `off` | +| `HIDE_HLS_NOTIFICATION` | `["on", "off"]` | `off` | +| `AUTOPLAY_VIDEOS` | `["on", "off"]` | `off` | +| `SUBSCRIPTIONS` | `+`-delimited list of subreddits (`sub1+sub2+sub3+...`) | _(none)_ | +| `HIDE_AWARDS` | `["on", "off"]` | `off` +| `HIDE_SCORE` | `["on", "off"]` | `off` +| `DISABLE_VISIT_REDDIT_CONFIRMATION` | `["on", "off"]` | `off` | You can also configure Libreddit with a configuration file. An example `libreddit.toml` can be found below: diff --git a/app.json b/app.json index fb0588f..8fc48fa 100644 --- a/app.json +++ b/app.json @@ -47,6 +47,9 @@ "LIBREDDIT_DEFAULT_HIDE_AWARDS": { "required": false }, + "LIBREDDIT_DEFAULT_HIDE_SCORE": { + "required": false + }, "LIBREDDIT_BANNER": { "required": false }, diff --git a/src/config.rs b/src/config.rs index e219550..f4f58ee 100644 --- a/src/config.rs +++ b/src/config.rs @@ -56,6 +56,9 @@ pub struct Config { #[serde(rename = "LIBREDDIT_DEFAULT_HIDE_AWARDS")] pub(crate) default_hide_awards: Option, + #[serde(rename = "LIBREDDIT_DEFAULT_HIDE_SCORE")] + pub(crate) default_hide_score: Option, + #[serde(rename = "LIBREDDIT_DEFAULT_SUBSCRIPTIONS")] pub(crate) default_subscriptions: Option, @@ -101,6 +104,7 @@ impl Config { default_use_hls: parse("LIBREDDIT_DEFAULT_USE_HLS"), default_hide_hls_notification: parse("LIBREDDIT_DEFAULT_HIDE_HLS"), default_hide_awards: parse("LIBREDDIT_DEFAULT_HIDE_AWARDS"), + default_hide_score: parse("LIBREDDIT_DEFAULT_HIDE_SCORE"), default_subscriptions: parse("LIBREDDIT_DEFAULT_SUBSCRIPTIONS"), default_disable_visit_reddit_confirmation: parse("LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"), banner: parse("LIBREDDIT_BANNER"), @@ -125,6 +129,7 @@ fn get_setting_from_config(name: &str, config: &Config) -> Option { "LIBREDDIT_DEFAULT_HIDE_HLS_NOTIFICATION" => config.default_hide_hls_notification.clone(), "LIBREDDIT_DEFAULT_WIDE" => config.default_wide.clone(), "LIBREDDIT_DEFAULT_HIDE_AWARDS" => config.default_hide_awards.clone(), + "LIBREDDIT_DEFAULT_HIDE_SCORE" => config.default_hide_score.clone(), "LIBREDDIT_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(), "LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(), "LIBREDDIT_BANNER" => config.banner.clone(), diff --git a/src/instance_info.rs b/src/instance_info.rs index edf379f..e1473ad 100644 --- a/src/instance_info.rs +++ b/src/instance_info.rs @@ -140,6 +140,7 @@ impl InstanceInfo { container.add_table( Table::from([ ["Hide awards", &convert(&self.config.default_hide_awards)], + ["Hide score", &convert(&self.config.default_hide_score)], ["Theme", &convert(&self.config.default_theme)], ["Front page", &convert(&self.config.default_front_page)], ["Layout", &convert(&self.config.default_layout)], @@ -173,6 +174,7 @@ impl InstanceInfo { Config:\n Banner: {:?}\n Hide awards: {:?}\n + Hide score: {:?}\n Default theme: {:?}\n Default front page: {:?}\n Default layout: {:?}\n @@ -196,6 +198,7 @@ impl InstanceInfo { self.config.pushshift, self.config.banner, self.config.default_hide_awards, + self.config.default_hide_score, self.config.default_theme, self.config.default_front_page, self.config.default_layout, diff --git a/src/settings.rs b/src/settings.rs index 3dd4e45..12795bc 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -19,7 +19,7 @@ struct SettingsTemplate { // CONSTANTS -const PREFS: [&str; 13] = [ +const PREFS: [&str; 14] = [ "theme", "front_page", "layout", @@ -32,6 +32,7 @@ const PREFS: [&str; 13] = [ "hide_hls_notification", "autoplay_videos", "hide_awards", + "hide_score", "disable_visit_reddit_confirmation", ]; diff --git a/src/utils.rs b/src/utils.rs index 09c2d5a..3931fad 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -578,6 +578,7 @@ pub struct Preferences { pub subscriptions: Vec, pub filters: Vec, pub hide_awards: String, + pub hide_score: String, } #[derive(RustEmbed)] @@ -597,21 +598,22 @@ impl Preferences { } Self { available_themes: themes, - theme: setting(req, "theme"), - front_page: setting(req, "front_page"), - layout: setting(req, "layout"), - wide: setting(req, "wide"), - show_nsfw: setting(req, "show_nsfw"), - blur_nsfw: setting(req, "blur_nsfw"), - use_hls: setting(req, "use_hls"), - hide_hls_notification: setting(req, "hide_hls_notification"), - autoplay_videos: setting(req, "autoplay_videos"), - disable_visit_reddit_confirmation: setting(req, "disable_visit_reddit_confirmation"), - comment_sort: setting(req, "comment_sort"), - post_sort: setting(req, "post_sort"), - subscriptions: setting(req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(), - filters: setting(req, "filters").split('+').map(String::from).filter(|s| !s.is_empty()).collect(), - hide_awards: setting(req, "hide_awards"), + theme: setting(&req, "theme"), + front_page: setting(&req, "front_page"), + layout: setting(&req, "layout"), + wide: setting(&req, "wide"), + show_nsfw: setting(&req, "show_nsfw"), + blur_nsfw: setting(&req, "blur_nsfw"), + use_hls: setting(&req, "use_hls"), + hide_hls_notification: setting(&req, "hide_hls_notification"), + autoplay_videos: setting(&req, "autoplay_videos"), + disable_visit_reddit_confirmation: setting(&req, "disable_visit_reddit_confirmation"), + comment_sort: setting(&req, "comment_sort"), + post_sort: setting(&req, "post_sort"), + subscriptions: setting(&req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(), + filters: setting(&req, "filters").split('+').map(String::from).filter(|s| !s.is_empty()).collect(), + hide_awards: setting(&req, "hide_awards"), + hide_score: setting(&req, "hide_score"), } } } diff --git a/templates/comment.html b/templates/comment.html index e75b888..ef1f4d8 100644 --- a/templates/comment.html +++ b/templates/comment.html @@ -5,8 +5,14 @@ {% else if kind == "t1" %}
-

{{ score.0 }}

-
+

+ {% if prefs.hide_score != "on" %} + {{ score.0 }} + {% else %} + • + {% endif %} +

+
diff --git a/templates/duplicates.html b/templates/duplicates.html index 4344325..d8faf2d 100644 --- a/templates/duplicates.html +++ b/templates/duplicates.html @@ -82,8 +82,14 @@ {% endif %} {{ post.title }}{% if post.flags.nsfw %} NSFW{% endif %} - -
{{ post.score.0 }} Upvotes
+ +
+ {% if prefs.hide_score != "on" %} + {{ post.score.0 }} + {% else %} + • + {% endif %} + Upvotes
diff --git a/templates/search.html b/templates/search.html index 53528e7..4278f19 100644 --- a/templates/search.html +++ b/templates/search.html @@ -77,7 +77,13 @@ {% else %}
-

{{ post.score.0 }}

+

+ {% if prefs.hide_score != "on" %} + {{ post.score.0 }} + {% else %} + • + {% endif %} +

diff --git a/templates/settings.html b/templates/settings.html index a7cc8dc..e70bfcd 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -90,6 +90,11 @@
+
+ + + +
@@ -132,7 +137,7 @@

Note: settings and subscriptions are saved in browser cookies. Clearing your cookies will reset them.


-

You can restore your current settings and subscriptions after clearing your cookies using this link.

+

You can restore your current settings and subscriptions after clearing your cookies using this link.

diff --git a/templates/user.html b/templates/user.html index a72cce0..3c97424 100644 --- a/templates/user.html +++ b/templates/user.html @@ -52,7 +52,13 @@ {% else %}
-

{{ post.score.0 }}

+

+ {% if prefs.hide_score != "on" %} + {{ post.score.0 }} + {% else %} + • + {% endif %} +

diff --git a/templates/utils.html b/templates/utils.html index 8e77d26..8481047 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -147,10 +147,13 @@
{{ post.body|safe }}
-
{{ post.score.0 }} Upvotes
- - {% call poll(post) %} - +
+ {% if prefs.hide_score != "on" %} + {{ post.score.0 }} + {% else %} + • + {% endif %} + Upvotes