diff options
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/Cargo.toml | 2 | ||||
| -rw-r--r-- | ui/src/components/login.rs | 43 | ||||
| -rw-r--r-- | ui/src/components/mod.rs | 16 | ||||
| -rw-r--r-- | ui/src/old/account/mod.rs | 103 |
4 files changed, 59 insertions, 105 deletions
diff --git a/ui/Cargo.toml b/ui/Cargo.toml index 9bf5082..55ff42f 100644 --- a/ui/Cargo.toml +++ b/ui/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] -markup = { git = "https://github.com/metamuffin/markup.rs", rev = "2ee9aee" } +markup = "0.16.0" jellycommon = { path = "../common" } humansize = "2.1.3" serde = { version = "1.0.228", features = ["derive", "rc"] } diff --git a/ui/src/components/login.rs b/ui/src/components/login.rs new file mode 100644 index 0000000..c54a541 --- /dev/null +++ b/ui/src/components/login.rs @@ -0,0 +1,43 @@ +/* + This file is part of jellything (https://codeberg.org/metamuffin/jellything) + which is licensed under the GNU Affero General Public License (version 3); see /COPYING. + Copyright (C) 2026 metamuffin <metamuffin.org> +*/ + +use jellyui_locale::tr; + +use crate::RenderInfo; + +markup::define! { + AccountSetPassword<'a>(ri: &'a RenderInfo<'a>, session: &'a str) { + form.account[method="POST", action=""] { + h1 { @tr(ri.lang, "account.set_password") } + input[type="text", name="session", hidden, value=session]; br; + + label[for="inp-password"] { @tr(ri.lang, "account.password") } + input[type="password", id="inp-password", name="password"]; br; + + input[type="submit", value=tr(ri.lang, "account.register.submit")]; + + + } + } + AccountLogin<'a>(ri: &'a RenderInfo<'a>) { + form.account[method="POST", action=""] { + h1 { @tr(ri.lang, "account.login") } + + label[for="inp-username"] { @tr(ri.lang, "account.username") } + input[type="text", id="inp-username", name="username"]; br; + label[for="inp-password"] { @tr(ri.lang, "account.password") } + input[type="password", id="inp-password", name="password"]; br; + + input[type="submit", value=tr(ri.lang, if ri.user.is_some() { "account.login.submit.switch" } else { "account.login.submit" })]; + } + } + AccountLogout<'a>(ri: &'a RenderInfo<'a>) { + form.account[method="POST", action=""] { + h1 { @tr(ri.lang, "account.logout") } + input[type="submit", value=tr(ri.lang, "account.logout.submit")]; + } + } +} diff --git a/ui/src/components/mod.rs b/ui/src/components/mod.rs index 07b050b..792894e 100644 --- a/ui/src/components/mod.rs +++ b/ui/src/components/mod.rs @@ -4,6 +4,7 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ +pub mod login; pub mod message; pub mod node_page; pub mod props; @@ -11,7 +12,11 @@ pub mod stats; use crate::{ RenderInfo, - components::{message::Message, node_page::NodePage}, + components::{ + login::{AccountLogin, AccountLogout, AccountSetPassword}, + message::Message, + node_page::NodePage, + }, }; use jellycommon::{jellyobject::Object, *}; use markup::define; @@ -24,5 +29,14 @@ define! { @if let Some(nku) = view.get(VIEW_NODE_PAGE) { @NodePage { ri, nku } } + @if let Some(()) = view.get(VIEW_ACCOUNT_LOGIN) { + @AccountLogin { ri } + } + @if let Some(()) = view.get(VIEW_ACCOUNT_LOGOUT) { + @AccountLogout{ ri } + } + @if let Some(session) = view.get(VIEW_ACCOUNT_SET_PASSWORD) { + @AccountSetPassword { ri, session } + } } } diff --git a/ui/src/old/account/mod.rs b/ui/src/old/account/mod.rs deleted file mode 100644 index e7da26f..0000000 --- a/ui/src/old/account/mod.rs +++ /dev/null @@ -1,103 +0,0 @@ -/* - This file is part of jellything (https://codeberg.org/metamuffin/jellything) - which is licensed under the GNU Affero General Public License (version 3); see /COPYING. - Copyright (C) 2026 metamuffin <metamuffin.org> -*/ -pub mod settings; - -use crate::{Page, locale::tr, scaffold::RenderInfo}; -use jellycommon::routes::{u_account_login, u_account_register}; - -impl Page for AccountLogin<'_> { - fn title(&self) -> String { - tr( - self.ri.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.ri.lang, "account.register").to_string() - } - fn to_render(&self) -> markup::DynRender<'_> { - markup::new!(@self) - } -} -impl Page for AccountRegisterSuccess<'_> { - fn title(&self) -> String { - tr(self.ri.lang, "account.register").to_string() - } - fn to_render(&self) -> markup::DynRender<'_> { - markup::new!(@self) - } -} -impl Page for AccountLogout<'_> { - fn title(&self) -> String { - tr(self.ri.lang, "account.logout").to_string() - } - fn to_render(&self) -> markup::DynRender<'_> { - markup::new!(@self) - } -} - -markup::define! { - AccountRegister<'a>(ri: &'a RenderInfo<'a>) { - form.account[method="POST", action=""] { - h1 { @tr(ri.lang, "account.register") } - - label[for="inp-invitation"] { @tr(ri.lang, "account.register.invitation") } - input[type="text", id="inp-invitation", name="invitation"]; br; - - label[for="inp-username"] { @tr(ri.lang, "account.username") } - input[type="text", id="inp-username", name="username"]; br; - label[for="inp-password"] { @tr(ri.lang, "account.password") } - input[type="password", id="inp-password", name="password"]; br; - - input[type="submit", value=tr(ri.lang, "account.register.submit")]; - - p { @tr(ri.lang, "account.register.login") " " a[href=u_account_login()] { @tr(ri.lang, "account.register.login_here") } } - } - } - AccountRegisterSuccess<'a>(ri: &'a RenderInfo<'a>, logged_in: bool) { - h1 { @tr(ri.lang, if *logged_in { - "account.register.success.switch" - } else { - "account.register.success" - })} - } - AccountLogin<'a>(ri: &'a RenderInfo<'a>, logged_in: bool) { - form.account[method="POST", action=""] { - h1 { @self.title() } - - label[for="inp-username"] { @tr(ri.lang, "account.username") } - input[type="text", id="inp-username", name="username"]; br; - label[for="inp-password"] { @tr(ri.lang, "account.password") } - input[type="password", id="inp-password", name="password"]; br; - - input[type="submit", value=tr(ri.lang, if *logged_in { "account.login.submit.switch" } else { "account.login.submit" })]; - - @if *logged_in { - p { @tr(ri.lang, "account.login.register.switch") " " a[href=u_account_register()] { @tr(ri.lang, "account.login.register_here") } } - } else { - p { @tr(ri.lang, "account.login.cookie_note") } - p { @tr(ri.lang, "account.login.register") " " a[href=u_account_register()] { @tr(ri.lang, "account.login.register_here") } } - } - } - } - AccountLogout<'a>(ri: &'a RenderInfo<'a>) { - form.account[method="POST", action=""] { - h1 { @tr(ri.lang, "account.logout") } - input[type="submit", value=tr(ri.lang, "account.logout.submit")]; - } - } -} |