wip
This commit is contained in:
1
TODO.txt
Normal file
1
TODO.txt
Normal file
@@ -0,0 +1 @@
|
||||
Add global vars to the env context, then add vars from user defined config.toml to the env context...
|
||||
@@ -34,6 +34,7 @@ pub struct Header {
|
||||
r#type: String,
|
||||
title: Option<String>,
|
||||
pub path: Option<String>,
|
||||
pub file_path: Option<String>,
|
||||
// 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());
|
||||
|
||||
@@ -72,9 +72,6 @@ async fn listen(
|
||||
listener: Async<TcpListener>,
|
||||
state: Arc<AppState<'static>>,
|
||||
) -> Result<()> {
|
||||
// Format the full host address.
|
||||
// println!("Listening on {}", host);
|
||||
|
||||
loop {
|
||||
// Wait for a new client.
|
||||
let (client, _) = listener.accept().await?;
|
||||
|
||||
Reference in New Issue
Block a user