aboutsummaryrefslogtreecommitdiff
path: root/ui/src/settings.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/settings.rs')
-rw-r--r--ui/src/settings.rs31
1 files changed, 17 insertions, 14 deletions
diff --git a/ui/src/settings.rs b/ui/src/settings.rs
index 9bc4b1d..fb4ef0f 100644
--- a/ui/src/settings.rs
+++ b/ui/src/settings.rs
@@ -4,7 +4,10 @@
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
use crate::locale::{Language, tr, trs};
-use jellycommon::user::{PlayerKind, Theme};
+use jellycommon::{
+ routes::{u_account_login, u_account_settings},
+ user::{PlayerKind, Theme},
+};
use markup::RenderAttributeValue;
markup::define! {
@@ -17,42 +20,42 @@ markup::define! {
}
}
h2 { @trs(&lang, "account") }
- a.switch_account[href=uri!(r_account_login())] { "Switch Account" }
- form[method="POST", action=uri!(r_account_settings_post())] {
+ a.switch_account[href=u_account_login()] { "Switch Account" }
+ form[method="POST", action=u_account_settings()] {
label[for="username"] { @trs(&lang, "account.username") }
input[type="text", id="username", disabled, value=&session.user.name];
input[type="submit", disabled, value=&*tr(**lang, "settings.immutable")];
}
- form[method="POST", action=uri!(r_account_settings_post())] {
+ form[method="POST", action=u_account_settings()] {
label[for="display_name"] { @trs(lang, "account.display_name") }
input[type="text", id="display_name", name="display_name", value=&session.user.display_name];
input[type="submit", value=&*tr(**lang, "settings.update")];
}
- form[method="POST", action=uri!(r_account_settings_post())] {
+ form[method="POST", action=u_account_settings()] {
label[for="password"] { @trs(lang, "account.password") }
input[type="password", id="password", name="password"];
input[type="submit", value=&*tr(**lang, "settings.update")];
}
h2 { @trs(&lang, "settings.appearance") }
- form[method="POST", action=uri!(r_account_settings_post())] {
+ form[method="POST", action=u_account_settings()] {
fieldset {
legend { @trs(&lang, "settings.appearance.theme") }
- @for (t, tlabel) in Theme::LIST {
- label { input[type="radio", name="theme", value=A(*t), checked=session.user.theme==*t]; @tlabel } br;
+ @for theme in Theme::ALL {
+ label { input[type="radio", name="theme", value=A(*theme), checked=session.user.theme==*theme]; @trs(lang, &format!("theme.{theme}")) } br;
}
}
input[type="submit", value=&*tr(**lang, "settings.apply")];
}
- form[method="POST", action=uri!(r_account_settings_post())] {
+ form[method="POST", action=u_account_settings()] {
fieldset {
legend { @trs(&lang, "settings.player_preference") }
- @for (t, tlabel) in PlayerKind::LIST {
- label { input[type="radio", name="player_preference", value=A(*t), checked=session.user.player_preference==*t]; @tlabel } br;
+ @for kind in PlayerKind::ALL {
+ label { input[type="radio", name="player_preference", value=A(*kind), checked=session.user.player_preference==*kind]; @trs(lang, &format!("player_kind.{kind}")) } br;
}
}
input[type="submit", value=&*tr(**lang, "settings.apply")];
}
- form[method="POST", action=uri!(r_account_settings_post())] {
+ form[method="POST", action=u_account_settings()] {
label[for="native_secret"] { "Native Secret" }
input[type="password", id="native_secret", name="native_secret"];
input[type="submit", value=&*tr(**lang, "settings.update")];
@@ -64,12 +67,12 @@ markup::define! {
struct A<T>(pub T);
impl markup::Render for A<Theme> {
fn render(&self, writer: &mut impl std::fmt::Write) -> std::fmt::Result {
- writer.write_fmt(format_args!("{}", self as &dyn UriDisplay<Query>))
+ writer.write_str(self.0.to_str())
}
}
impl markup::Render for A<PlayerKind> {
fn render(&self, writer: &mut impl std::fmt::Write) -> std::fmt::Result {
- writer.write_fmt(format_args!("{}", self as &dyn UriDisplay<Query>))
+ writer.write_str(self.0.to_str())
}
}
impl RenderAttributeValue for A<Theme> {}