aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main.rs9
-rw-r--r--src/poetry.rs1
-rw-r--r--src/templates.rs1
3 files changed, 9 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 1c5126a..60c501f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,6 +25,7 @@ use poem::{
EndpointExt, Route, Server,
};
use poem::{IntoResponse, Response};
+use rand::seq::SliceRandom;
use rust_embed::RustEmbed;
use error::BlossomError;
@@ -45,19 +46,23 @@ struct Static;
#[handler]
async fn home(Data(reqwest): Data<&reqwest::Client>) -> templates::Home {
let listenbrainz_client = listenbrainz::raw::Client::new();
- let (live, listenbrainz, blogposts) = tokio::join!(
+ let (live, listenbrainz, blogposts, poems) = tokio::join!(
live::get_live_status(reqwest),
scrobbles::get_now_playing(&listenbrainz_client),
// skweets::get_recents(&clients.skinnyverse),
- Blogpost::get_articles()
+ Blogpost::get_articles(),
+ Poem::get_articles()
);
let is_live = live.unwrap_or_default().online;
let listenbrainz = listenbrainz.unwrap_or_default();
let blogposts = blogposts.unwrap_or_default();
+ let poems = poems.unwrap_or_default();
+ let poem = poems.choose(&mut rand::thread_rng()).cloned();
templates::Home {
is_live,
listenbrainz,
blogposts,
+ poem,
}
}
diff --git a/src/poetry.rs b/src/poetry.rs
index ef168e8..68fa2ef 100644
--- a/src/poetry.rs
+++ b/src/poetry.rs
@@ -6,6 +6,7 @@ use crate::{article::Article, posts::Post};
static DIRECTORY: &str = "./poetry";
+#[derive(Clone)]
pub struct Poem {
pub file_name: String,
pub title: Option<String>,
diff --git a/src/templates.rs b/src/templates.rs
index 8eafd98..4bcb64b 100644
--- a/src/templates.rs
+++ b/src/templates.rs
@@ -26,6 +26,7 @@ pub struct Home {
pub is_live: bool,
pub listenbrainz: NowPlayingData,
pub blogposts: Vec<blog::Blogpost>,
+ pub poem: Option<poetry::Poem>,
}
#[derive(Template)]