From c42238a624781e7cae271d53f74c523f473470fb Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 9 Apr 2023 17:01:30 +0200 Subject: [PATCH] cleanup --- src/config.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4427086..aa85c47 100644 --- a/src/config.rs +++ b/src/config.rs @@ -89,8 +89,10 @@ pub fn get_config(file_path: &str) -> Config { let internal_config = get_file_config(file_path); let static_dir = "static".to_string(); + // TODO: Check if templates dir is coherent with the whole list let templates_dir = get_askama_config().general.dirs.last().unwrap().to_string(); - let files_root = init(static_dir.clone(), templates_dir); + // TODO: Check dist by askama config file + let files_root = init("dist".to_string(), static_dir.clone(), templates_dir); Config { fc: internal_config, @@ -98,16 +100,11 @@ pub fn get_config(file_path: &str) -> Config { } } -fn init(static_dir: String, templates_dir: String) -> String { - let dist_folder = "dist".to_string(); - - // println!("static = {}/{}", dist_folder, static_dir); - // println!("templates = {}/{}", dist_folder, templates_dir); - +fn init(dist_dir: String, static_dir: String, templates_dir: String) -> String { // The static folder is minimized only in release mode if cfg!(debug_assertions) { // Be sure that we not gonna use the dist folder by deleting it - remove_dir_all(dist_folder).unwrap_or_default(); + remove_dir_all(dist_dir).unwrap_or_default(); ".".to_string() } else { @@ -118,7 +115,7 @@ fn init(static_dir: String, templates_dir: String) -> String { let path = entry.unwrap(); let path_with_dist = path .to_string_lossy() - .replace(&static_dir, &format!("{dist_folder}/{static_dir}")); + .replace(&static_dir, &format!("{dist_dir}/{static_dir}")); minify_and_copy(&cfg, path, path_with_dist); } @@ -128,12 +125,12 @@ fn init(static_dir: String, templates_dir: String) -> String { let path = entry.unwrap(); let path_with_dist = path .to_string_lossy() - .replace(&templates_dir, &format!("{dist_folder}/{templates_dir}")); + .replace(&templates_dir, &format!("{dist_dir}/{templates_dir}")); minify_and_copy(&cfg, path, path_with_dist); } - dist_folder + dist_dir } }