From bcdd3628ef990cb8580b9754ac4ec2e8f21d7965 Mon Sep 17 00:00:00 2001
From: Per Stark
Date: Wed, 30 Apr 2025 12:49:25 +0200
Subject: [PATCH] feat: content reader modal
---
html-router/src/routes/content/handlers.rs | 19 +++++++++
html-router/src/routes/content/mod.rs | 4 +-
html-router/src/routes/index/handlers.rs | 12 ++----
.../templates/content/content_list.html | 4 ++
.../templates/content/read_content_modal.html | 42 +++++++++++++++++++
html-router/templates/icons/read_icon.html | 5 +++
html-router/templates/modal_base.html | 5 ++-
7 files changed, 80 insertions(+), 11 deletions(-)
create mode 100644 html-router/templates/content/read_content_modal.html
create mode 100644 html-router/templates/icons/read_icon.html
diff --git a/html-router/src/routes/content/handlers.rs b/html-router/src/routes/content/handlers.rs
index 6c11a6e..94600f9 100644
--- a/html-router/src/routes/content/handlers.rs
+++ b/html-router/src/routes/content/handlers.rs
@@ -164,3 +164,22 @@ pub async fn delete_text_content(
},
))
}
+
+pub async fn show_content_read_modal(
+ State(state): State,
+ RequireUser(user): RequireUser,
+ Path(id): Path,
+) -> Result {
+ // Get and validate the text content
+ let text_content = User::get_and_validate_text_content(&id, &user.id, &state.db).await?;
+ #[derive(Serialize)]
+ pub struct TextContentReadModalData {
+ pub user: User,
+ pub text_content: TextContent,
+ }
+
+ Ok(TemplateResponse::new_template(
+ "content/read_content_modal.html",
+ TextContentReadModalData { user, text_content },
+ ))
+}
diff --git a/html-router/src/routes/content/mod.rs b/html-router/src/routes/content/mod.rs
index 6b2590b..d8f12c2 100644
--- a/html-router/src/routes/content/mod.rs
+++ b/html-router/src/routes/content/mod.rs
@@ -2,7 +2,8 @@ mod handlers;
use axum::{extract::FromRef, routing::get, Router};
use handlers::{
- delete_text_content, patch_text_content, show_content_page, show_text_content_edit_form,
+ delete_text_content, patch_text_content, show_content_page, show_content_read_modal,
+ show_text_content_edit_form,
};
use crate::html_state::HtmlState;
@@ -14,6 +15,7 @@ where
{
Router::new()
.route("/content", get(show_content_page))
+ .route("/content/{id}/read", get(show_content_read_modal))
.route(
"/content/{id}",
get(show_text_content_edit_form)
diff --git a/html-router/src/routes/index/handlers.rs b/html-router/src/routes/index/handlers.rs
index eab2c06..a8ea282 100644
--- a/html-router/src/routes/index/handlers.rs
+++ b/html-router/src/routes/index/handlers.rs
@@ -18,15 +18,9 @@ use crate::{
use common::{
error::AppError,
storage::types::{
- conversation::Conversation,
- file_info::{FileError, FileInfo},
- ingestion_task::IngestionTask,
- knowledge_entity::KnowledgeEntity,
- knowledge_relationship::KnowledgeRelationship,
- text_chunk::TextChunk,
- text_content::TextContent,
- user::User,
- StoredObject,
+ conversation::Conversation, file_info::FileInfo, ingestion_task::IngestionTask,
+ knowledge_entity::KnowledgeEntity, knowledge_relationship::KnowledgeRelationship,
+ text_chunk::TextChunk, text_content::TextContent, user::User,
},
};
diff --git a/html-router/templates/content/content_list.html b/html-router/templates/content/content_list.html
index f4df509..bf68a01 100644
--- a/html-router/templates/content/content_list.html
+++ b/html-router/templates/content/content_list.html
@@ -29,6 +29,10 @@
{{ text_content.category }}
+