aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-01-30 16:16:05 +0000
committerLibravatar cel 🌸 <cel@blos.sm>2024-01-30 16:16:05 +0000
commitf00159f53b3774601500ec65345791311ff6efa1 (patch)
treecc65a487e71a056126e1935108a494c7851863f9 /src/templates.rs
parent8c03d9a53f4bc2f70fb5c1e0487bc74fe0137fcb (diff)
downloadblossom-f00159f53b3774601500ec65345791311ff6efa1.tar.gz
blossom-f00159f53b3774601500ec65345791311ff6efa1.tar.bz2
blossom-f00159f53b3774601500ec65345791311ff6efa1.zip
migrate to poem and askama
Diffstat (limited to 'src/templates.rs')
-rw-r--r--src/templates.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/templates.rs b/src/templates.rs
new file mode 100644
index 0000000..861930f
--- /dev/null
+++ b/src/templates.rs
@@ -0,0 +1,55 @@
+use std::collections::HashSet;
+
+use askama::Template;
+use poem::http::StatusCode;
+use rand::{thread_rng, Rng};
+
+use crate::posts::Post;
+use crate::{blog, scrobbles::NowPlayingData};
+
+mod filters {
+ pub fn mytruncate(s: impl std::fmt::Display, length: usize) -> ::askama::Result<String> {
+ let mut s = s.to_string();
+ s.truncate(length);
+ Ok(s)
+ }
+}
+
+#[derive(Template)]
+#[template(path = "base.html")]
+struct Base;
+
+#[derive(Template)]
+#[template(path = "home.html")]
+pub struct Home {
+ pub is_live: bool,
+ pub listenbrainz: NowPlayingData,
+ pub blogposts: Vec<blog::Blogpost>,
+}
+
+#[derive(Template)]
+#[template(path = "blogpost.html")]
+pub struct Blogpost {
+ pub blogpost: blog::Blogpost,
+ pub filter_tags: HashSet<String>,
+}
+
+// filtertags, blogpost-panel
+#[derive(Template)]
+#[template(path = "blog.html")]
+pub struct Blog {
+ pub blogposts: Vec<blog::Blogpost>,
+ pub tags: Vec<String>,
+ pub filter_tags: HashSet<String>,
+}
+
+#[derive(Template)]
+#[template(path = "contact.html")]
+pub struct Contact;
+
+#[derive(Template)]
+#[template(path = "error.html")]
+pub struct Error {
+ pub status: StatusCode,
+ pub message: String,
+}