Panic comments
This commit is contained in:
parent
3ea0b6290d
commit
f49105ef7f
@ -10,7 +10,7 @@ Configuration
|
|||||||
|
|
||||||
### example: `config.yaml`
|
### example: `config.yaml`
|
||||||
```yaml
|
```yaml
|
||||||
output_dir: public/
|
output_dir: public
|
||||||
links:
|
links:
|
||||||
source: data/links/links.yaml
|
source: data/links/links.yaml
|
||||||
template: templates/links/links.html
|
template: templates/links/links.html
|
||||||
|
@ -111,4 +111,4 @@ links:
|
|||||||
links:
|
links:
|
||||||
- text: Fork this project!
|
- text: Fork this project!
|
||||||
icon: fa-solid fa-code-fork
|
icon: fa-solid fa-code-fork
|
||||||
href: https://gitea.tyrel.dev/tyrel/rustylinks
|
href: https://gitea.tyrel.dev/tyrel/rust-ssg
|
||||||
|
@ -19,6 +19,9 @@ pub fn copy_recursively(source: impl AsRef<Path>, destination: impl AsRef<Path>)
|
|||||||
pub fn write_file(html: String) {
|
pub fn write_file(html: String) {
|
||||||
// copy all files in static to public
|
// copy all files in static to public
|
||||||
if Path::new("./public/links").exists() {
|
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");
|
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");
|
fs::write("./public/links/index.html", html).expect("Could not write to index.html");
|
||||||
|
@ -8,6 +8,8 @@ use std::path::PathBuf;
|
|||||||
use crate::file_utils::{write_file, copy_recursively};
|
use crate::file_utils::{write_file, copy_recursively};
|
||||||
|
|
||||||
fn load_links(config: &LinksConfig) -> RustyLinks {
|
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 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");
|
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 {
|
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 main = std::fs::read_to_string(&config.template).expect(&format!("Could not find {}", config.template));
|
||||||
|
|
||||||
let mut env = Environment::new();
|
let mut env = Environment::new();
|
||||||
|
@ -44,6 +44,8 @@ fn main() {
|
|||||||
let blog_str = "blog";
|
let blog_str = "blog";
|
||||||
// let blog_dir = PathBuf::from(blog_str);
|
// 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 config: Config = load_config("./config.yaml");
|
||||||
let output_dir = PathBuf::from(&config.output_dir);
|
let output_dir = PathBuf::from(&config.output_dir);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user