diff options
Diffstat (limited to 'server/src/routes/ui/layout.rs')
-rw-r--r-- | server/src/routes/ui/layout.rs | 18 |
1 files changed, 15 insertions, 3 deletions
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) |