aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/routes/ui/account/admin.rs4
-rw-r--r--server/src/routes/ui/account/mod.rs4
-rw-r--r--server/src/routes/ui/account/settings.rs1
-rw-r--r--server/src/routes/ui/error.rs2
-rw-r--r--server/src/routes/ui/home.rs2
-rw-r--r--server/src/routes/ui/layout.rs18
-rw-r--r--server/src/routes/ui/node.rs1
-rw-r--r--server/src/routes/ui/player.rs2
8 files changed, 31 insertions, 3 deletions
diff --git a/server/src/routes/ui/account/admin.rs b/server/src/routes/ui/account/admin.rs
index 9d0a674..d7e5a36 100644
--- a/server/src/routes/ui/account/admin.rs
+++ b/server/src/routes/ui/account/admin.rs
@@ -55,6 +55,7 @@ pub fn r_account_admin_dashboard(
}}
}}
},
+ ..Default::default()
})
}
@@ -75,6 +76,7 @@ pub fn r_account_admin_invite(
content: markup::new! {
pre { code { @i } }
},
+ ..Default::default()
})
}
@@ -103,6 +105,7 @@ pub fn r_account_admin_remove_user(
p { "User removed" }
a[href=uri!(r_account_admin_dashboard())] {"Back"}
},
+ ..Default::default()
})
}
@@ -131,5 +134,6 @@ pub fn r_account_admin_remove_invite(
p { "Invite invalidated" }
a[href=uri!(r_account_admin_dashboard())] {"Back"}
},
+ ..Default::default()
})
}
diff --git a/server/src/routes/ui/account/mod.rs b/server/src/routes/ui/account/mod.rs
index 8e6d054..d4afb06 100644
--- a/server/src/routes/ui/account/mod.rs
+++ b/server/src/routes/ui/account/mod.rs
@@ -55,6 +55,7 @@ pub async fn r_account_register() -> DynLayoutPage<'static> {
input[type="submit", value="Register now!"];
}
},
+ ..Default::default()
}
}
@@ -84,6 +85,7 @@ pub fn r_account_login() -> DynLayoutPage<'static> {
p { "While logged in, a cookie will be used to identify you." }
}
},
+ ..Default::default()
}
}
@@ -97,6 +99,7 @@ pub fn r_account_logout() -> DynLayoutPage<'static> {
input[type="submit", value="Log out."];
}
},
+ ..Default::default()
}
}
@@ -132,6 +135,7 @@ pub fn r_account_register_post<'a>(
content: markup::new! {
h1 { "Registration successful, you may log in now." }
},
+ ..Default::default()
}),
Err(_) => Err(MyError(anyhow!("username is taken"))),
}
diff --git a/server/src/routes/ui/account/settings.rs b/server/src/routes/ui/account/settings.rs
index c95c4bb..d44aef4 100644
--- a/server/src/routes/ui/account/settings.rs
+++ b/server/src/routes/ui/account/settings.rs
@@ -58,6 +58,7 @@ fn settings_page(session: Session, flash: Option<MyResult<String>>) -> DynLayout
h2 { "Appearance" }
p.error { "TODO: theming" }
},
+ ..Default::default()
}
}
diff --git a/server/src/routes/ui/error.rs b/server/src/routes/ui/error.rs
index 7913e1a..88573a6 100644
--- a/server/src/routes/ui/error.rs
+++ b/server/src/routes/ui/error.rs
@@ -24,6 +24,7 @@ pub fn r_catch<'a>(status: Status, _request: &Request) -> DynLayoutPage<'a> {
p { "You might need to " a[href=uri!(r_account_login())] { "log in" } ", to see this page" }
}
},
+ ..Default::default()
}
}
@@ -40,6 +41,7 @@ impl<'r> Responder<'r, 'static> for MyError {
h2 { "An error occured. Nobody is sorry"}
pre.error { @format!("{:?}", self.0) }
},
+ ..Default::default()
}
.respond_to(req)
}
diff --git a/server/src/routes/ui/home.rs b/server/src/routes/ui/home.rs
index f81e04f..dde2369 100644
--- a/server/src/routes/ui/home.rs
+++ b/server/src/routes/ui/home.rs
@@ -20,6 +20,7 @@ pub fn r_home(_sess: Session, library: &State<Library>) -> DynLayoutPage {
p { "Welcome to " @CONF.brand }
@NodePage { node: library.root.clone() }
},
+ ..Default::default()
}
}
@@ -31,5 +32,6 @@ pub async fn r_home_unpriv() -> MyResult<DynLayoutPage<'static>> {
content: markup::new! {
@markup::raw(&front)
},
+ ..Default::default()
})
}
diff --git a/server/src/routes/ui/layout.rs b/server/src/routes/ui/layout.rs
index bc01c2e..746b534 100644
--- a/server/src/routes/ui/layout.rs
+++ b/server/src/routes/ui/layout.rs
@@ -12,7 +12,7 @@ use crate::{
uri, CONF,
};
use async_std::task::block_on;
-use markup::Render;
+use markup::{DynRender, Render};
use rocket::{
http::ContentType,
response::{self, Responder},
@@ -21,7 +21,7 @@ use rocket::{
use std::io::Cursor;
markup::define! {
- Layout<Main: Render>(title: String, main: Main, session: Option<Session>) {
+ Layout<'a, Main: Render>(title: String, main: Main, class: Option<&'a str>, session: Option<Session>) {
@markup::doctype()
html {
head {
@@ -29,7 +29,7 @@ markup::define! {
link[rel="stylesheet", href="/assets/style.css"];
script[src="/assets/bundle.js"] {}
}
- body {
+ body[class=class.unwrap_or("")] {
nav {
h1 { a[href="/"] { @CONF.brand } }
@if let Some(_) = session {
@@ -63,9 +63,20 @@ pub type DynLayoutPage<'a> = LayoutPage<markup::DynRender<'a>>;
pub struct LayoutPage<T> {
pub title: String,
+ pub class: Option<&'static str>,
pub content: T,
}
+impl Default for LayoutPage<DynRender<'_>> {
+ fn default() -> Self {
+ Self {
+ class: None,
+ content: markup::new!(),
+ title: String::new(),
+ }
+ }
+}
+
impl<'r, Main: Render> Responder<'r, 'static> for LayoutPage<Main> {
fn respond_to(self, req: &'r Request<'_>) -> response::Result<'static> {
// TODO blocking the event loop here. it seems like there is no other way to
@@ -76,6 +87,7 @@ impl<'r, Main: Render> Responder<'r, 'static> for LayoutPage<Main> {
Layout {
main: self.content,
title: self.title,
+ class: self.class.as_deref(),
session,
}
.render(&mut out)
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs
index ad44410..fc57eea 100644
--- a/server/src/routes/ui/node.rs
+++ b/server/src/routes/ui/node.rs
@@ -32,6 +32,7 @@ pub async fn r_library_node(
content: markup::new! {
@NodePage { node: node.clone() }
},
+ ..Default::default()
})
}
diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs
index ca3ce14..050a164 100644
--- a/server/src/routes/ui/player.rs
+++ b/server/src/routes/ui/player.rs
@@ -51,6 +51,7 @@ pub fn r_player(
Ok(LayoutPage {
title: item.info.title.to_owned(),
+ class: Some("player"),
content: markup::new! {
video[src=stream_uri(&item.lib_path, &tracks, true), controls];
},
@@ -109,5 +110,6 @@ pub fn player_conf<'a>(item: Arc<Item>) -> MyResult<DynLayoutPage<'a>> {
input[type="submit", value="Start playback"];
}
},
+ ..Default::default()
})
}