diff options
Diffstat (limited to 'server/src/routes/ui/mod.rs')
-rw-r--r-- | server/src/routes/ui/mod.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/server/src/routes/ui/mod.rs b/server/src/routes/ui/mod.rs new file mode 100644 index 0000000..aa0259d --- /dev/null +++ b/server/src/routes/ui/mod.rs @@ -0,0 +1,32 @@ +use self::layout::Layout; +use markup::Render; +use rocket::{ + http::ContentType, + response::{self, Responder}, + Request, Response, +}; +use std::io::Cursor; + +pub mod error; +pub mod home; +pub mod layout; +pub mod node; +pub mod style; + +pub struct HtmlTemplate<T>(pub String, pub T); + +impl<'r, T: Render> Responder<'r, 'static> for HtmlTemplate<T> { + fn respond_to(self, _: &'r Request<'_>) -> response::Result<'static> { + let mut out = String::new(); + Layout { + title: self.0, + main: self.1, + } + .render(&mut out) + .unwrap(); + Response::build() + .header(ContentType::HTML) + .streamed_body(Cursor::new(out)) + .ok() + } +} |