diff options
| author | WriterV2 <primary-v2@protonmail.com> | 2023-06-03 15:05:57 +0200 |
|---|---|---|
| committer | WriterV2 <primary-v2@protonmail.com> | 2023-06-03 15:05:57 +0200 |
| commit | c8393e29b93a0d36b35134cfa12b9e4cbd41a62a (patch) | |
| tree | ab172809f862b9c18c4c16be6fea8e2b2d7897a6 /src/works/mod.rs | |
| parent | 3d1e4859f6a09208966407cefaae5ba6803ddc26 (diff) | |
Refactor standard library paths to mod tops + Add missing json extension to file path
Diffstat (limited to 'src/works/mod.rs')
| -rw-r--r-- | src/works/mod.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/works/mod.rs b/src/works/mod.rs index a588ae8..8cda299 100644 --- a/src/works/mod.rs +++ b/src/works/mod.rs @@ -1,4 +1,5 @@ -use std::fs::File; +use std::fs::{write, File}; +use std::io::BufReader; use std::path::PathBuf; use anyhow::{Context, Ok, Result}; @@ -11,8 +12,8 @@ pub trait Works: for<'a> Deserialize<'a> + Serialize { // create works from the corresponding JSON file, // e.g. stories from stories.json fn new_from_file(workname: &str) -> Result<Self> { - let work = serde_json::from_reader(std::io::BufReader::new( - &File::open(PathBuf::from(workname)) + let work = serde_json::from_reader(BufReader::new( + &File::open(PathBuf::from(format!("{}.json", workname))) .with_context(|| format!("Failed to open {}.json", workname))?, )) .with_context(|| format!("Failed to create works from {}.json", workname))?; @@ -37,7 +38,7 @@ pub trait Works: for<'a> Deserialize<'a> + Serialize { tera_instance: &tera::Tera, filename_without_extension: &str, ) -> Result<Self> { - std::fs::write( + write( format!("docs/{}.html", filename_without_extension).as_str(), tera_instance .render( |
