diff --git a/README.md b/README.md index 3b2f454..1ac5dba 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ - [`axum`](https://github.com/tokio-rs/axum) is used as an http framework, build on top of [tokio](https://github.com/tokio-rs/tokio) and [hyper](https://github.com/hyperium/hyper) - [`sqlx`](https://github.com) is used for database queries - [`askama`](https://github.com/djc/askama) is used as a templating engine for the web interface - - [`tailwind`](https://github.com/tailwindlabs/tailwindcss) is used for styling + - [`tailwind`](https://github.com/tailwindlabs/tailwindcss) is used for styling +- [`htmx`](https://htmx.org/) is used to provide a little reactivity on the frontend ## Development @@ -19,7 +20,7 @@ ### Docker -A compose stack is provided to start go2, with both a supporting database container and a mock authentication service. +A compose stack is provided to start go2, with both a supporting database container and a mock authentication service. The stack uses host networking due to weirdness in communication between the user, go2, and the auth service. This means that stack **requires rootful docker running on Linux**, and will not work with rootless docker or on MacOS/Windows. Contributions of a workaround to this would be appreciated. diff --git a/src/routes/app.rs b/src/routes/app.rs index 809eb00..a94f2bd 100644 --- a/src/routes/app.rs +++ b/src/routes/app.rs @@ -24,10 +24,7 @@ struct PanelTemplate { username: String, } -async fn panel( - session: ReadableSession, - State(state): State, -) -> Result { +async fn panel(session: ReadableSession, _: State) -> Result { if session.get::("username").is_none() { return Err(Redirect::to("/auth/login").into()); } @@ -41,6 +38,8 @@ async fn panel( 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, State(state): State, @@ -80,7 +79,10 @@ async fn handle_form( "An error occursed while adding your go link to the database.", ) })?; - Ok(Redirect::to("/app/panel")) + + //return updated table for htmx to swap in + //TODO: only return new row, more + Ok(Redirect::to("/app/panel/table")) } pub fn app_routes() -> Router { diff --git a/templates/app.html b/templates/app.html index 8086660..5984c22 100644 --- a/templates/app.html +++ b/templates/app.html @@ -2,8 +2,9 @@

Add new go link

diff --git a/templates/table.html b/templates/table.html index c860ac0..6d13a81 100644 --- a/templates/table.html +++ b/templates/table.html @@ -1,4 +1,4 @@ - + {% for r in redirects %}