1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
use std::collections::HashSet;
use askama::Template;
use poem::http::StatusCode;
use poem::i18n::Locale;
use rand::{thread_rng, Rng};
use crate::poetry;
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 = "home.html")]
pub struct Home {
pub title: String,
pub is_live: bool,
pub listenbrainz: NowPlayingData,
pub blogposts: Vec<blog::Blogpost>,
pub poem: Option<poetry::Poem>,
pub locale: Locale,
}
#[derive(Template)]
#[template(path = "blogpost.html")]
pub struct Blogpost {
pub title: String,
pub blogpost: blog::Blogpost,
pub filter_tags: HashSet<String>,
pub locale: Locale,
}
// filtertags, blogpost-panel
#[derive(Template)]
#[template(path = "blog.html")]
pub struct Blog {
pub title: String,
pub blogposts: Vec<blog::Blogpost>,
pub tags: Vec<String>,
pub filter_tags: HashSet<String>,
pub locale: Locale,
}
#[derive(Template)]
#[template(path = "poem.html")]
pub struct Poem {
pub title: String,
pub poem: poetry::Poem,
pub jiggle: isize,
pub locale: Locale,
}
#[derive(Template)]
#[template(path = "poetry.html")]
pub struct Poetry {
pub title: String,
pub poems: Vec<poetry::Poem>,
pub jiggle: isize,
pub locale: Locale,
}
#[derive(Template)]
#[template(path = "contact.html")]
pub struct Contact {
pub title: String,
pub locale: Locale,
}
#[derive(Template)]
#[template(path = "error.html")]
pub struct Error {
pub title: String,
pub status: StatusCode,
pub message: String,
// TODO: localize error page
}
|