From 30944579d7ceb8eaef5d4e94395df5c3032285ab Mon Sep 17 00:00:00 2001 From: nieve Date: Tue, 18 Jun 2024 00:21:00 -0400 Subject: [PATCH 01/19] add default filter config --- .env.example | 1 + app.json | 3 +++ src/config.rs | 12 ++++++++++++ src/instance_info.rs | 5 ++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index b74e45c..d8d08ee 100644 --- a/.env.example +++ b/.env.example @@ -36,6 +36,7 @@ REDLIB_DEFAULT_HIDE_HLS_NOTIFICATION=off REDLIB_DEFAULT_AUTOPLAY_VIDEOS=off # Define a default list of subreddit subscriptions (format: sub1+sub2+sub3) REDLIB_DEFAULT_SUBSCRIPTIONS= +REDLIB_DEFAULT_FILTERS= # Hide awards by default REDLIB_DEFAULT_HIDE_AWARDS=off # Hide sidebar and summary diff --git a/app.json b/app.json index e1ae650..b3e8616 100644 --- a/app.json +++ b/app.json @@ -59,6 +59,9 @@ "REDLIB_DEFAULT_SUBSCRIPTIONS": { "required": false }, + "REDLIB_DEFAULT_FILTERS": { + "required": false + }, "REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION": { "required": false }, diff --git a/src/config.rs b/src/config.rs index e345537..eea1ddf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -79,6 +79,10 @@ pub struct Config { #[serde(rename = "REDLIB_DEFAULT_SUBSCRIPTIONS")] #[serde(alias = "LIBREDDIT_DEFAULT_SUBSCRIPTIONS")] pub(crate) default_subscriptions: Option, + + #[serde(rename = "REDLIB_DEFAULT_FILTERS")] + #[serde(alias = "LIBREDDIT_DEFAULT_FILTERS")] + pub(crate) default_filters: Option, #[serde(rename = "REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION")] #[serde(alias = "LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION")] @@ -134,6 +138,7 @@ impl Config { 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_filters: parse("REDLIB_DEFAULT_FILTERS"), default_disable_visit_reddit_confirmation: parse("REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"), banner: parse("REDLIB_BANNER"), robots_disable_indexing: parse("REDLIB_ROBOTS_DISABLE_INDEXING"), @@ -159,6 +164,7 @@ fn get_setting_from_config(name: &str, config: &Config) -> Option { "REDLIB_DEFAULT_HIDE_SIDEBAR_AND_SUMMARY" => config.default_hide_sidebar_and_summary.clone(), "REDLIB_DEFAULT_HIDE_SCORE" => config.default_hide_score.clone(), "REDLIB_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(), + "REDLIB_DEFAULT_FILTERS" => config.default_filters.clone(), "REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(), "REDLIB_BANNER" => config.banner.clone(), "REDLIB_ROBOTS_DISABLE_INDEXING" => config.robots_disable_indexing.clone(), @@ -231,6 +237,12 @@ fn test_default_subscriptions() { assert_eq!(get_setting("REDLIB_DEFAULT_SUBSCRIPTIONS"), Some("news+bestof".into())); } +#[test] +#[sealed_test(env = [("REDLIB_DEFAULT_FILTERS", "news+bestof")])] +fn test_default_filters() { + assert_eq!(get_setting("REDLIB_DEFAULT_FILTERS"), Some("news+bestof".into())); +} + #[test] #[sealed_test] fn test_pushshift() { diff --git a/src/instance_info.rs b/src/instance_info.rs index 462e09c..85c4883 100644 --- a/src/instance_info.rs +++ b/src/instance_info.rs @@ -146,6 +146,7 @@ impl InstanceInfo { ["Use HLS", &convert(&self.config.default_use_hls)], ["Hide HLS notification", &convert(&self.config.default_hide_hls_notification)], ["Subscriptions", &convert(&self.config.default_subscriptions)], + ["Filters", &convert(&self.config.default_filters)], ]) .with_header_row(["Default preferences"]), ); @@ -177,7 +178,8 @@ impl InstanceInfo { Default blur NSFW: {:?}\n Default use HLS: {:?}\n Default hide HLS notification: {:?}\n - Default subscriptions: {:?}\n", + Default subscriptions: {:?}\n + Default filters: {:?}\n", self.package_name, self.crate_version, self.git_commit, @@ -200,6 +202,7 @@ impl InstanceInfo { self.config.default_use_hls, self.config.default_hide_hls_notification, self.config.default_subscriptions, + self.config.default_filters, ) } StringType::Html => self.to_table(), From 1408c32a4dfd338978601dfe793a1f7aea48f411 Mon Sep 17 00:00:00 2001 From: nieve Date: Tue, 18 Jun 2024 00:25:29 -0400 Subject: [PATCH 02/19] Update .env.example --- .env.example | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.example b/.env.example index d8d08ee..5e187f9 100644 --- a/.env.example +++ b/.env.example @@ -36,6 +36,7 @@ REDLIB_DEFAULT_HIDE_HLS_NOTIFICATION=off REDLIB_DEFAULT_AUTOPLAY_VIDEOS=off # Define a default list of subreddit subscriptions (format: sub1+sub2+sub3) REDLIB_DEFAULT_SUBSCRIPTIONS= +# Define a default list of subreddit filters (format: sub1+sub2+sub3) REDLIB_DEFAULT_FILTERS= # Hide awards by default REDLIB_DEFAULT_HIDE_AWARDS=off From 3491e754ac44bef07f3b9ad7c491918e4cb61556 Mon Sep 17 00:00:00 2001 From: nieve Date: Tue, 18 Jun 2024 00:30:53 -0400 Subject: [PATCH 03/19] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a8d371a..6ca325c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ /target .env +redlib.toml + # Idea Files .idea/ From 91975865b88faa578d12481457778fedd26be630 Mon Sep 17 00:00:00 2001 From: Alessandro Pizzorni Date: Wed, 19 Jun 2024 00:42:38 +0200 Subject: [PATCH 04/19] Make server listen on both IPv6 and IPv4 by default --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ee2da5a..3eccc30 100644 --- a/src/main.rs +++ b/src/main.rs @@ -135,7 +135,7 @@ async fn main() { .long("address") .value_name("ADDRESS") .help("Sets address to listen on") - .default_value("0.0.0.0") + .default_value("[::]") .num_args(1), ) .arg( From 5a13b9892b37e5041224fc773501af7cc6dda37a Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Wed, 19 Jun 2024 14:28:48 -0400 Subject: [PATCH 05/19] chore(clippy): add lint --- src/utils.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils.rs b/src/utils.rs index dbaf1de..05a7f7b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] use crate::config::get_setting; // // CRATES From 997cd8f829f8be18d4fe051b19d318cf53df7cb3 Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Wed, 19 Jun 2024 14:45:32 -0400 Subject: [PATCH 06/19] feat(bug): Improve bug reporting while keeping logs private --- src/client.rs | 12 ++++++------ src/utils.rs | 2 +- templates/error.html | 16 ++++++++++------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/client.rs b/src/client.rs index 5ea9d1c..34934a8 100644 --- a/src/client.rs +++ b/src/client.rs @@ -314,9 +314,9 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo #[cached(size = 100, time = 30, result = true)] pub async fn json(path: String, quarantine: bool) -> Result { // Closure to quickly build errors - let err = |msg: &str, e: String| -> Result { + let err = |msg: &str, e: String, path: String| -> Result { // eprintln!("{} - {}: {}", url, msg, e); - Err(format!("{msg}: {e}")) + Err(format!("{msg}: {e} | {path}")) }; // Fetch the url... @@ -339,7 +339,7 @@ pub async fn json(path: String, quarantine: bool) -> Result { let () = force_refresh_token().await; return Err("OAuth token has expired. Please refresh the page!".to_string()); } - Err(format!("Reddit error {} \"{}\": {}", json["error"], json["reason"], json["message"])) + Err(format!("Reddit error {} \"{}\": {} | {path}", json["error"], json["reason"], json["message"])) } else { Ok(json) } @@ -349,15 +349,15 @@ pub async fn json(path: String, quarantine: bool) -> Result { if status.is_server_error() { Err("Reddit is having issues, check if there's an outage".to_string()) } else { - err("Failed to parse page JSON data", e.to_string()) + err("Failed to parse page JSON data", e.to_string(), path) } } } } - Err(e) => err("Failed receiving body from Reddit", e.to_string()), + Err(e) => err("Failed receiving body from Reddit", e.to_string(), path), } } - Err(e) => err("Couldn't send request to Reddit", e), + Err(e) => err("Couldn't send request to Reddit", e, path), } } diff --git a/src/utils.rs b/src/utils.rs index 05a7f7b..ff75a06 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1029,7 +1029,7 @@ pub fn redirect(path: &str) -> Response { /// Renders a generic error landing page. pub async fn error(req: Request, msg: &str) -> Result, String> { - error!("Error page rendered: {msg}"); + error!("Error page rendered: {}", msg.split("|").next().unwrap_or_default()); let url = req.uri().to_string(); let body = ErrorTemplate { msg: msg.to_string(), diff --git a/templates/error.html b/templates/error.html index a16fc74..e831200 100644 --- a/templates/error.html +++ b/templates/error.html @@ -2,10 +2,14 @@ {% block title %}Error: {{ msg }}{% endblock %} {% block sortstyle %}{% endblock %} {% block content %} -
-

