From a52e4b4ddebd15dbe323ab598e6e53eb8745841d Mon Sep 17 00:00:00 2001 From: Nick Pegg Date: Sun, 27 Apr 2025 10:20:27 -0700 Subject: [PATCH] Remove consts --- src/skel.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/skel.rs b/src/skel.rs index bb81ca6..e81010c 100644 --- a/src/skel.rs +++ b/src/skel.rs @@ -3,12 +3,6 @@ use std::io; use std::path::Path; use thiserror::Error; -const BASE_TMPL: &'static [u8; 653] = include_bytes!("../resources/skel/_templates/base.html"); -const ALBUM_TMPL: &'static [u8; 1682] = include_bytes!("../resources/skel/_templates/album.html"); -const PHOTO_TMPL: &'static [u8; 1333] = include_bytes!("../resources/skel/_templates/photo.html"); -const INDEX_CSS: &'static [u8; 1421] = include_bytes!("../resources/skel/static/index.css"); -const BASE_CONFIG: &'static [u8; 315] = include_bytes!("../resources/skel/photojawn.conf.yml"); - #[derive(Error, Debug)] pub enum InitError { #[error("Album directory already initialized - contains a photojawn.conf.yml")] @@ -24,17 +18,32 @@ pub fn make_skeleton(album_path: &Path) -> Result<(), InitError> { } fs::create_dir_all(album_path)?; - fs::write(cfg_path, BASE_CONFIG)?; + fs::write( + cfg_path, + include_bytes!("../resources/skel/photojawn.conf.yml"), + )?; let static_path = album_path.join("static"); fs::create_dir_all(&static_path)?; - fs::write(static_path.join("index.css"), INDEX_CSS)?; + fs::write( + static_path.join("index.css"), + include_bytes!("../resources/skel/static/index.css"), + )?; let tmpl_path = album_path.join("_templates"); fs::create_dir_all(tmpl_path)?; - fs::write(static_path.join("base.html"), BASE_TMPL)?; - fs::write(static_path.join("album.html"), ALBUM_TMPL)?; - fs::write(static_path.join("photo.html"), PHOTO_TMPL)?; + fs::write( + static_path.join("base.html"), + include_bytes!("../resources/skel/_templates/base.html"), + )?; + fs::write( + static_path.join("album.html"), + include_bytes!("../resources/skel/_templates/album.html"), + )?; + fs::write( + static_path.join("photo.html"), + include_bytes!("../resources/skel/_templates/photo.html"), + )?; Ok(()) }