Templates and TLS requests
All checks were successful
Rust / Test (push) Successful in 5m34s
Rust / Rustfmt (push) Successful in 22s
Rust / Clippy (push) Successful in 1m13s
Rust / Code coverage (push) Successful in 3m33s

Refactored HTML templates and added TLS back to issue HTTP requests
This commit is contained in:
Alphonse Paix
2025-09-29 02:39:53 +02:00
parent 3b727269c5
commit de44564ba0
29 changed files with 513 additions and 401 deletions

View File

@@ -21,23 +21,33 @@ where
}
#[derive(Template)]
pub enum MessageTemplate {
#[template(path = "../templates/success.html")]
Success { message: String },
#[template(path = "../templates/error.html")]
Error { message: String },
#[template(path = "message.html")]
pub struct MessageTemplate {
pub message: String,
pub error: bool,
}
#[derive(Template)]
#[template(path = "../templates/500.html")]
pub struct InternalErrorTemplate;
impl MessageTemplate {
pub fn success(message: String) -> Self {
Self {
message,
error: false,
}
}
pub fn error(message: String) -> Self {
Self {
message,
error: true,
}
}
}
#[derive(Template)]
#[template(path = "../templates/login.html")]
pub struct LoginTemplate;
#[derive(Template)]
#[template(path = "../templates/dashboard.html")]
#[template(path = "dashboard/dashboard.html")]
pub struct DashboardTemplate {
pub username: String,
pub idempotency_key_1: String,
@@ -53,27 +63,27 @@ pub struct DashboardTemplate {
pub struct HomeTemplate;
#[derive(Template)]
#[template(path = "posts.html")]
#[template(path = "posts/list.html")]
pub struct PostsTemplate {
pub posts: Vec<PostEntry>,
pub next_page: Option<i64>,
}
#[derive(Template)]
#[template(path = "posts.html", block = "posts")]
#[template(path = "posts/list.html", block = "posts")]
pub struct PostListTemplate {
pub posts: Vec<PostEntry>,
pub next_page: Option<i64>,
}
#[derive(Template)]
#[template(path = "post.html")]
#[template(path = "posts/page.html")]
pub struct PostTemplate {
pub post: PostEntry,
}
#[derive(Template)]
#[template(path = "dashboard.html", block = "subs")]
#[template(path = "dashboard/subscribers/list.html", block = "subs")]
pub struct SubListTemplate {
pub subscribers: Vec<SubscriberEntry>,
pub current_page: i64,
@@ -81,19 +91,23 @@ pub struct SubListTemplate {
}
#[derive(Template)]
#[template(path = "confirm.html")]
#[template(path = "subscribe/confirm.html")]
pub struct ConfirmTemplate;
#[derive(Template)]
#[template(path = "404.html")]
pub struct NotFoundTemplate;
pub enum ErrorTemplate {
#[template(path = "error/404.html")]
NotFound,
#[template(path = "error/500.html")]
InternalServer,
}
#[derive(Template)]
#[template(path = "unsubscribe_confirm.html")]
#[template(path = "unsubscribe/confirm.html")]
pub struct UnsubscribeConfirmTemplate;
#[derive(Template)]
#[template(path = "unsubscribe.html")]
#[template(path = "unsubscribe/form.html")]
pub struct UnsubscribeTemplate;
#[derive(Template)]