mirror of
https://github.com/perstarkse/minne.git
synced 2026-07-17 18:21:21 +02:00
feat: doc pages, finished refactor of ingress
This commit is contained in:
@@ -24,6 +24,7 @@ use zettle_db::{
|
||||
},
|
||||
html::{
|
||||
account::{delete_account, set_api_key, show_account_page},
|
||||
documentation::index::show_documentation_index,
|
||||
gdpr::{accept_gdpr, deny_gdpr},
|
||||
index::index_handler,
|
||||
ingress::{process_ingress_form, show_ingress_form},
|
||||
@@ -164,6 +165,7 @@ fn html_routes(
|
||||
"/signup",
|
||||
get(show_signup_form).post(process_signup_and_show_verification),
|
||||
)
|
||||
.route("/documentation", get(show_documentation_index))
|
||||
.nest_service("/assets", ServeDir::new("assets/"))
|
||||
.layer(
|
||||
AuthSessionLayer::<User, String, SessionSurrealPool<Any>, Surreal<Any>>::new(Some(
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
use super::ingress_object::IngressObject;
|
||||
use crate::{
|
||||
error::AppError,
|
||||
storage::{
|
||||
db::{get_item, SurrealDbClient},
|
||||
types::file_info::FileInfo,
|
||||
},
|
||||
};
|
||||
use crate::{error::AppError, storage::types::file_info::FileInfo};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::info;
|
||||
use url::Url;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
use crate::{
|
||||
error::{ApiError, AppError},
|
||||
ingress::types::{
|
||||
ingress_input::{create_ingress_objects, IngressInput},
|
||||
ingress_object,
|
||||
},
|
||||
ingress::types::ingress_input::{create_ingress_objects, IngressInput},
|
||||
server::AppState,
|
||||
storage::types::{file_info::FileInfo, user::User},
|
||||
};
|
||||
use axum::{extract::State, http::StatusCode, response::IntoResponse, Extension, Json};
|
||||
use axum::{extract::State, http::StatusCode, response::IntoResponse, Extension};
|
||||
use axum_typed_multipart::{FieldData, TryFromMultipart, TypedMultipart};
|
||||
use futures::{future::try_join_all, TryFutureExt};
|
||||
use tempfile::NamedTempFile;
|
||||
@@ -31,7 +28,7 @@ pub async fn ingress_data(
|
||||
info!("Received input: {:?}", input);
|
||||
|
||||
let file_infos = try_join_all(input.files.into_iter().map(|file| {
|
||||
FileInfo::new(file, &state.surreal_db_client, &user.id).map_err(|e| AppError::from(e))
|
||||
FileInfo::new(file, &state.surreal_db_client, &user.id).map_err(AppError::from)
|
||||
}))
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -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!(IndexData, "documentation/index.html", {
|
||||
user: Option<User>
|
||||
});
|
||||
|
||||
pub async fn show_documentation_index(
|
||||
State(state): State<AppState>,
|
||||
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
|
||||
) -> Result<impl IntoResponse, HtmlError> {
|
||||
let output = render_template(
|
||||
IndexData::template_name(),
|
||||
IndexData {
|
||||
user: auth.current_user,
|
||||
},
|
||||
state.templates.clone(),
|
||||
)
|
||||
.map_err(|e| HtmlError::from_template_error(e, state.templates.clone()))?;
|
||||
|
||||
Ok(output.into_response())
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod index;
|
||||
@@ -76,7 +76,7 @@ pub async fn process_ingress_form(
|
||||
},
|
||||
user.id.as_str(),
|
||||
)
|
||||
.map_err(|e| HtmlError::new(AppError::from(e), state.templates.clone()))?;
|
||||
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;
|
||||
|
||||
let futures: Vec<_> = ingress_objects
|
||||
.into_iter()
|
||||
@@ -86,9 +86,7 @@ pub async fn process_ingress_form(
|
||||
try_join_all(futures)
|
||||
.await
|
||||
.map_err(AppError::from)
|
||||
.map_err(|e| HtmlError::new(AppError::from(e), state.templates.clone()))?;
|
||||
// Process the ingress (implement your logic here)
|
||||
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;
|
||||
|
||||
Ok(Html("SuccessBRO!").into_response())
|
||||
// Ok((HxRedirect::from(Uri::from_static("/")), StatusCode::OK).into_response())
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ use axum::response::Html;
|
||||
use minijinja_autoreload::AutoReloader;
|
||||
|
||||
pub mod account;
|
||||
pub mod documentation;
|
||||
pub mod gdpr;
|
||||
pub mod index;
|
||||
pub mod ingress;
|
||||
|
||||
Reference in New Issue
Block a user