diff --git a/src/lib.rs b/src/lib.rs index e7d8bc1..630bf0c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,10 +4,8 @@ pub mod prelude { pub use crate::log; } -pub mod formats; pub mod types; pub mod router; -pub mod handlers; pub mod syntax; pub mod dev; diff --git a/src/main.rs b/src/main.rs index 92d97f2..ab8dcb4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,10 @@ use std::{backtrace, io, panic}; -use en::{prelude::*, ONSET, formats::populate_graph, syntax}; +use en::{prelude::*, ONSET, syntax::serial::populate_graph, syntax}; #[tokio::main] async fn main() -> io::Result<()> { - let args = syntax::arguments::Arguments::new().parse(); + let args = syntax::command::Arguments::new().parse(); let address = args.make_address(); panic::set_hook(Box::new(|info| { diff --git a/src/router.rs b/src/router.rs index 00ab756..351b18d 100644 --- a/src/router.rs +++ b/src/router.rs @@ -1,6 +1,8 @@ use axum::{routing::get, Router}; -use crate::{formats::Format, handlers, types::Graph}; +use crate::{syntax::serial::Format, types::Graph}; + +mod handlers; pub fn new(graph: &Graph) -> Router { let mut router = Router::new() diff --git a/src/handlers.rs b/src/router/handlers.rs similarity index 100% rename from src/handlers.rs rename to src/router/handlers.rs diff --git a/src/handlers/error.rs b/src/router/handlers/error.rs similarity index 92% rename from src/handlers/error.rs rename to src/router/handlers/error.rs index 9b24d54..e017e4d 100644 --- a/src/handlers/error.rs +++ b/src/router/handlers/error.rs @@ -3,9 +3,9 @@ use axum::{ http::{Response, StatusCode, header}, }; -use crate::{formats::populate_graph, handlers}; +use crate::{syntax::serial::populate_graph, router::handlers}; -pub(in crate::handlers) fn by_code( +pub(in crate::router::handlers) fn by_code( code: Option, message: Option<&str>, ) -> Response { diff --git a/src/handlers/fixed.rs b/src/router/handlers/fixed.rs similarity index 94% rename from src/handlers/fixed.rs rename to src/router/handlers/fixed.rs index 7b372b4..6406533 100644 --- a/src/handlers/fixed.rs +++ b/src/router/handlers/fixed.rs @@ -5,9 +5,9 @@ use axum::{ use crate::prelude::*; use crate::{ - formats::{Format, populate_graph, serialize_graph}, + router::handlers, + syntax::serial::{Format, populate_graph, serialize_graph}, }; -use crate::handlers; /// # Panics /// Will panic if file read fails. diff --git a/src/handlers/graph.rs b/src/router/handlers/graph.rs similarity index 94% rename from src/handlers/graph.rs rename to src/router/handlers/graph.rs index 6733114..a3d3f1e 100644 --- a/src/handlers/graph.rs +++ b/src/router/handlers/graph.rs @@ -3,7 +3,7 @@ use axum::{body::Body, extract::Path, http::Response, response::Redirect}; use crate::syntax::content; -use crate::{formats::populate_graph, handlers, types::Node}; +use crate::{syntax::serial::populate_graph, router::handlers, types::Node}; pub async fn node(Path(id): Path) -> Response { let graph = populate_graph(); diff --git a/src/handlers/navigation.rs b/src/router/handlers/navigation.rs similarity index 91% rename from src/handlers/navigation.rs rename to src/router/handlers/navigation.rs index 9a6ea26..71655c2 100644 --- a/src/handlers/navigation.rs +++ b/src/router/handlers/navigation.rs @@ -5,7 +5,7 @@ use axum::{ Form, }; -use crate::{formats::populate_graph, handlers, types::Node}; +use crate::{syntax::serial::populate_graph, router::handlers, types::Node}; #[expect(clippy::unused_async)] pub async fn page(template: &str) -> Response { diff --git a/src/handlers/raw.rs b/src/router/handlers/raw.rs similarity index 94% rename from src/handlers/raw.rs rename to src/router/handlers/raw.rs index 2632a7f..578add3 100644 --- a/src/handlers/raw.rs +++ b/src/router/handlers/raw.rs @@ -5,7 +5,7 @@ use axum::{ use crate::prelude::*; -pub(in crate::handlers) fn make_response( +pub(in crate::router::handlers) fn make_response( body: &str, status_code: u16, headers: &[(header::HeaderName, &str)], diff --git a/src/handlers/template.rs b/src/router/handlers/template.rs similarity index 91% rename from src/handlers/template.rs rename to src/router/handlers/template.rs index 7934f0e..7ce6e52 100644 --- a/src/handlers/template.rs +++ b/src/router/handlers/template.rs @@ -3,9 +3,9 @@ use axum::{ http::{header, Response, StatusCode}, }; -use crate::{prelude::*, handlers::raw::make_response}; +use crate::{prelude::*, router::handlers::raw::make_response}; -pub(in crate::handlers) fn by_filename( +pub(in crate::router::handlers) fn by_filename( name: &str, context: &tera::Context, error_code: u16, @@ -19,12 +19,7 @@ pub(in crate::handlers) fn by_filename( make_response(&body, status_code, &[(header::CONTENT_TYPE, "text/html")]) } -#[expect(clippy::unused_async)] -pub async fn fixed(name: &str) -> Response { - by_filename(name, &tera::Context::new(), 500, None, false) -} - -pub(in crate::handlers) fn render( +pub(in crate::router::handlers) fn render( name: &str, // TODO take Option, skip context if None, // then template_handler can replace static_template_handler diff --git a/src/syntax.rs b/src/syntax.rs index caef4dc..c88a706 100644 --- a/src/syntax.rs +++ b/src/syntax.rs @@ -1,2 +1,3 @@ -pub mod arguments; +pub mod command; pub mod content; +pub mod serial; diff --git a/src/syntax/arguments.rs b/src/syntax/command.rs similarity index 100% rename from src/syntax/arguments.rs rename to src/syntax/command.rs diff --git a/src/syntax/content/parser.rs b/src/syntax/content/parser.rs index 80b0e65..9e67f39 100644 --- a/src/syntax/content/parser.rs +++ b/src/syntax/content/parser.rs @@ -1,6 +1,6 @@ use std::collections::{HashMap}; -use crate::{formats::populate_graph, types::Config}; +use crate::{syntax::serial::populate_graph, types::Config}; use super::{Parseable as _, Token, LexMap}; use token::{ anchor::Anchor, linebreak::LineBreak, paragraph::Paragraph, header::Header, diff --git a/src/formats.rs b/src/syntax/serial.rs similarity index 99% rename from src/formats.rs rename to src/syntax/serial.rs index 4f79aac..10abf45 100644 --- a/src/formats.rs +++ b/src/syntax/serial.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use crate::{ - syntax::arguments::Arguments, + syntax::command::Arguments, types::{Edge, Graph, Node}, };