aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/mod.rs')
-rw-r--r--src/utils/mod.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index a1ece8b..2e79934 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -1,4 +1,5 @@
use diesel::pg::PgConnection;
+use std::fmt::Display;
use r2d2;
use r2d2_diesel::ConnectionManager;
@@ -44,6 +45,13 @@ impl Deref for DbConn {
}
}
+#[derive(BartDisplay, Serialize)]
+#[template = "templates/layout.html"]
+pub struct Page<T: Display> {
+ pub title: String,
+ pub content: T
+}
+
macro_rules! implement_responder_for {
// Implement a responder for the given template type
//
@@ -52,7 +60,7 @@ macro_rules! implement_responder_for {
// So it will have to be passed in to the argument at
// the macro incovation instead.
($template_type:ty) => (
- impl<'a> ::rocket::response::Responder<'a> for $template_type {
+ impl<'a> ::rocket::response::Responder<'a> for ::utils::Page<$template_type> {
fn respond_to(self, _: &::rocket::Request) -> Result<::rocket::Response<'static>, ::rocket::http::Status> {
::rocket::Response::build()
.header(::rocket::http::ContentType::HTML)