aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2026-01-01 22:11:02 +0100
committerLibravatar cel 🌸 <cel@bunny.garden>2026-01-01 22:16:58 +0100
commit324794a9e8d60c9e187dd8c24f9cae076e933142 (patch)
tree48cf25db9a79af578a338100d1ce44203f0db627
parent7c14130b61d806b42e7c0d1c8cf846b964caadff (diff)
downloadblossom-324794a9e8d60c9e187dd8c24f9cae076e933142.tar.gz
blossom-324794a9e8d60c9e187dd8c24f9cae076e933142.tar.bz2
blossom-324794a9e8d60c9e187dd8c24f9cae076e933142.zip
new home feed
-rw-r--r--TODO.md8
-rw-r--r--src/blog.rs12
-rw-r--r--src/main.rs38
-rw-r--r--src/templates.rs5
-rw-r--r--static/style.css12
-rw-r--r--templates/home.html13
-rw-r--r--templates/poetry.html2
7 files changed, 77 insertions, 13 deletions
diff --git a/TODO.md b/TODO.md
index 1e74629..c9c81af 100644
--- a/TODO.md
+++ b/TODO.md
@@ -4,13 +4,15 @@
[x] update contact
[x] about page
[x] capitalisation
-[ ] new badge(s)
-[ ] replace homepage with blog post feed
+[x] replace homepage with blog/poetry feed
[x] remove dead links (in navbar)
[x] remove latest update thing
+[ ] new badge(s)
+ [ ] update serving https badges better thumb LOL
[ ] fix atom feed stuff
[ ] migrate to ructe
[ ] opengraph
+[ ] publish new poetry
[x] make sure posts are organised in date order
[x] atom feed
[x] tags
@@ -25,7 +27,6 @@
[ ] projects page
[ ] more badges
[ ] harbor valorant
- [ ] update serving https badges better thumb LOL
[ ] fun stuff
[ ] links i like
[ ] badges i created
@@ -53,7 +54,6 @@ badges to steal:
badges to make:
[ ] f5ve badge
-[ ]
projects:
- this website
diff --git a/src/blog.rs b/src/blog.rs
index 9acb5e2..36204e7 100644
--- a/src/blog.rs
+++ b/src/blog.rs
@@ -17,12 +17,12 @@ static DIRECTORY: &str = "./blog";
#[derive(Clone)]
pub struct Blogpost {
- file_name: String,
- title: String,
- published_at: DateTime<Utc>,
- updated_at: Option<DateTime<Utc>>,
- tags: Vec<String>,
- content: String,
+ pub file_name: String,
+ pub title: String,
+ pub published_at: DateTime<Utc>,
+ pub updated_at: Option<DateTime<Utc>>,
+ pub tags: Vec<String>,
+ pub content: String,
}
#[derive(Deserialize)]
diff --git a/src/main.rs b/src/main.rs
index 0f14e3c..7247c33 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,6 +15,7 @@ mod utils;
use std::{collections::HashSet, time::Duration};
+use chrono::{DateTime, Utc};
use i18n::set_language;
use poem::http::StatusCode;
use poem::i18n::unic_langid::langid;
@@ -64,14 +65,51 @@ async fn home(Data(reqwest): Data<&reqwest::Client>, locale: Locale) -> template
let listenbrainz = listenbrainz.unwrap_or_default();
let blogposts = blogposts.unwrap_or_default();
let poems = poems.unwrap_or_default();
+
+ let mut posts = blogposts
+ .iter()
+ .take(10)
+ .map(Clone::clone)
+ .map(HomeFeedItem::Blogpost)
+ .chain(
+ poems
+ .iter()
+ .take(10)
+ .map(Clone::clone)
+ .map(HomeFeedItem::Poem),
+ )
+ .collect::<Vec<_>>();
+
+ posts.sort_by_key(|i| i.published_at());
+ posts.reverse();
+ posts.truncate(10);
+
let poem = poems.choose(&mut rand::thread_rng()).cloned();
+
templates::Home {
title: locale.text("title").unwrap(),
is_live,
listenbrainz,
+ feed: posts,
blogposts,
poem,
locale,
+ filter_tags: HashSet::new(),
+ jiggle: 8,
+ }
+}
+
+pub enum HomeFeedItem {
+ Blogpost(Blogpost),
+ Poem(Poem),
+}
+
+impl HomeFeedItem {
+ pub fn published_at(&self) -> DateTime<Utc> {
+ match self {
+ HomeFeedItem::Blogpost(post) => post.published_at,
+ HomeFeedItem::Poem(poem) => poem.published_at,
+ }
}
}
diff --git a/src/templates.rs b/src/templates.rs
index b4ea98d..c086487 100644
--- a/src/templates.rs
+++ b/src/templates.rs
@@ -5,9 +5,9 @@ use poem::http::StatusCode;
use rand::{thread_rng, Rng};
use crate::i18n::Locale;
-use crate::poetry;
use crate::posts::Post;
use crate::{blog, scrobbles::NowPlayingData};
+use crate::{poetry, HomeFeedItem};
mod filters {
pub fn mytruncate(s: impl std::fmt::Display, length: usize) -> ::askama::Result<String> {
@@ -23,9 +23,12 @@ pub struct Home {
pub title: String,
pub is_live: bool,
pub listenbrainz: NowPlayingData,
+ pub feed: Vec<HomeFeedItem>,
pub blogposts: Vec<blog::Blogpost>,
pub poem: Option<poetry::Poem>,
pub locale: Locale,
+ pub filter_tags: HashSet<String>,
+ pub jiggle: isize,
}
#[derive(Template)]
diff --git a/static/style.css b/static/style.css
index e3b083f..6205635 100644
--- a/static/style.css
+++ b/static/style.css
@@ -138,6 +138,18 @@ nav {
padding: 0;
}
+.home-feed-footer {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 4vw;
+}
+
+.home-feed-footer .panel {
+ background-color: #5faf87;
+ text-align: center;
+}
+
#suscakke {
margin: 0;
padding: 0;
diff --git a/templates/home.html b/templates/home.html
index d8efc3e..95e614c 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -28,7 +28,18 @@
{% block content %}
-<div class="panel content">
+{% for post in feed %}
+{% match post %}
+{% when HomeFeedItem::Blogpost(blogpost) %}
+{% include "blogpost-panel.html" %}
+{% when HomeFeedItem::Poem(poem) %}
+{% include "poem-panel.html" %}
+{% endmatch %}
+{% endfor %}
+
+<div class="home-feed-footer">
+ <div class="panel"><a href="/blog">More blogposts...</a></div>
+ <div class="panel"><a href="/poetry">More poetry...</a></div>
</div>
{% endblock content %}
diff --git a/templates/poetry.html b/templates/poetry.html
index 8c51cff..f12a5d9 100644
--- a/templates/poetry.html
+++ b/templates/poetry.html
@@ -10,4 +10,4 @@
{% endfor %}
</div>
-{% endblock content %} \ No newline at end of file
+{% endblock content %}