Simplify handler contexts, template and style tweaks
This commit is contained in:
parent
75f50d6ed1
commit
940aadb6e5
14 changed files with 176 additions and 110 deletions
|
|
@ -20,6 +20,28 @@ pub async fn page(template: &str) -> Response<Body> {
|
|||
handlers::template::by_filename(template, &context, 500, None, false)
|
||||
}
|
||||
|
||||
pub async fn tree() -> Response<Body> {
|
||||
let mut context = tera::Context::default();
|
||||
let mut graph = Graph::load();
|
||||
|
||||
context.insert("graph", &graph);
|
||||
if let Some(root_node) = graph.get_root() {
|
||||
graph.nodes.remove(&root_node.id);
|
||||
context.insert("root_node", &root_node);
|
||||
context.insert(
|
||||
"nodes",
|
||||
&graph.nodes.values().cloned().collect::<Vec<Node>>(),
|
||||
);
|
||||
} else {
|
||||
context.insert(
|
||||
"nodes",
|
||||
&graph.nodes.values().cloned().collect::<Vec<Node>>(),
|
||||
);
|
||||
}
|
||||
|
||||
handlers::template::by_filename("tree.html", &context, 500, None, false)
|
||||
}
|
||||
|
||||
pub async fn data() -> Response<Body> {
|
||||
let mut context = tera::Context::default();
|
||||
let graph = Graph::load();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue