35 lines
1.4 KiB
Rust
35 lines
1.4 KiB
Rust
|
|
||
|
fn get_config(path: String) -> Result<Config> {
|
||
|
let inp_def_yaml = fs::read_to_string(path)
|
||
|
.expect("Should have been able to read the the config file");
|
||
|
|
||
|
serde_yaml::from_str(&inp_def_yaml)
|
||
|
.map_err(|e| anyhow!("Failed to parse config, {:?}", e))
|
||
|
}
|
||
|
|
||
|
fn build_templating_env() -> Environment<'static> {
|
||
|
let mut templating_env = Environment::new();
|
||
|
|
||
|
let _ = templating_env
|
||
|
.add_template("layouts/base.html", include_str!("./templates/layouts/base.html"));
|
||
|
let _ = templating_env
|
||
|
.add_template("pages/home.html", include_str!("./templates/pages/home.html"));
|
||
|
let _ = templating_env
|
||
|
.add_template("pages/list_tasks.html", include_str!("./templates/pages/list_tasks.html"));
|
||
|
let _ = templating_env
|
||
|
.add_template("pages/list_task_runs.html", include_str!("./templates/pages/list_task_runs.html"));
|
||
|
let _ = templating_env
|
||
|
.add_template("pages/task_run_details.html", include_str!("./templates/pages/task_run_details.html"));
|
||
|
let _ = templating_env
|
||
|
.add_template("pages/run_task.html", include_str!("./templates/pages/run_task.html"));
|
||
|
|
||
|
// TODO: better loading with embed https://docs.rs/minijinja-embed/latest/minijinja_embed/
|
||
|
templating_env.add_global("gl", context! {
|
||
|
instance => context! {
|
||
|
version => "1.243".to_string()
|
||
|
}
|
||
|
});
|
||
|
templating_env
|
||
|
}
|
||
|
|