aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.rs9
-rw-r--r--src/poetry.rs1
-rw-r--r--src/templates.rs1
-rw-r--r--static/style.css22
-rw-r--r--templates/home.html1
-rw-r--r--templates/random-poem.html11
6 files changed, 43 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)]
diff --git a/static/style.css b/static/style.css
index cef4a10..dfc3bc9 100644
--- a/static/style.css
+++ b/static/style.css
@@ -478,6 +478,28 @@ iframe {
text-decoration: underline;
}
+#random-poem {
+ background-color: #e8cdcf;
+}
+
+#random-poem h2 {
+ font-family: 'Louise';
+ margin-bottom: 0;
+}
+
+#random-poem h3 {
+ margin-top: 0;
+}
+
+#random-poem a {
+ font-family: 'Steps Mono';
+ padding: 0;
+ margin: 0;
+ background-color: transparent;
+ color: #b52f6a;
+ text-decoration: underline;
+}
+
/* filter-tags */
#filter-tags {
font-family: 'Go Mono';
diff --git a/templates/home.html b/templates/home.html
index 540abce..7bbed9e 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -46,6 +46,7 @@
<div class="panel" style="background-color: #b52f6a; z-index: -1; font-family: 'Terminal Grotesque'; font-size: 2em">
latest update: added poetry!</div>
{% include "latestposts.html" %}
+ {% include "random-poem.html" %}
</aside>
diff --git a/templates/random-poem.html b/templates/random-poem.html
new file mode 100644
index 0000000..bdfbaff
--- /dev/null
+++ b/templates/random-poem.html
@@ -0,0 +1,11 @@
+{% if let Some(poem) = poem %}
+<div class="panel" id="random-poem">
+ <h2>random poem</h2>
+ <a href="/poetry/{{ poem.file_name }}">
+ <h3>{% if let Some(title) = poem.title %}{{ title }}{% else %}permalink{% endif %}</h3>
+ </a>
+ <div class="poem-content">
+ {{ poem.content|safe }}
+ </div>
+</div>
+{% endif %} \ No newline at end of file