From 5760f597eb17eab5abe6a3ae6c905ad9e111dc46 Mon Sep 17 00:00:00 2001 From: WriterV2 Date: Mon, 11 May 2026 23:52:49 +0200 Subject: Refactor page and story --- src/data.rs | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/data.rs (limited to 'src/data.rs') diff --git a/src/data.rs b/src/data.rs new file mode 100644 index 0000000..2e5b3d1 --- /dev/null +++ b/src/data.rs @@ -0,0 +1,98 @@ +use crate::page; +use crate::story; +use maud::{html, Markup}; +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct Data { + pub stories: Vec, +} + +impl page::Page for Data { + fn page_title() -> String { + String::from("Home") + } + + fn alternative_htmlfilename() -> Option { + Some(String::from("index")) + } + + fn render_content(&self) -> Markup { + let last_story = self.stories.first(); + html!( + @if let Some(story) = last_story { + div class="latest-story" lang=(story.html_lang_value()) { + h2 lang="en" { "Latest Story" } + h3 { + (story.name) + } + @if let Some(content_warnings) = story.render_content_warnings() { + (content_warnings) + } + + p { (story.description) } + ul lang="en" { + li { "Language: " (story.language) } + li { + a href=(&story.format_pdf_path()) download + { + "PDF" + } + } + } + + } + } + ) + } + + fn content_style() -> Markup { + html!( + """ +h2 { + font-size: 2.5rem; + color: #2F3C57; + text-decoration: 0.1rem solid underline black; +} + +h3 { + font-size: 1.8rem; + color: #2F3C57; + padding: 2rem 0; +} + +.latest-story { + padding: 3rem; + margin: 3rem; + text-align: left; + background-color: #FFD1A3; + hyphens: auto; + * { + margin: 1rem 0; + } + + p { + font-size: 1.2rem; + } +} + +a { + text-decoration: underline; + color: #3D1D49; +} + +ul { + list-style: none; +} + +.content-warning { + background-color: #EC7981; + margin: 2rem 0; + padding: 0.3rem; + width: fit-content; +} + + """ + ) + } +} -- cgit v1.2.3