|
|
|
@ -16,19 +16,6 @@ struct SettingsTemplate {
|
|
|
|
|
prefs: Preferences,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize, Default, Debug)]
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub struct Form {
|
|
|
|
|
theme: Option<String>,
|
|
|
|
|
front_page: Option<String>,
|
|
|
|
|
layout: Option<String>,
|
|
|
|
|
wide: Option<String>,
|
|
|
|
|
comment_sort: Option<String>,
|
|
|
|
|
show_nsfw: Option<String>,
|
|
|
|
|
redirect: Option<String>,
|
|
|
|
|
subscriptions: Option<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FUNCTIONS
|
|
|
|
|
|
|
|
|
|
// Retrieve cookies from request "Cookie" header
|
|
|
|
@ -63,7 +50,7 @@ pub async fn set(req: Request<Body>) -> Result<Response<Body>, String> {
|
|
|
|
|
|
|
|
|
|
let mut res = redirect("/settings".to_string());
|
|
|
|
|
|
|
|
|
|
let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "show_nsfw", "subscriptions"];
|
|
|
|
|
let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "post_sort", "show_nsfw", "subscriptions"];
|
|
|
|
|
|
|
|
|
|
for name in names {
|
|
|
|
|
match form.get(name) {
|
|
|
|
@ -98,7 +85,7 @@ pub async fn restore(req: Request<Body>) -> Result<Response<Body>, String> {
|
|
|
|
|
|
|
|
|
|
let form = url::form_urlencoded::parse(query).collect::<HashMap<_, _>>();
|
|
|
|
|
|
|
|
|
|
let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "show_nsfw", "subscriptions"];
|
|
|
|
|
let names = vec!["theme", "front_page", "layout", "wide", "comment_sort", "post_sort", "show_nsfw", "subscriptions"];
|
|
|
|
|
|
|
|
|
|
let path = match form.get("redirect") {
|
|
|
|
|
Some(value) => format!("/{}/", value),
|
|
|
|
|