use std::collections::HashSet; use askama::Template; use poem::http::StatusCode; use rand::{thread_rng, Rng}; use crate::poetry; use crate::posts::Post; use crate::{blog, scrobbles::NowPlayingData}; mod filters { pub fn mytruncate(s: impl std::fmt::Display, length: usize) -> ::askama::Result { let mut s = s.to_string(); s.truncate(length); Ok(s) } } #[derive(Template)] #[template(path = "base.html")] struct Base; #[derive(Template)] #[template(path = "home.html")] pub struct Home { pub is_live: bool, pub listenbrainz: NowPlayingData, pub blogposts: Vec, pub poem: Option, } #[derive(Template)] #[template(path = "blogpost.html")] pub struct Blogpost { pub blogpost: blog::Blogpost, pub filter_tags: HashSet, } // filtertags, blogpost-panel #[derive(Template)] #[template(path = "blog.html")] pub struct Blog { pub blogposts: Vec, pub tags: Vec, pub filter_tags: HashSet, } #[derive(Template)] #[template(path = "poem.html")] pub struct Poem { pub poem: poetry::Poem, pub jiggle: isize, } #[derive(Template)] #[template(path = "poetry.html")] pub struct Poetry { pub poems: Vec, pub jiggle: isize, } #[derive(Template)] #[template(path = "contact.html")] pub struct Contact; #[derive(Template)] #[template(path = "error.html")] pub struct Error { pub status: StatusCode, pub message: String, }