Heavy refactor and extraction of most code to handler submodules

This commit is contained in:
Juno Takano 2025-12-12 04:13:32 -03:00
commit ab6e90b6b8
9 changed files with 313 additions and 277 deletions

View file

@ -0,0 +1,29 @@
use axum::{
body::Body,
http::{Response},
response::Redirect,
Form,
};
use crate::{formats::populate_graph, types::Node, handlers};
pub async fn nexus(template: &str) -> Response<Body> {
let mut context = tera::Context::new();
let graph = populate_graph();
let root_node = graph.get_root().unwrap_or_default();
let nodes: Vec<Node> = graph.nodes.into_values().collect();
context.insert("nodes", &nodes);
context.insert("root_node", &root_node);
handlers::template::by_filename(template, &context, 500, None, false)
}
pub async fn search(Form(query): Form<Query>) -> Redirect {
Redirect::permanent(format!("/node/{}", query.node).as_str())
}
#[derive(serde::Deserialize)]
pub struct Query {
node: String,
}