Skip to main content

max / makenotwork

1.9 KB · 66 lines History Blame Raw
1 //! Askama templates for the public embed widgets (`/embed/*`). Ported from
2 //! hand-rolled `format!` HTML so user-derived fields (titles, creator names,
3 //! descriptions, URLs) are autoescaped by Askama rather than per-field by hand.
4
5 use askama::Template;
6
7 #[derive(Template)]
8 #[template(path = "embed/item_button.html")]
9 pub struct EmbedItemButtonTemplate {
10 pub title: String,
11 pub price_display: String,
12 pub purchase_url: String,
13 pub button_text: String,
14 pub cover_image_url: Option<String>,
15 }
16
17 #[derive(Template)]
18 #[template(path = "embed/item_card.html")]
19 pub struct EmbedItemCardTemplate {
20 pub title: String,
21 pub price_display: String,
22 pub purchase_url: String,
23 pub button_text: String,
24 pub cover_image_url: Option<String>,
25 pub creator_display_name: String,
26 pub profile_url: String,
27 /// Empty string = no description block.
28 pub description_excerpt: String,
29 pub is_horizontal: bool,
30 }
31
32 #[derive(Template)]
33 #[template(path = "embed/item_player.html")]
34 pub struct EmbedItemPlayerTemplate {
35 pub title: String,
36 pub price_display: String,
37 pub purchase_url: String,
38 pub button_text: String,
39 pub creator_display_name: String,
40 pub cover_image_url: Option<String>,
41 pub preview_url: String,
42 }
43
44 #[derive(Template)]
45 #[template(path = "embed/tip_button.html")]
46 pub struct EmbedTipButtonTemplate {
47 pub display_name: String,
48 pub username: String,
49 pub tip_url: String,
50 pub avatar_url: Option<String>,
51 }
52
53 #[derive(Template)]
54 #[template(path = "embed/project_card.html")]
55 pub struct EmbedProjectCardTemplate {
56 pub title: String,
57 pub creator_display_name: String,
58 pub profile_url: String,
59 pub project_url: String,
60 pub cover_image_url: Option<String>,
61 /// Empty string = no description block.
62 pub description_excerpt: String,
63 pub item_count: usize,
64 pub category_label: String,
65 }
66