From f49105ef7f89487e370c8d9dc69ae3e1fa39cfc6 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Sat, 14 Oct 2023 23:32:49 -0400 Subject: [PATCH] Panic comments --- README.md | 4 ++-- data/links/links.yaml | 2 +- src/file_utils/mod.rs | 3 +++ src/links/mod.rs | 4 ++++ src/main.rs | 2 ++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e58e81a..9beabc4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Configuration ### example: `config.yaml` ```yaml -output_dir: public/ +output_dir: public links: source: data/links/links.yaml template: templates/links/links.html @@ -58,4 +58,4 @@ This is optional, but everything inside will be copied directly next to the `ind Debating on manually needing to specify a list of files in `config:` but not sold on that yet. -## Blog - Coming Soon \ No newline at end of file +## Blog - Coming Soon diff --git a/data/links/links.yaml b/data/links/links.yaml index d3306f1..77bf148 100644 --- a/data/links/links.yaml +++ b/data/links/links.yaml @@ -111,4 +111,4 @@ links: links: - text: Fork this project! icon: fa-solid fa-code-fork - href: https://gitea.tyrel.dev/tyrel/rustylinks + href: https://gitea.tyrel.dev/tyrel/rust-ssg diff --git a/src/file_utils/mod.rs b/src/file_utils/mod.rs index a5c0e34..79332e6 100644 --- a/src/file_utils/mod.rs +++ b/src/file_utils/mod.rs @@ -19,6 +19,9 @@ pub fn copy_recursively(source: impl AsRef, destination: impl AsRef) pub fn write_file(html: String) { // copy all files in static to public if Path::new("./public/links").exists() { + // TODO: Move me into links wtf am i in here for + // TODO: Handle Panic + // thread 'main' panicked at 'Could not copy static directory: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/file_utils/mod.rs:22:56 copy_recursively("./static", "./public/links").expect("Could not copy static directory"); } fs::write("./public/links/index.html", html).expect("Could not write to index.html"); diff --git a/src/links/mod.rs b/src/links/mod.rs index c6902f1..bfeffa5 100644 --- a/src/links/mod.rs +++ b/src/links/mod.rs @@ -8,6 +8,8 @@ use std::path::PathBuf; use crate::file_utils::{write_file, copy_recursively}; fn load_links(config: &LinksConfig) -> RustyLinks { + // TODO: Handle Panic + // thread 'main' panicked at 'Could not find data/links/links.yaml: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/links/mod.rs:11:58 let links_yaml = std::fs::File::open(&config.source).expect(&format!("Could not find {}", config.source)); let mut rusty_links: RustyLinks = serde_yaml::from_reader(links_yaml).expect("Could not read values"); @@ -21,6 +23,8 @@ fn load_links(config: &LinksConfig) -> RustyLinks { } fn render_links(rusty_links: RustyLinks, config: &LinksConfig) -> String { + // TODO: Handle Panic + // thread 'main' panicked at 'Could not find templates/links/links.html: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/links/mod.rs:24:58 let main = std::fs::read_to_string(&config.template).expect(&format!("Could not find {}", config.template)); let mut env = Environment::new(); diff --git a/src/main.rs b/src/main.rs index 16054b1..a3aae24 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,8 @@ fn main() { let blog_str = "blog"; // let blog_dir = PathBuf::from(blog_str); + // TODO: Handle Panic: + // thread 'main' panicked at 'Could not find config.yaml file: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:19:53 let config: Config = load_config("./config.yaml"); let output_dir = PathBuf::from(&config.output_dir);