From bc3e25f8c1edbd233ed0c266c574892e88644d9c Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Wed, 15 Jan 2025 15:54:27 +1300 Subject: 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. --- src/generate_html.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/generate_html.rs') 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!("

{paragraph}

") } html!(""); }, + "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!(""); + }), _ => { html!("
", language);
                         html!("{}", sanitize_text(content));
-- 
cgit v1.2.3-70-g09d2