diff options
Diffstat (limited to 'src/controllers/home_controller.rs')
-rw-r--r-- | src/controllers/home_controller.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/controllers/home_controller.rs b/src/controllers/home_controller.rs index d9a539a..2f657c3 100644 --- a/src/controllers/home_controller.rs +++ b/src/controllers/home_controller.rs @@ -2,11 +2,12 @@ use ::{models, utils}; use rocket; use rocket_contrib::Json; use std::path::PathBuf; +use posts_controller::ShowPostTemplate; #[derive(BartDisplay, Serialize)] #[template = "templates/index.html"] struct IndexTemplate { - posts: Vec<models::Post> + posts: Vec<ShowPostTemplate> } implement_responder_for!(IndexTemplate); @@ -17,7 +18,9 @@ fn index(flash: Option<rocket::request::FlashMessage>, conn: utils::DbConn) -> u title: String::from("Bloggen"), flash: flash.map_or(None, |f| Some(f.msg().to_string())), content: IndexTemplate { - posts: models::Post::get_all(conn) + posts: models::Post::get_all(conn).into_iter() + .map(|p| ShowPostTemplate { post: p }) + .collect() } } } |