cleanup
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending
ci/woodpecker/pr/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-09 17:01:30 +02:00
parent ea5ce83658
commit c42238a624
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -89,8 +89,10 @@ pub fn get_config(file_path: &str) -> Config {
let internal_config = get_file_config(file_path); let internal_config = get_file_config(file_path);
let static_dir = "static".to_string(); 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 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 { Config {
fc: internal_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 { fn init(dist_dir: String, 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);
// The static folder is minimized only in release mode // The static folder is minimized only in release mode
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
// Be sure that we not gonna use the dist folder by deleting it // 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() ".".to_string()
} else { } else {
@ -118,7 +115,7 @@ fn init(static_dir: String, templates_dir: String) -> String {
let path = entry.unwrap(); let path = entry.unwrap();
let path_with_dist = path let path_with_dist = path
.to_string_lossy() .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); 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 = entry.unwrap();
let path_with_dist = path let path_with_dist = path
.to_string_lossy() .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); minify_and_copy(&cfg, path, path_with_dist);
} }
dist_folder dist_dir
} }
} }