Reorganize module structure
This commit is contained in:
parent
51047ad11c
commit
14dc84cc43
14 changed files with 19 additions and 23 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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| {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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<u16>,
|
||||
message: Option<&str>,
|
||||
) -> Response<Body> {
|
||||
|
|
@ -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.
|
||||
|
|
@ -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<String>) -> Response<Body> {
|
||||
let graph = populate_graph();
|
||||
|
|
@ -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<Body> {
|
||||
|
|
@ -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)],
|
||||
|
|
@ -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<Body> {
|
||||
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
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
pub mod arguments;
|
||||
pub mod command;
|
||||
pub mod content;
|
||||
pub mod serial;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
syntax::arguments::Arguments,
|
||||
syntax::command::Arguments,
|
||||
types::{Edge, Graph, Node},
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue