gallery index

This commit is contained in:
Cadey Ratio 2020-07-13 08:26:55 -04:00
parent cfd903dfd6
commit 8a2333a461
5 changed files with 50 additions and 2 deletions

13
src/handlers/gallery.rs Normal file
View File

@ -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<State>) -> Result<impl Reply, Rejection> {
let state = state.clone();
Response::builder().html(|o| templates::galleryindex_html(o, state.gallery.clone()))
}

View File

@ -35,6 +35,7 @@ pub async fn not_found() -> Result<impl Reply, Rejection> {
}
pub mod blog;
pub mod gallery;
#[derive(Debug, thiserror::Error)]
struct PostNotFound(String, String);

View File

@ -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"));

View File

@ -16,7 +16,7 @@ mod tests {
use anyhow::Result;
#[test]
fn load() -> Result<()> {
let people: Vec<super::Person> = serde_dhall::from_file("./signalboost.dhall").parse()?;
let _people: Vec<super::Person> = serde_dhall::from_file("./signalboost.dhall").parse()?;
Ok(())
}

View File

@ -0,0 +1,23 @@
@use crate::post::Post;
@use super::{header_html, footer_html};
@(posts: Vec<Post>)
@:header_html(Some("Gallery"), None)
<h1>Gallery</h1>
<p>Here are links to a lot of the art I have done in the last few years.</p>
<div class="grid">
@for post in posts {
<div class="card cell -4of12 blogpost-card">
<header class="card-header">@post.front_matter.title</header>
<div class="card-content">
<center><p>Posted on @post.date<br /><a href="@post.link"><img src="@post.front_matter.thumb.as_ref().unwrap()" /></a></p></center>
</div>
</div>
}
</div>
@:footer_html()