Modified : now generates content regularly
This commit is contained in:
parent
522bcf3289
commit
1879af7230
@ -24,4 +24,4 @@ VOLUME ["/opt/flog/templates"]
|
|||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
CMD ["/usr/local/bin/flog-docker"]
|
CMD ["flog"]
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Squi's awesome git blog</h1>
|
<h1>Squi's awesome blog</h1>
|
||||||
<p><img src="/pics/ferris.png" style="width:20%;"></p>
|
<p><img src="/pics/ferris.png" style="width:20%;"></p>
|
||||||
<br><br>
|
<br><br>
|
||||||
<h2>Lately on this great blog</h2>
|
<h2>Lately on this great blog</h2>
|
||||||
|
@ -4,6 +4,7 @@ use ssw::websrv::run_server;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::{thread, time};
|
||||||
|
|
||||||
//1 - Ingest all the pages into a variable
|
//1 - Ingest all the pages into a variable
|
||||||
// : all the pages must start with a number indicating their order
|
// : all the pages must start with a number indicating their order
|
||||||
@ -92,15 +93,7 @@ fn generate_index(pages: (String, String),
|
|||||||
fs::write(&index_path, index.as_str()).expect("Could not write index");
|
fs::write(&index_path, index.as_str()).expect("Could not write index");
|
||||||
}
|
}
|
||||||
|
|
||||||
//#4
|
fn generate_content() -> String {
|
||||||
fn start_websrv(conf: WebsrvConfig) {
|
|
||||||
run_server(conf);
|
|
||||||
loop {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
//Initialize from env variables
|
//Initialize from env variables
|
||||||
let root_path_env = "FLOG_ROOT_FOLDER";
|
let root_path_env = "FLOG_ROOT_FOLDER";
|
||||||
let root_folder = match env::var(root_path_env) {
|
let root_folder = match env::var(root_path_env) {
|
||||||
@ -115,18 +108,36 @@ fn main() {
|
|||||||
let footer_path = format!("{html_folder_path}/footer.html");
|
let footer_path = format!("{html_folder_path}/footer.html");
|
||||||
|
|
||||||
let pages = match ingest_pages(&pages_path, &header_path, &footer_path, &html_folder_path) {
|
let pages = match ingest_pages(&pages_path, &header_path, &footer_path, &html_folder_path) {
|
||||||
Some(p) => p,
|
Some(p) => {
|
||||||
None => (String::new(), String::new()),
|
println!("INFO : Generated site's content");
|
||||||
|
p
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
println!("ERR : No pages found, nothing to ingest");
|
||||||
|
(String::new(), String::new())
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
generate_index(pages, &index_template_path, &html_folder_path, &header_path, &footer_path);
|
generate_index(pages, &index_template_path, &html_folder_path, &header_path, &footer_path);
|
||||||
|
return html_folder_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let html_folder = generate_content();
|
||||||
//Web conf
|
//Web conf
|
||||||
let webconf = WebsrvConfig {
|
let webconf = WebsrvConfig {
|
||||||
nbr_of_threads: 10,
|
nbr_of_threads: 10,
|
||||||
bind_addr: String::from("0.0.0.0:8000"),
|
bind_addr: String::from("0.0.0.0:8000"),
|
||||||
root_folder: String::from(&html_folder_path),
|
root_folder: String::from(&html_folder),
|
||||||
};
|
};
|
||||||
start_websrv(webconf);
|
run_server(webconf);
|
||||||
|
loop {
|
||||||
|
let time_wait = time::Duration::from_secs(600);
|
||||||
|
thread::sleep(time_wait);
|
||||||
|
generate_content();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user