diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-29 17:06:23 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-29 17:06:23 +0200 |
commit | 212a0f23bc894faf88e159560c113f504349cc05 (patch) | |
tree | ee2ff0ff3b185d1874eb0e8fc4b75f1badf659b8 /ui | |
parent | f73aa32549743b2967160d38c1622199c41524a4 (diff) | |
download | jellything-212a0f23bc894faf88e159560c113f504349cc05.tar jellything-212a0f23bc894faf88e159560c113f504349cc05.tar.bz2 jellything-212a0f23bc894faf88e159560c113f504349cc05.tar.zst |
comiles again but still many logic holes
Diffstat (limited to 'ui')
-rw-r--r-- | ui/src/account/mod.rs | 83 | ||||
-rw-r--r-- | ui/src/account/settings.rs (renamed from ui/src/settings.rs) | 12 | ||||
-rw-r--r-- | ui/src/admin/log.rs | 10 | ||||
-rw-r--r-- | ui/src/lib.rs | 1 | ||||
-rw-r--r-- | ui/src/stats.rs | 16 |
5 files changed, 112 insertions, 10 deletions
diff --git a/ui/src/account/mod.rs b/ui/src/account/mod.rs index bc8d3ce..36a41c5 100644 --- a/ui/src/account/mod.rs +++ b/ui/src/account/mod.rs @@ -3,8 +3,55 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin <metamuffin.org> */ -use crate::locale::{Language, tr, trs}; -use jellycommon::routes::u_account_login; +pub mod settings; + +use crate::{ + Page, + locale::{Language, tr, trs}, +}; +use jellycommon::routes::{u_account_login, u_account_register}; + +impl Page for AccountLogin<'_> { + fn title(&self) -> String { + tr( + *self.lang, + if self.logged_in { + "account.login.switch" + } else { + "account.login" + }, + ) + .to_string() + } + + fn to_render(&self) -> markup::DynRender { + markup::new!(@self) + } +} +impl Page for AccountRegister<'_> { + fn title(&self) -> String { + tr(*self.lang, "account.register").to_string() + } + fn to_render(&self) -> markup::DynRender { + markup::new!(@self) + } +} +impl Page for AccountRegisterSuccess<'_> { + fn title(&self) -> String { + tr(*self.lang, "account.register").to_string() + } + fn to_render(&self) -> markup::DynRender { + markup::new!(@self) + } +} +impl Page for AccountLogout<'_> { + fn title(&self) -> String { + tr(*self.lang, "account.logout").to_string() + } + fn to_render(&self) -> markup::DynRender { + markup::new!(@self) + } +} markup::define! { AccountRegister<'a>(lang: &'a Language) { @@ -24,4 +71,36 @@ markup::define! { p { @trs(&lang, "account.register.login") " " a[href=u_account_login()] { @trs(&lang, "account.register.login_here") } } } } + AccountRegisterSuccess<'a>(lang: &'a Language, logged_in: bool) { + h1 { @trs(&lang, if *logged_in { + "account.register.success.switch" + } else { + "account.register.success" + })} + } + AccountLogin<'a>(lang: &'a Language, logged_in: bool) { + form.account[method="POST", action=""] { + h1 { @self.title() } + + label[for="inp-username"] { @trs(&lang, "account.username") } + input[type="text", id="inp-username", name="username"]; br; + label[for="inp-password"] { @trs(&lang, "account.password") } + input[type="password", id="inp-password", name="password"]; br; + + input[type="submit", value=&*tr(**lang, if *logged_in { "account.login.submit.switch" } else { "account.login.submit" })]; + + @if *logged_in { + p { @trs(&lang, "account.login.register.switch") " " a[href=u_account_register()] { @trs(&lang, "account.login.register_here") } } + } else { + p { @trs(&lang, "account.login.cookie_note") } + p { @trs(&lang, "account.login.register") " " a[href=u_account_register()] { @trs(&lang, "account.login.register_here") } } + } + } + } + AccountLogout<'a>(lang: &'a Language) { + form.account[method="POST", action=""] { + h1 { @trs(&lang, "account.logout") } + input[type="submit", value=&*tr(**lang, "account.logout.submit")]; + } + } } diff --git a/ui/src/settings.rs b/ui/src/account/settings.rs index 5ff3946..7c5a3b8 100644 --- a/ui/src/settings.rs +++ b/ui/src/account/settings.rs @@ -4,6 +4,7 @@ Copyright (C) 2025 metamuffin <metamuffin.org> */ use crate::{ + Page, locale::{Language, tr, trs}, scaffold::SessionInfo, }; @@ -13,8 +14,17 @@ use jellycommon::{ }; use markup::RenderAttributeValue; +impl Page for SettingsPage<'_> { + fn title(&self) -> String { + format!("Settings") + } + fn to_render(&self) -> markup::DynRender { + markup::new!(@self) + } +} + markup::define! { - Settings<'a>(flash: Option<Result<String, String>>, session: &'a SessionInfo, lang: &'a Language) { + SettingsPage<'a>(flash: Option<Result<String, String>>, session: &'a SessionInfo, lang: &'a Language) { h1 { "Settings" } @if let Some(flash) = &flash { @match flash { diff --git a/ui/src/admin/log.rs b/ui/src/admin/log.rs index a69bdfa..3669571 100644 --- a/ui/src/admin/log.rs +++ b/ui/src/admin/log.rs @@ -4,6 +4,7 @@ Copyright (C) 2025 metamuffin <metamuffin.org> */ +use crate::Page; use jellycommon::{ api::{LogLevel, LogLine}, routes::u_admin_log, @@ -11,6 +12,15 @@ use jellycommon::{ use markup::raw; use std::fmt::Write; +impl Page for ServerLogPage<'_> { + fn title(&self) -> String { + "Server Log".to_string() + } + fn to_render(&self) -> markup::DynRender { + markup::new!(@self) + } +} + markup::define! { ServerLogPage<'a>(warnonly: bool, messages: &'a [String]) { h1 { "Server Log" } diff --git a/ui/src/lib.rs b/ui/src/lib.rs index 8a4b950..4f1901a 100644 --- a/ui/src/lib.rs +++ b/ui/src/lib.rs @@ -12,7 +12,6 @@ pub mod node_page; pub mod props; pub mod scaffold; pub mod search; -pub mod settings; pub mod stats; pub mod items; pub mod admin; diff --git a/ui/src/stats.rs b/ui/src/stats.rs index c3e5a14..11163f3 100644 --- a/ui/src/stats.rs +++ b/ui/src/stats.rs @@ -5,6 +5,7 @@ */ use crate::{ + Page, format::{format_duration, format_duration_long, format_kind, format_size}, locale::{Language, tr, trs}, }; @@ -14,6 +15,15 @@ use jellycommon::{ }; use markup::raw; +impl Page for StatsPage<'_> { + fn title(&self) -> String { + tr(*self.lang, "stats.title").to_string() + } + fn to_render(&self) -> markup::DynRender { + markup::new!(@self) + } +} + markup::define! { StatsPage<'a>(lang: &'a Language, r: ApiStatsResponse) { .page.stats { @@ -57,12 +67,6 @@ markup::define! { } } -impl StatsPage<'_> { - pub fn title(&self) -> String { - tr(*self.lang, "stats.title").to_string() - } -} - trait BinExt { fn average_runtime(&self) -> f64; fn average_size(&self) -> f64; |