feat: privacy page and misc templates

This commit is contained in:
Per Stark
2025-01-16 09:14:30 +01:00
parent 0826a23a60
commit b37df4a9ed
10 changed files with 134 additions and 63 deletions

View File

@@ -32,6 +32,7 @@ use zettle_db::{
index::index_handler,
ingress::{process_ingress_form, show_ingress_form},
ingress_tasks::{delete_task, show_queue_tasks},
privacy_policy::show_privacy_policy,
search_result::search_result_handler,
signin::{authenticate_user, show_signin_form},
signout::sign_out_user,
@@ -170,6 +171,7 @@ fn html_routes(
.route("/", get(index_handler))
.route("/gdpr/accept", post(accept_gdpr))
.route("/gdpr/deny", post(deny_gdpr))
.route("/privacy-policy", get(show_privacy_policy))
.route("/search", get(search_result_handler))
.route("/signout", get(sign_out_user))
.route("/signin", get(show_signin_form).post(authenticate_user))

View File

@@ -13,7 +13,6 @@ use scraper::{Html, Selector};
use serde::{Deserialize, Serialize};
use std::fmt::Write;
use tiktoken_rs::{o200k_base, CoreBPE};
use tracing::info;
/// Knowledge object type, containing the content or reference to it, as well as metadata
#[derive(Debug, Serialize, Deserialize, Clone)]

View File

@@ -9,6 +9,7 @@ pub mod gdpr;
pub mod index;
pub mod ingress;
pub mod ingress_tasks;
pub mod privacy_policy;
pub mod search_result;
pub mod signin;
pub mod signout;

View File

@@ -0,0 +1,31 @@
use axum::{extract::State, response::IntoResponse};
use axum_session_auth::AuthSession;
use axum_session_surreal::SessionSurrealPool;
use surrealdb::{engine::any::Any, Surreal};
use crate::{
error::HtmlError,
page_data,
server::{routes::html::render_template, AppState},
storage::types::user::User,
};
page_data!(PrivacyPolicyData, "privacy_policy.html", {
user: Option<User>
});
pub async fn show_privacy_policy(
State(state): State<AppState>,
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
) -> Result<impl IntoResponse, HtmlError> {
let output = render_template(
PrivacyPolicyData::template_name(),
PrivacyPolicyData {
user: auth.current_user,
},
state.templates.clone(),
)
.map_err(|e| HtmlError::from_template_error(e, state.templates.clone()))?;
Ok(output.into_response())
}