From 9f341d439f7aa5fd2365024169ead2d6bdc3210c Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Sat, 14 Sep 2024 20:30:05 -0400 Subject: feat: rewrite complete --- src/handlers.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/handlers.rs (limited to 'src/handlers.rs') diff --git a/src/handlers.rs b/src/handlers.rs new file mode 100644 index 0000000..db5cf7c --- /dev/null +++ b/src/handlers.rs @@ -0,0 +1,34 @@ +use askama::Template; +use crate::views::posts::PostsView; +use crate::posts::abstractions::repo::PostRepo; +use crate::views::policies::PoliciesTemplate; +use crate::views::index::IndexTemplate; +use crate::views::brochure::BrochureTemplate; +use crate::views::about::AboutView; +use crate::tutors::abstractions::tutor_repo::TutorRepo; +use std::sync::Arc; +use axum::response::Html; +use axum::extract::State; + +pub async fn about_handler(State(repo): State>) -> Html { + let view = AboutView::with_tutors(repo.load()); + Html(view.render().unwrap()) +} + +pub async fn brochure_handler() -> Html { + Html(BrochureTemplate{}.render().unwrap()) +} + +pub async fn index_handler() -> Html { + Html(IndexTemplate {}.render().unwrap()) +} + +pub async fn policies_handler() -> Html { + Html(PoliciesTemplate{}.render().unwrap()) +} + +pub async fn posts_handler(State(repo): State>) -> Html { + let view = PostsView::with_posts(repo.load()); + Html(view.render().unwrap()) +} + -- cgit v1.2.3 From 18339f611fd17e1300593edd65adf7604a39ad72 Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Sat, 14 Sep 2024 20:54:44 -0400 Subject: feat: working rudimentary blog presentation --- src/handlers.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/handlers.rs') diff --git a/src/handlers.rs b/src/handlers.rs index db5cf7c..800d8f8 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -1,4 +1,5 @@ use askama::Template; +use crate::views::post::PostView; use crate::views::posts::PostsView; use crate::posts::abstractions::repo::PostRepo; use crate::views::policies::PoliciesTemplate; @@ -8,7 +9,7 @@ use crate::views::about::AboutView; use crate::tutors::abstractions::tutor_repo::TutorRepo; use std::sync::Arc; use axum::response::Html; -use axum::extract::State; +use axum::extract::{State, Path}; pub async fn about_handler(State(repo): State>) -> Html { let view = AboutView::with_tutors(repo.load()); @@ -32,3 +33,8 @@ pub async fn posts_handler(State(repo): State>) -> Html, State(repo): State>) -> Html { + let view = PostView::with_post(repo.by_id(&post_id)); + Html(view.render().unwrap()) +} + -- cgit v1.2.3