From b78d026c242e8d95e611e050afd5b72eb562d56d Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Wed, 31 Jan 2024 17:54:14 +0000 Subject: genericise articles --- src/main.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index de9b7ad..3d52f46 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,17 @@ +#![feature(path_file_prefix)] + +mod article; mod atom; mod blog; mod error; mod live; +mod poetry; mod posts; mod scrobbles; mod skweets; mod templates; mod utils; -use std::rc::Rc; use std::{collections::HashSet, time::Duration}; use poem::http::StatusCode; @@ -28,6 +31,9 @@ use error::BlossomError; use serde::Deserialize; use tracing_subscriber::FmtSubscriber; +use crate::article::Article; +use crate::blog::Blogpost; + type Result = std::result::Result; #[derive(RustEmbed)] @@ -41,7 +47,7 @@ async fn home(Data(reqwest): Data<&reqwest::Client>) -> templates::Home { live::get_live_status(reqwest), scrobbles::get_now_playing(&listenbrainz_client), // skweets::get_recents(&clients.skinnyverse), - blog::get_blogposts() + Blogpost::get_articles() ); let is_live = live.unwrap_or_default().online; let listenbrainz = listenbrainz.unwrap_or_default(); @@ -56,7 +62,7 @@ async fn home(Data(reqwest): Data<&reqwest::Client>) -> templates::Home { // #[get("/blog/")] #[handler] async fn blogpost(Path(blogpost): Path) -> Result { - let blogpost = blog::get_blogpost(&blogpost).await?; + let blogpost = Blogpost::get_article(&blogpost).await?; Ok(templates::Blogpost { blogpost, filter_tags: HashSet::new(), @@ -71,7 +77,7 @@ struct FilterTags { // #[get("/blog?")] #[handler] async fn get_blog(filter_tags: Option>) -> Result { - let mut blogposts = blog::get_blogposts().await?; + let mut blogposts = Blogpost::get_articles().await?; let tags: Vec = posts::Post::get_tags(&blogposts) .into_iter() .map(|tag| tag.to_owned()) @@ -90,7 +96,7 @@ async fn get_blog(filter_tags: Option>) -> Result Result { - let posts = blog::get_blogposts().await?; + let posts = Blogpost::get_articles().await?; // TODO: i18n let context = atom::Context { page_title: "celeste's hard drive".to_owned(), -- cgit