summaryrefslogtreecommitdiff
path: root/src/generate_html.rs
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2025-01-15 15:54:27 +1300
committerBen Bridle <ben@derelict.engineering>2025-01-15 16:22:59 +1300
commitbc3e25f8c1edbd233ed0c266c574892e88644d9c (patch)
tree5da6e11aa9738b11a55190950e8bb335cc30ad7f /src/generate_html.rs
parent01cd799f688ad39cfb03ede3e149512d1c8faef6 (diff)
downloadtoaster-bc3e25f8c1edbd233ed0c266c574892e88644d9c.zip
Implement image galleries
Each gallery image must be kept in the three directories images/large, images/small, and images/thumb. A gallery is a fragment with the language 'gallery' containing a list of image filenames, one per line.
Diffstat (limited to 'src/generate_html.rs')
-rw-r--r--src/generate_html.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/generate_html.rs b/src/generate_html.rs
index 3486352..0210986 100644
--- a/src/generate_html.rs
+++ b/src/generate_html.rs
@@ -188,6 +188,17 @@ pub fn document_to_html(document: &MarkdownDocument, page: &Page, website: &Webs
for paragraph in recipe.process { html!("<p>{paragraph}</p>") }
html!("</div>");
},
+ "gallery" => wrap!("div", "class='gallery'", for line in content.lines() {
+ let file = line.trim();
+ if !website.has_image(file) {
+ warn!("Gallery on page {:?} references nonexistent image {file:?}", page.name);
+ continue;
+ }
+ let large = format!("{root}images/large/{file}");
+ // let small = format!("{root}images/small/{file}");
+ let thumb = format!("{root}images/thumb/{file}");
+ html!("<a href='{large}'><img src='{thumb}'></a>");
+ }),
_ => {
html!("<pre class='{}'>", language);
html!("{}", sanitize_text(content));