{{ msg }}

-

Reddit Status

-
-

Head back home?

-
+
+

{{ msg }}

+

Reddit Status

+
+

Expected something to work? Report + an issue

+
+

Head back home?

+
{% endblock %} \ No newline at end of file From 9013e589dd67443c4267b8be58286f5c4ea2790a Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Wed, 19 Jun 2024 14:45:55 -0400 Subject: [PATCH 07/19] chore(clippy): fix lint --- src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index ff75a06..f44d037 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1029,7 +1029,7 @@ pub fn redirect(path: &str) -> Response { /// Renders a generic error landing page. pub async fn error(req: Request, msg: &str) -> Result, String> { - error!("Error page rendered: {}", msg.split("|").next().unwrap_or_default()); + error!("Error page rendered: {}", msg.split('|').next().unwrap_or_default()); let url = req.uri().to_string(); let body = ErrorTemplate { msg: msg.to_string(), From f460895cc04a1346fcafc0a4a8cb9bd879c1d01f Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Thu, 20 Jun 2024 07:56:43 -0400 Subject: [PATCH 08/19] chore(clippy): fix lint --- src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index eea1ddf..a787251 100644 --- a/src/config.rs +++ b/src/config.rs @@ -79,7 +79,7 @@ pub struct Config { #[serde(rename = "REDLIB_DEFAULT_SUBSCRIPTIONS")] #[serde(alias = "LIBREDDIT_DEFAULT_SUBSCRIPTIONS")] pub(crate) default_subscriptions: Option, - + #[serde(rename = "REDLIB_DEFAULT_FILTERS")] #[serde(alias = "LIBREDDIT_DEFAULT_FILTERS")] pub(crate) default_filters: Option, From 3301da1ef1e71866a367f27e1deb58006fc04eca Mon Sep 17 00:00:00 2001 From: pimlie Date: Sat, 22 Jun 2024 12:16:12 +0200 Subject: [PATCH 09/19] feat: add support to blur spoiler previews --- .env.example | 2 ++ README.md | 1 + app.json | 3 +++ contrib/redlib.conf | 1 + src/config.rs | 6 ++++++ src/instance_info.rs | 3 +++ src/settings.rs | 3 ++- src/utils.rs | 5 +++++ templates/settings.html | 5 +++++ templates/utils.html | 11 ++++++----- 10 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 5e187f9..5e60b08 100644 --- a/.env.example +++ b/.env.example @@ -24,6 +24,8 @@ REDLIB_DEFAULT_WIDE=off REDLIB_DEFAULT_POST_SORT=hot # Set the default comment sort method (options: confidence, top, new, controversial, old) REDLIB_DEFAULT_COMMENT_SORT=confidence +# Enable blurring Spoiler content by default +REDLIB_DEFAULT_BLUR_SPOILER=off # Enable showing NSFW content by default REDLIB_DEFAULT_SHOW_NSFW=off # Enable blurring NSFW content by default diff --git a/README.md b/README.md index 1773858..533b628 100644 --- a/README.md +++ b/README.md @@ -394,6 +394,7 @@ Assign a default value for each user-modifiable setting by passing environment v | `WIDE` | `["on", "off"]` | `off` | | `POST_SORT` | `["hot", "new", "top", "rising", "controversial"]` | `hot` | | `COMMENT_SORT` | `["confidence", "top", "new", "controversial", "old"]` | `confidence` | +| `BLUR_SPOILER` | `["on", "off"]` | `off` | | `SHOW_NSFW` | `["on", "off"]` | `off` | | `BLUR_NSFW` | `["on", "off"]` | `off` | | `USE_HLS` | `["on", "off"]` | `off` | diff --git a/app.json b/app.json index b3e8616..d73780c 100644 --- a/app.json +++ b/app.json @@ -29,6 +29,9 @@ "REDLIB_DEFAULT_POST_SORT": { "required": false }, + "REDLIB_DEFAULT_BLUR_SPOILER": { + "required": false + }, "REDLIB_DEFAULT_SHOW_NSFW": { "required": false }, diff --git a/contrib/redlib.conf b/contrib/redlib.conf index 880bc7a..43c1d86 100644 --- a/contrib/redlib.conf +++ b/contrib/redlib.conf @@ -6,6 +6,7 @@ PORT=12345 #REDLIB_DEFAULT_WIDE=off #REDLIB_DEFAULT_POST_SORT=hot #REDLIB_DEFAULT_COMMENT_SORT=confidence +#REDLIB_DEFAULT_BLUR_SPOILER=off #REDLIB_DEFAULT_SHOW_NSFW=off #REDLIB_DEFAULT_BLUR_NSFW=off #REDLIB_DEFAULT_USE_HLS=off diff --git a/src/config.rs b/src/config.rs index a787251..2b8c752 100644 --- a/src/config.rs +++ b/src/config.rs @@ -48,6 +48,10 @@ pub struct Config { #[serde(alias = "LIBREDDIT_DEFAULT_POST_SORT")] pub(crate) default_post_sort: Option, + #[serde(rename = "REDLIB_DEFAULT_BLUR_SPOILER")] + #[serde(alias = "LIBREDDIT_DEFAULT_BLUR_SPOILER")] + pub(crate) default_blur_spoiler: Option, + #[serde(rename = "REDLIB_DEFAULT_SHOW_NSFW")] #[serde(alias = "LIBREDDIT_DEFAULT_SHOW_NSFW")] pub(crate) default_show_nsfw: Option, @@ -130,6 +134,7 @@ impl Config { default_post_sort: parse("REDLIB_DEFAULT_POST_SORT"), default_wide: parse("REDLIB_DEFAULT_WIDE"), default_comment_sort: parse("REDLIB_DEFAULT_COMMENT_SORT"), + default_blur_spoiler: parse("REDLIB_DEFAULT_BLUR_SPOILER"), default_show_nsfw: parse("REDLIB_DEFAULT_SHOW_NSFW"), default_blur_nsfw: parse("REDLIB_DEFAULT_BLUR_NSFW"), default_use_hls: parse("REDLIB_DEFAULT_USE_HLS"), @@ -155,6 +160,7 @@ fn get_setting_from_config(name: &str, config: &Config) -> Option { "REDLIB_DEFAULT_LAYOUT" => config.default_layout.clone(), "REDLIB_DEFAULT_COMMENT_SORT" => config.default_comment_sort.clone(), "REDLIB_DEFAULT_POST_SORT" => config.default_post_sort.clone(), + "REDLIB_DEFAULT_BLUR_SPOILER" => config.default_blur_spoiler.clone(), "REDLIB_DEFAULT_SHOW_NSFW" => config.default_show_nsfw.clone(), "REDLIB_DEFAULT_BLUR_NSFW" => config.default_blur_nsfw.clone(), "REDLIB_DEFAULT_USE_HLS" => config.default_use_hls.clone(), diff --git a/src/instance_info.rs b/src/instance_info.rs index 85c4883..20ffc6d 100644 --- a/src/instance_info.rs +++ b/src/instance_info.rs @@ -141,6 +141,7 @@ impl InstanceInfo { ["Wide", &convert(&self.config.default_wide)], ["Comment sort", &convert(&self.config.default_comment_sort)], ["Post sort", &convert(&self.config.default_post_sort)], + ["Blur Spoiler", &convert(&self.config.default_blur_spoiler)], ["Show NSFW", &convert(&self.config.default_show_nsfw)], ["Blur NSFW", &convert(&self.config.default_blur_nsfw)], ["Use HLS", &convert(&self.config.default_use_hls)], @@ -174,6 +175,7 @@ impl InstanceInfo { Default wide: {:?}\n Default comment sort: {:?}\n Default post sort: {:?}\n + Default blur Spoiler: {:?}\n Default show NSFW: {:?}\n Default blur NSFW: {:?}\n Default use HLS: {:?}\n @@ -197,6 +199,7 @@ impl InstanceInfo { self.config.default_wide, self.config.default_comment_sort, self.config.default_post_sort, + self.config.default_blur_spoiler, self.config.default_show_nsfw, self.config.default_blur_nsfw, self.config.default_use_hls, diff --git a/src/settings.rs b/src/settings.rs index 6964675..6c0480c 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -19,13 +19,14 @@ struct SettingsTemplate { // CONSTANTS -const PREFS: [&str; 16] = [ +const PREFS: [&str; 17] = [ "theme", "front_page", "layout", "wide", "comment_sort", "post_sort", + "blur_spoiler", "show_nsfw", "blur_nsfw", "use_hls", diff --git a/src/utils.rs b/src/utils.rs index f44d037..4d412cc 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -157,6 +157,7 @@ impl PollOption { // Post flags with nsfw and stickied pub struct Flags { + pub spoiler: bool, pub nsfw: bool, pub stickied: bool, } @@ -403,6 +404,7 @@ impl Post { }, }, flags: Flags { + spoiler: data["spoiler"].as_bool().unwrap_or_default(), nsfw: data["over_18"].as_bool().unwrap_or_default(), stickied: data["stickied"].as_bool().unwrap_or_default() || data["pinned"].as_bool().unwrap_or_default(), }, @@ -575,6 +577,7 @@ pub struct Preferences { pub front_page: String, pub layout: String, pub wide: String, + pub blur_spoiler: String, pub show_nsfw: String, pub blur_nsfw: String, pub hide_hls_notification: String, @@ -612,6 +615,7 @@ impl Preferences { front_page: setting(req, "front_page"), layout: setting(req, "layout"), wide: setting(req, "wide"), + blur_spoiler: setting(req, "blur_spoiler"), show_nsfw: setting(req, "show_nsfw"), hide_sidebar_and_summary: setting(req, "hide_sidebar_and_summary"), blur_nsfw: setting(req, "blur_nsfw"), @@ -732,6 +736,7 @@ pub async fn parse_post(post: &Value) -> Post { }, }, flags: Flags { + spoiler: post["data"]["spoiler"].as_bool().unwrap_or_default(), nsfw: post["data"]["over_18"].as_bool().unwrap_or_default(), stickied: post["data"]["stickied"].as_bool().unwrap_or_default() || post["data"]["pinned"].as_bool().unwrap_or(false), }, diff --git a/templates/settings.html b/templates/settings.html index 496b9b1..434f0d2 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -54,6 +54,11 @@ {% call utils::options(prefs.comment_sort, ["confidence", "top", "new", "controversial", "old"], "confidence") %} +
+ + + +
{% if !crate::utils::sfw_only() %}
diff --git a/templates/utils.html b/templates/utils.html index a99e2be..e40d6c6 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -194,6 +194,7 @@ {% endmacro %} {% macro post_in_list(post) -%} +{% set post_should_be_blurred = (post.flags.nsfw && prefs.blur_nsfw=="on") || (post.flags.spoiler && prefs.blur_spoiler=="on") -%}

{% let community -%} @@ -233,7 +234,7 @@ Post image {% else %} @@ -247,19 +248,19 @@

{% else if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "gif" %}
- +
{% else if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "video" %} {% if prefs.use_hls == "on" && !post.media.alt_url.is_empty() %}
-
{% else %}
- +
{% call render_hls_notification(format!("{}%23{}", &self.url[1..].replace("&", "%26").replace("+", "%2B"), post.id)) %} {% endif %} @@ -272,7 +273,7 @@ {% else %}
- + Thumbnail From 1d44bd180e5802f160c40af1924239a3cfcdfaff Mon Sep 17 00:00:00 2001 From: pimlie Date: Sat, 22 Jun 2024 12:38:13 +0200 Subject: [PATCH 10/19] feat: add spoiler badge to post title --- static/style.css | 11 +++++++++++ templates/utils.html | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/static/style.css b/static/style.css index 7cef37c..05b4e4b 100644 --- a/static/style.css +++ b/static/style.css @@ -52,6 +52,7 @@ --visited: #aaa; --shadow: 0 1px 3px rgba(0, 0, 0, 0.5); --popup: #b80a27; + --spoiler: #ddd; /* Hint color theme to browser for scrollbar */ color-scheme: dark; @@ -71,6 +72,7 @@ --highlighted: white; --visited: #555; --shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + --spoiler: #0f0f0f; /* Hint color theme to browser for scrollbar */ color-scheme: light; @@ -929,6 +931,15 @@ a.search_subreddit:hover { font-weight: bold; } +.spoiler { + color: var(--spoiler); + margin-left: 5px; + border: 1px solid var(--spoiler); + padding: 3px; + font-size: 12px; + border-radius: 5px; +} + .post_media_content, .post .__NoScript_PlaceHolder__, .gallery { max-width: calc(100% - 40px); grid-area: post_media; diff --git a/templates/utils.html b/templates/utils.html index e40d6c6..2722218 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -93,6 +93,7 @@ style="color:{{ post.flair.foreground_color }}; background:{{ post.flair.background_color }};">{% call render_flair(post.flair.flair_parts) %} {% endif %} {% if post.flags.nsfw %} NSFW{% endif %} + {% if post.flags.spoiler %} Spoiler{% endif %} @@ -223,7 +224,7 @@ style="color:{{ post.flair.foreground_color }}; background:{{ post.flair.background_color }};" dir="ltr">{% call render_flair(post.flair.flair_parts) %} {% endif %} - {{ post.title }}{% if post.flags.nsfw %} NSFW{% endif %} + {{ post.title }}{% if post.flags.nsfw %} NSFW{% endif %}{% if post.flags.spoiler %} Spoiler{% endif %} {% if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "image" %} From 69f9d9ff3c38a78136dda889730d8f391be28165 Mon Sep 17 00:00:00 2001 From: pimlie Date: Sat, 22 Jun 2024 12:47:33 +0200 Subject: [PATCH 11/19] feat: also blur spoiler previews on post view --- templates/utils.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/utils.html b/templates/utils.html index 2722218..8edb55b 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -62,6 +62,7 @@ {%- endmacro %} {% macro post(post) -%} +{% set post_should_be_blurred = post.flags.spoiler && prefs.blur_spoiler=="on" -%}

@@ -102,12 +103,13 @@

{% if post.media.height == 0 || post.media.width == 0 %} - - Post image + + Post image {% else %} @@ -121,7 +123,7 @@ {% if prefs.use_hls == "on" && !post.media.alt_url.is_empty() %}
-