diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/works/stories.rs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/works/stories.rs b/src/works/stories.rs index ccc01e0..22ad1dc 100644 --- a/src/works/stories.rs +++ b/src/works/stories.rs @@ -31,13 +31,7 @@ impl super::Works for Stories { let mut context = tera::Context::new(); context.insert("story", story); result.push(std::fs::write( - format!( - // use story document name for the single page - // e.g. mit_gutem_gewissen.pdf -> mit_gutem_gewissen.html - "docs/stories/{}.html", - story.path_to_document.replace(".pdf", "") - ) - .as_str(), + story.get_html_path()?.as_str(), tera_instance.render(format!("{}.html", template_name).as_str(), &context)?, )); } @@ -45,6 +39,25 @@ impl super::Works for Stories { } } +impl Story { + // check if story document was modified + fn document_modified(&self) -> anyhow::Result<bool> { + Ok( + std::fs::metadata(format!("docs/stories/{}", &self.path_to_document))?.modified()? + > std::fs::metadata(self.get_html_path()?)?.modified()?, + ) + } + + // use story document name for the single page + // e.g. mit_gutem_gewissen.pdf -> mit_gutem_gewissen.html + fn get_html_path(&self) -> anyhow::Result<String> { + Ok(format!( + "docs/stories/{}.html", + self.path_to_document.replace(".pdf", "") + )) + } +} + // language of story content #[derive(Deserialize, Serialize, Debug)] pub enum Language { |
