diff --git a/src/routes/app.rs b/src/routes/app/mod.rs similarity index 83% rename from src/routes/app.rs rename to src/routes/app/mod.rs index 1bbdaa2..b5d6313 100644 --- a/src/routes/app.rs +++ b/src/routes/app/mod.rs @@ -1,7 +1,6 @@ use super::handle_error; use crate::{db, types::GoPair, AppState}; use anyhow::Context; -use askama::Template; use axum::{ extract::State, http::StatusCode, @@ -10,19 +9,12 @@ use axum::{ Form, Router, }; use axum_sessions::extractors::ReadableSession; -pub async fn home() -> impl IntoResponse { - #[derive(Template)] - #[template(path = "home.html")] - struct IndexTemplate; - IndexTemplate -} +mod templates; +use templates::*; -#[derive(Template)] -#[template(path = "app.html")] -struct AppTemplate { - username: String, - message: Option, +pub async fn home() -> impl IntoResponse { + IndexTemplate } async fn app(session: ReadableSession, _: State) -> Result { @@ -37,18 +29,6 @@ async fn app(session: ReadableSession, _: State) -> Result, -} - -#[derive(Template)] -#[template(path = "table.html")] -struct TableTemplate { - redirects: Vec, -} - ///this returns just the html for the table body. Used for lazy loading and reloading by HTMX. async fn table( session: ReadableSession, diff --git a/src/routes/app/templates.rs b/src/routes/app/templates.rs new file mode 100644 index 0000000..b3fe8c6 --- /dev/null +++ b/src/routes/app/templates.rs @@ -0,0 +1,24 @@ +use askama::Template; + +#[derive(Template)] +#[template(path = "app.html")] +pub struct AppTemplate { + pub username: String, + pub message: Option, +} + +#[derive(Template)] +#[template(path = "home.html")] +pub struct IndexTemplate; + +#[derive(Template)] +#[template(path = "panel.html")] +pub struct PanelTemplate { + pub message: Option, +} + +#[derive(Template)] +#[template(path = "table.html")] +pub struct TableTemplate { + pub redirects: Vec, +}