Askama + htmx for frontend
Server-side rendering with htmx and Tailwind CSS for the styling
This commit is contained in:
@@ -4,6 +4,7 @@ use crate::{
|
||||
session_state::TypedSession,
|
||||
startup::AppState,
|
||||
};
|
||||
use askama::Template;
|
||||
use axum::{
|
||||
Form, Json,
|
||||
extract::State,
|
||||
@@ -50,18 +51,25 @@ impl IntoResponse for LoginError {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "../templates/login.html")]
|
||||
struct LoginTemplate {
|
||||
error_html: String,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct LoginFormData {
|
||||
username: String,
|
||||
password: SecretString,
|
||||
}
|
||||
|
||||
pub async fn get_login(messages: Messages) -> impl IntoResponse {
|
||||
pub async fn get_login(messages: Messages) -> Html<String> {
|
||||
let mut error_html = String::new();
|
||||
for message in messages {
|
||||
writeln!(error_html, "<p><i>{}</i></p>", message).unwrap();
|
||||
}
|
||||
Html(format!(include_str!("login/login.html"), error_html))
|
||||
let template = LoginTemplate { error_html };
|
||||
Html(template.render().unwrap())
|
||||
}
|
||||
|
||||
pub async fn post_login(
|
||||
|
||||
Reference in New Issue
Block a user