From 23a5d5596e9b07ed383c026e96d82e3d426e7149 Mon Sep 17 00:00:00 2001 From: Doloro1978 Date: Fri, 16 Jan 2026 10:12:45 +0000 Subject: [PATCH] wip --- TODO.txt | 1 + src/loader.rs | 22 +++++++++++++++++++++- src/main.rs | 3 --- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 TODO.txt diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..287cb53 --- /dev/null +++ b/TODO.txt @@ -0,0 +1 @@ +Add global vars to the env context, then add vars from user defined config.toml to the env context... diff --git a/src/loader.rs b/src/loader.rs index b903682..2acbe94 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -34,6 +34,7 @@ pub struct Header { r#type: String, title: Option, pub path: Option, + pub file_path: Option, // TODO impl this later // extras: Table, } @@ -66,7 +67,8 @@ impl AppState<'_> { config_path.push("config.toml"); let config_file = fs::read_to_string(config_path).await?; - let header: Header = toml::from_str(&config_file)?; + let mut header: Header = toml::from_str(&config_file)?; + header.file_path = Some(entry.path().to_str().unwrap().to_string()); let mut index = entry.path(); index.push("index.html"); @@ -80,6 +82,24 @@ impl AppState<'_> { continue; } let page = Page { header: header }; + + let mut error_out = false; + for x in &self.pages { + if x.header.id == page.header.id { + println!( + "{:#?} has the same id as {:#?} !! not loading this page", + entry.path(), + x.header.file_path.unwrap() + ); + error_out = true; + break; + } + } + + if error_out { + continue; + } + self.pages.push(page); } else { println!("Not parsing {}", entry.file_name().to_str().unwrap()); diff --git a/src/main.rs b/src/main.rs index ab76d16..28c94f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,9 +72,6 @@ async fn listen( listener: Async, state: Arc>, ) -> Result<()> { - // Format the full host address. - // println!("Listening on {}", host); - loop { // Wait for a new client. let (client, _) = listener.accept().await?;