diff --git a/src/search.rs b/src/search.rs index dd8439d..a789d49 100644 --- a/src/search.rs +++ b/src/search.rs @@ -33,7 +33,7 @@ struct SearchTemplate { // SERVICES pub async fn find(req: HttpRequest) -> HttpResponse { - let nsfw_results = if cookie(&req, "hide_nsfw") != "on" { "&include_over_18=on" } else { "" }; + let nsfw_results = if cookie(&req, "show_nsfw") == "on" { "&include_over_18=on" } else { "" }; let path = format!("{}.json?{}{}", req.path(), req.query_string(), nsfw_results); let sub = req.match_info().get("sub").unwrap_or("").to_string(); diff --git a/src/settings.rs b/src/settings.rs index 3b0fd72..6d7560f 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -18,7 +18,7 @@ pub struct SettingsForm { layout: Option, wide: Option, comment_sort: Option, - hide_nsfw: Option, + show_nsfw: Option, } // FUNCTIONS @@ -33,8 +33,8 @@ pub async fn get(req: HttpRequest) -> HttpResponse { pub async fn set(_req: HttpRequest, form: Form) -> HttpResponse { let mut res = HttpResponse::Found(); - let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "hide_nsfw"]; - let values = vec![&form.theme, &form.front_page, &form.layout, &form.wide, &form.comment_sort, &form.hide_nsfw]; + let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "show_nsfw"]; + let values = vec![&form.theme, &form.front_page, &form.layout, &form.wide, &form.comment_sort, &form.show_nsfw]; for (i, name) in names.iter().enumerate() { match values[i] { diff --git a/src/utils.rs b/src/utils.rs index 1efea71..da6ab3d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -127,7 +127,7 @@ pub struct Preferences { pub front_page: String, pub layout: String, pub wide: String, - pub hide_nsfw: String, + pub show_nsfw: String, pub comment_sort: String, pub subs: Vec, } @@ -143,7 +143,7 @@ pub fn prefs(req: HttpRequest) -> Preferences { front_page: cookie(&req, "front_page"), layout: cookie(&req, "layout"), wide: cookie(&req, "wide"), - hide_nsfw: cookie(&req, "hide_nsfw"), + show_nsfw: cookie(&req, "show_nsfw"), comment_sort: cookie(&req, "comment_sort"), subs: cookie(&req, "subscriptions").split('+').map(String::from).filter(|s| s != "").collect(), } diff --git a/templates/search.html b/templates/search.html index 37edfc6..1d6bb1e 100644 --- a/templates/search.html +++ b/templates/search.html @@ -46,7 +46,7 @@ {% endif %} {% for post in posts %} - {% if post.flags.nsfw && prefs.hide_nsfw == "on" %} + {% if post.flags.nsfw && prefs.show_nsfw != "on" %} {% else if post.title != "Comment" %}

diff --git a/templates/settings.html b/templates/settings.html index 1da5cce..8369ed8 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -42,9 +42,9 @@ {% call utils::options(prefs.comment_sort, ["confidence", "top", "new", "controversial", "old"], "confidence") %}

-
- - +
+ +

Note: settings are saved in browser cookies. Clearing your cookie data will reset them.

diff --git a/templates/subreddit.html b/templates/subreddit.html index 315244a..6fd7325 100644 --- a/templates/subreddit.html +++ b/templates/subreddit.html @@ -41,7 +41,7 @@
{% for post in posts %} - {% if !(post.flags.nsfw && prefs.hide_nsfw == "on") %} + {% if !(post.flags.nsfw && prefs.show_nsfw != "on") %}

diff --git a/templates/user.html b/templates/user.html index c19a3ca..a556a98 100644 --- a/templates/user.html +++ b/templates/user.html @@ -31,7 +31,7 @@

{% for post in posts %} - {% if post.flags.nsfw && prefs.hide_nsfw == "on" %} + {% if post.flags.nsfw && prefs.show_nsfw != "on" %} {% else if post.title != "Comment" %}