aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-01-31 21:02:28 +0000
committerLibravatar cel 🌸 <cel@blos.sm>2024-01-31 21:02:28 +0000
commit2ac490aca1be78d5cb01eeeb9639c6d02ccf40e5 (patch)
tree04426c29d75d74b35e5e681acc0b58eda713ded3 /src/main.rs
parent7ccf135f287ccb6c12494275b2220aae63aa9126 (diff)
downloadblossom-2ac490aca1be78d5cb01eeeb9639c6d02ccf40e5.tar.gz
blossom-2ac490aca1be78d5cb01eeeb9639c6d02ccf40e5.tar.bz2
blossom-2ac490aca1be78d5cb01eeeb9639c6d02ccf40e5.zip
add poetry
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 4f8ec55..5ee3b2a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -33,6 +33,7 @@ use tracing_subscriber::FmtSubscriber;
use crate::article::Article;
use crate::blog::Blogpost;
+use crate::poetry::Poem;
use crate::posts::Post;
type Result<T> = std::result::Result<T, BlossomError>;
@@ -123,6 +124,20 @@ async fn plants() -> Result<()> {
Err(BlossomError::Unimplemented)
}
+#[handler]
+async fn get_poem(Path(poem): Path<String>) -> Result<templates::Poem> {
+ let poem = Poem::get_article(&poem).await?;
+ Ok(templates::Poem { poem, jiggle: 4 })
+}
+
+#[handler]
+async fn get_poetry() -> Result<templates::Poetry> {
+ let mut poems = Poem::get_articles().await?;
+ poems.sort_by_key(|poem| poem.created_at);
+ poems.reverse();
+ Ok(templates::Poetry { poems, jiggle: 16 })
+}
+
async fn custom_error(err: poem::Error) -> impl IntoResponse {
templates::Error {
status: err.status(),
@@ -143,6 +158,8 @@ async fn main() -> std::result::Result<(), std::io::Error> {
.at("/", get(home))
.at("/blog", get(get_blog))
.at("/blog/:blogpost", get(blogpost))
+ .at("/poetry", get(get_poetry))
+ .at("/poetry/:poem", get(get_poem))
.at("/feed", get(feed))
.at("/contact", get(contact))
.at("/plants", get(plants))