summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorWriterV2 <primary-v2@protonmail.com>2026-05-11 00:16:43 +0200
committerWriterV2 <primary-v2@protonmail.com>2026-05-11 00:16:43 +0200
commitfa0f57d719dee5f3a34a03f660e9db0084e03f74 (patch)
treea92e212ecd1e705b2f241b3632583d660530c55f /src/main.rs
parent5a819e715b6ae9e81417b38c7147bd7cd0999350 (diff)
Add home page
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs84
1 files changed, 81 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 7ad56c2..5882335 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,12 +12,89 @@ struct Data {
stories: Vec<Story>,
}
+impl page::Page for Data {
+ fn page_title() -> String {
+ String::from("Home")
+ }
+
+ fn alternative_htmlfilename() -> Option<String> {
+ 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" {
+ h2 { "Latest Story" }
+ h3 {
+ (story.name)
+ }
+ p { (story.description) }
+ ul {
+ 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;
+ * {
+ margin: 1rem 0;
+ }
+
+ p {
+ font-size: 1.2rem;
+ }
+ }
+
+ a {
+ text-decoration: underline;
+ color: #3D1D49;
+ }
+
+ ul {
+ list-style: none;
+ }
+
+ """
+ )
+ }
+}
+
impl page::Page for Vec<Story> {
fn page_title() -> String {
String::from("Stories")
}
- fn render_content(self) -> Markup {
+ fn render_content(&self) -> Markup {
html!(
@for story in self {
(story.render_as_card())
@@ -111,7 +188,7 @@ struct Story {
}
impl Story {
- fn render_as_card(self) -> Markup {
+ fn render_as_card(&self) -> Markup {
html!(div class="story-card" {
card {
h2 { (self.name) }
@@ -147,7 +224,8 @@ impl Story {
fn main() -> Result<()> {
let data_file_content =
std::fs::read_to_string("data.toml").with_context(|| "Failed to read data.toml")?;
- let data: Data = toml::from_str(&data_file_content)?;
+ let mut data: Data = toml::from_str(&data_file_content)?;
data.stories.write_page()?;
+ data.write_page()?;
Ok(())
}