diff --git a/src/handlers/gallery.rs b/src/handlers/gallery.rs new file mode 100644 index 0000000..3172c40 --- /dev/null +++ b/src/handlers/gallery.rs @@ -0,0 +1,13 @@ +use super::{PostNotFound, SeriesNotFound}; +use crate::{ + app::State, + post::Post, + templates::{self, Html, RenderRucte}, +}; +use std::sync::Arc; +use warp::{http::Response, Rejection, Reply}; + +pub async fn index(state: Arc) -> Result { + let state = state.clone(); + Response::builder().html(|o| templates::galleryindex_html(o, state.gallery.clone())) +} diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index e9a89b5..eab42bd 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -35,6 +35,7 @@ pub async fn not_found() -> Result { } pub mod blog; +pub mod gallery; #[derive(Debug, thiserror::Error)] struct PostNotFound(String, String); diff --git a/src/main.rs b/src/main.rs index 5c1fcc9..55d104f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,6 +56,16 @@ async fn main() -> Result<()> { index.or(series.or(series_view)).or(post_view) }; + let gallery = { + let base = warp::path!("gallery" / ..); + let index = base + .and(warp::path::end()) + .and(with_state(state.clone())) + .and_then(handlers::gallery::index); + + index + }; + let static_pages = { let contact = warp::path!("contact").and_then(handlers::contact); let feeds = warp::path!("feeds").and_then(handlers::feeds); @@ -72,7 +82,8 @@ async fn main() -> Result<()> { let routes = warp::get() .and(path::end().and_then(handlers::index)) .or(static_pages) - .or(blog); + .or(blog) + .or(gallery); let files = { let files = warp::path("static").and(warp::fs::dir("./static")); diff --git a/src/signalboost.rs b/src/signalboost.rs index acd136a..079990b 100644 --- a/src/signalboost.rs +++ b/src/signalboost.rs @@ -16,7 +16,7 @@ mod tests { use anyhow::Result; #[test] fn load() -> Result<()> { - let people: Vec = serde_dhall::from_file("./signalboost.dhall").parse()?; + let _people: Vec = serde_dhall::from_file("./signalboost.dhall").parse()?; Ok(()) } diff --git a/templates/galleryindex.rs.html b/templates/galleryindex.rs.html new file mode 100644 index 0000000..a9f2f71 --- /dev/null +++ b/templates/galleryindex.rs.html @@ -0,0 +1,23 @@ +@use crate::post::Post; +@use super::{header_html, footer_html}; + +@(posts: Vec) + +@:header_html(Some("Gallery"), None) + +

Gallery

+ +

Here are links to a lot of the art I have done in the last few years.

+ +
+ @for post in posts { +
+
@post.front_matter.title
+
+

Posted on @post.date

+
+
+ } +
+ +@:footer_html()