diff options
author | metamuffin <metamuffin@disroot.org> | 2023-10-24 15:08:15 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-10-24 15:08:15 +0200 |
commit | f4f3a16bca576c202887799066bd896863612e2b (patch) | |
tree | 8ddb9cdc47abae7bc615109f241b2cd12e141128 /server/src/routes | |
parent | c1afcdc0dc4e59cb2ce1e8c65b69c5647f2132f3 (diff) | |
download | jellything-f4f3a16bca576c202887799066bd896863612e2b.tar jellything-f4f3a16bca576c202887799066bd896863612e2b.tar.bz2 jellything-f4f3a16bca576c202887799066bd896863612e2b.tar.zst |
partial theme implementation
Diffstat (limited to 'server/src/routes')
-rw-r--r-- | server/src/routes/ui/account/mod.rs | 3 | ||||
-rw-r--r-- | server/src/routes/ui/account/session/token.rs | 1 | ||||
-rw-r--r-- | server/src/routes/ui/account/settings.rs | 6 | ||||
-rw-r--r-- | server/src/routes/ui/layout.rs | 18 | ||||
-rw-r--r-- | server/src/routes/ui/style.rs | 5 |
5 files changed, 26 insertions, 7 deletions
diff --git a/server/src/routes/ui/account/mod.rs b/server/src/routes/ui/account/mod.rs index a4aa2dd..88f6f45 100644 --- a/server/src/routes/ui/account/mod.rs +++ b/server/src/routes/ui/account/mod.rs @@ -16,7 +16,7 @@ use anyhow::anyhow; use argon2::{password_hash::Salt, Argon2, PasswordHasher}; use chrono::Duration; use jellybase::CONF; -use jellycommon::user::{PermissionSet, User}; +use jellycommon::user::{PermissionSet, Theme, User}; use rocket::{ form::{Contextual, Form}, get, @@ -132,6 +132,7 @@ pub fn r_account_register_post<'a>( name: form.username.clone(), password: hash_password(&form.username, &form.password), admin: false, + theme: Theme::Dark, permissions: PermissionSet::default(), }), ) diff --git a/server/src/routes/ui/account/session/token.rs b/server/src/routes/ui/account/session/token.rs index baec665..b6c22f7 100644 --- a/server/src/routes/ui/account/session/token.rs +++ b/server/src/routes/ui/account/session/token.rs @@ -79,6 +79,7 @@ fn test() { password: vec![], admin: false, permissions: jellycommon::user::PermissionSet::default(), + theme: jellycommon::user::Theme::Dark, }, Duration::days(1), ); diff --git a/server/src/routes/ui/account/settings.rs b/server/src/routes/ui/account/settings.rs index b02c871..d61d9f1 100644 --- a/server/src/routes/ui/account/settings.rs +++ b/server/src/routes/ui/account/settings.rs @@ -59,7 +59,11 @@ fn settings_page(session: Session, flash: Option<MyResult<String>>) -> DynLayout input[type="submit", value="Update"]; } h2 { "Appearance" } - p.error { "TODO: theming" } + fieldset { + legend { "Theme" } + // label { input[type="radio", name="theme", value=t, checked=session.user.theme==t]; @label } br; + // label { input[type="radio", name="theme", value=t, checked=session.user.theme==t]; @label } br; + } }, ..Default::default() } diff --git a/server/src/routes/ui/layout.rs b/server/src/routes/ui/layout.rs index cdac09c..c4d1275 100644 --- a/server/src/routes/ui/layout.rs +++ b/server/src/routes/ui/layout.rs @@ -18,6 +18,7 @@ use crate::{ }; use futures::executor::block_on; use jellybase::CONF; +use jellycommon::user::Theme; use markup::{DynRender, Render}; use rocket::{ http::ContentType, @@ -27,7 +28,7 @@ use rocket::{ use std::io::Cursor; markup::define! { - Layout<'a, Main: Render>(title: String, main: Main, class: Option<&'a str>, session: Option<Session>) { + Layout<'a, Main: Render>(title: String, main: Main, class: &'a str, session: Option<Session>) { @markup::doctype() html { head { @@ -35,7 +36,7 @@ markup::define! { link[rel="stylesheet", href="/assets/style.css"]; script[src="/assets/bundle.js"] {} } - body[class=class.unwrap_or("")] { + body[class=class] { nav { h1 { a[href="/"] { @CONF.brand } } " " @if let Some(_) = session { @@ -102,7 +103,18 @@ impl<'r, Main: Render> Responder<'r, 'static> for LayoutPage<Main> { Layout { main: self.content, title: self.title, - class: self.class.as_deref(), + class: &format!( + "{} {}", + self.class.as_deref().unwrap_or(""), + match session + .as_ref() + .map(|s| s.user.theme) + .unwrap_or(Theme::Dark) + { + Theme::Dark => "theme-dark", + Theme::Light => "theme-light", + } + ), session, } .render(&mut out) diff --git a/server/src/routes/ui/style.rs b/server/src/routes/ui/style.rs index bdaddd2..19283e1 100644 --- a/server/src/routes/ui/style.rs +++ b/server/src/routes/ui/style.rs @@ -35,14 +35,15 @@ macro_rules! concat_files { fn css_bundle() -> String { concat_files!( - ["../../../../web"], + ["../../../../web/style"], "layout.css", "player.css", "nodepage.css", "nodecard.css", "js-player.css", "js-transition.css", - "forms.css" + "forms.css", + "themes.css" ) } |