diff options
author | curly <curlybryce@protonmail.com> | 2022-12-28 15:25:22 -0700 |
---|---|---|
committer | curly <curlybryce@protonmail.com> | 2022-12-28 15:25:22 -0700 |
commit | f31d940ed0b9b67b92212adcc01b44fc4d528f69 (patch) | |
tree | 89f238322de6b7fe2ac84a6bb80d49661196932d /src/main.rs | |
download | s3g-f31d940ed0b9b67b92212adcc01b44fc4d528f69.tar.gz s3g-f31d940ed0b9b67b92212adcc01b44fc4d528f69.tar.bz2 s3g-f31d940ed0b9b67b92212adcc01b44fc4d528f69.zip |
initial
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..a6f8e1f --- /dev/null +++ b/src/main.rs @@ -0,0 +1,72 @@ +use std::fs; + +fn main() { + + let config = match fs::read_to_string("settings.toml") { + Ok(n) => simple_static_site_generator::Config::import(&(n.as_str())), + Err(n) => {print!("\"settings.toml\": {}: ", n); simple_static_site_generator::Config::new()}, + }; + + println!("{}", config.get_str("source").unwrap()); + + let mut path_vec = vec![]; + let mut ex_path_vec = vec![]; + + let dirs = fs::read_dir("src").unwrap(); + for dir in dirs { + + let path = dir.as_ref().unwrap().path(); + if path != std::path::PathBuf::from("assets") { + path_vec.push(path); + } else { + ex_path_vec.push(path); + } + } + + println!("INCLUDED"); + for x in &path_vec { + println!("{:?}", x) + } + println!("EXCLUDED"); + for x in &ex_path_vec { + println!("{:?}", x) + } + println!(); + + + // create build directory or panic + simple_static_site_generator::create_dir("build").unwrap(); + + for path in path_vec { + let mut file_string = String::new(); + + if path.is_dir() { + // RECURSE HERE + continue + } + + for line in fs::read_to_string(&path).unwrap().lines() { + if line.contains(":?") { + let v: Vec<&str> = line.trim().split(":?").collect(); + let v = v.get(1).unwrap(); + + println!("INSERTING {} into {:?}", v, path); + + file_string.push_str(fs::read_to_string(v).unwrap().as_ref()); + } else { + file_string.push_str(line); + file_string.push('\n') + } + } + + + let dest = simple_static_site_generator::replace_path_head(&path, "build/"); + + // NEEDS TO CREATE DIRECTORY STRUCTURE + fs::write(dest, file_string).expect("Could not write file"); + + } + + + // NEEDS TO COPY NOT SCANNED DIRECTORIES +}
\ No newline at end of file |