From 89635cfd4174a3af6446265a63498dd850b6d7f2 Mon Sep 17 00:00:00 2001 From: Per Stark Date: Tue, 1 Apr 2025 13:24:42 +0200 Subject: [PATCH] refactor: signin landing page --- crates/html-router/src/routes/auth/signin.rs | 4 +- .../html-router/src/routes/index/handlers.rs | 37 +++++------ .../templates/auth/admin_panel.html | 61 ++++++++++--------- .../templates/auth/signin_base.html | 6 ++ .../templates/auth/signin_form.html | 7 +-- crates/html-router/templates/gdpr.html | 15 ----- crates/html-router/templates/index/hero.html | 51 ---------------- crates/html-router/templates/index/index.html | 5 +- todo.md | 4 +- 9 files changed, 59 insertions(+), 131 deletions(-) create mode 100644 crates/html-router/templates/auth/signin_base.html delete mode 100644 crates/html-router/templates/gdpr.html delete mode 100644 crates/html-router/templates/index/hero.html diff --git a/crates/html-router/src/routes/auth/signin.rs b/crates/html-router/src/routes/auth/signin.rs index 1c6771d..0ed8379 100644 --- a/crates/html-router/src/routes/auth/signin.rs +++ b/crates/html-router/src/routes/auth/signin.rs @@ -29,11 +29,11 @@ pub async fn show_signin_form( } match boosted { true => Ok(TemplateResponse::new_partial( - "auth/signin_form.html", + "auth/signin_base.html", "body", (), )), - false => Ok(TemplateResponse::new_template("auth/signin_form.html", ())), + false => Ok(TemplateResponse::new_template("auth/signin_base.html", ())), } } diff --git a/crates/html-router/src/routes/index/handlers.rs b/crates/html-router/src/routes/index/handlers.rs index 5dbb6b0..6a96a88 100644 --- a/crates/html-router/src/routes/index/handlers.rs +++ b/crates/html-router/src/routes/index/handlers.rs @@ -10,7 +10,7 @@ use crate::{ auth_middleware::RequireUser, response_middleware::{HtmlError, TemplateResponse}, }, - AuthSessionType, SessionType, + AuthSessionType, }; use common::{ error::AppError, @@ -25,7 +25,6 @@ use crate::html_state::HtmlState; #[derive(Serialize)] pub struct IndexPageData { - gdpr_accepted: bool, user: Option, latest_text_contents: Vec, active_jobs: Vec, @@ -34,34 +33,26 @@ pub struct IndexPageData { pub async fn index_handler( State(state): State, auth: AuthSessionType, - session: SessionType, ) -> Result { - let gdpr_accepted = auth.current_user.is_some() | session.get("gdpr_accepted").unwrap_or(false); - - let active_jobs = match auth.current_user.is_some() { - true => { - User::get_unfinished_ingestion_tasks(&auth.current_user.clone().unwrap().id, &state.db) - .await? - } - false => vec![], + let Some(user) = auth.current_user else { + return Ok(TemplateResponse::new_template( + "index/index.html", + IndexPageData { + user: None, + latest_text_contents: vec![], + active_jobs: vec![], + }, + )); }; - let latest_text_contents = match auth.current_user.clone().is_some() { - true => { - User::get_latest_text_contents( - auth.current_user.clone().unwrap().id.as_str(), - &state.db, - ) - .await? - } - false => vec![], - }; + let active_jobs = User::get_unfinished_ingestion_tasks(&user.id, &state.db).await?; + + let latest_text_contents = User::get_latest_text_contents(user.id.as_str(), &state.db).await?; Ok(TemplateResponse::new_template( "index/index.html", IndexPageData { - gdpr_accepted, - user: auth.current_user, + user: Some(user), latest_text_contents, active_jobs, }, diff --git a/crates/html-router/templates/auth/admin_panel.html b/crates/html-router/templates/auth/admin_panel.html index fd915b4..fadaea7 100644 --- a/crates/html-router/templates/auth/admin_panel.html +++ b/crates/html-router/templates/auth/admin_panel.html @@ -25,19 +25,23 @@
-
- Registration - -
-
+ {% block system_prompt_section %} +
+
+ System Prompts +
+ + +
+
+
+ {% endblock %}
AI Models @@ -76,23 +80,20 @@ {% endblock %}
- {% block system_prompt_section %} -
-
- System Prompts -
- - -
-
-
- {% endblock %} +
+ Registration + +
+
+
{% endblock %} \ No newline at end of file diff --git a/crates/html-router/templates/auth/signin_base.html b/crates/html-router/templates/auth/signin_base.html new file mode 100644 index 0000000..f12f8a9 --- /dev/null +++ b/crates/html-router/templates/auth/signin_base.html @@ -0,0 +1,6 @@ +{% extends "head_base.html" %} +{% block body %} +
+ {% include "auth/signin_form.html" %} +
+{% endblock %} \ No newline at end of file diff --git a/crates/html-router/templates/auth/signin_form.html b/crates/html-router/templates/auth/signin_form.html index cdc82a5..d2af81a 100644 --- a/crates/html-router/templates/auth/signin_form.html +++ b/crates/html-router/templates/auth/signin_form.html @@ -1,12 +1,10 @@ -{% extends "head_base.html" %} -{% block body %} -
+

Minne @@ -51,5 +49,4 @@ Don't have an account? Sign up

-
-{% endblock %} \ No newline at end of file + \ No newline at end of file diff --git a/crates/html-router/templates/gdpr.html b/crates/html-router/templates/gdpr.html deleted file mode 100644 index a86f610..0000000 --- a/crates/html-router/templates/gdpr.html +++ /dev/null @@ -1,15 +0,0 @@ -
-
-

We use cookies to enhance your experience. By continuing to visit this site, - you agree to - our use cookies. - Learn more -

-
- - -
-
-
\ No newline at end of file diff --git a/crates/html-router/templates/index/hero.html b/crates/html-router/templates/index/hero.html deleted file mode 100644 index 0b7f8e9..0000000 --- a/crates/html-router/templates/index/hero.html +++ /dev/null @@ -1,51 +0,0 @@ -
-
-
- -

- Your Second Brain, Built to Remember -
- Minne /ˈmɪnɛ/ [Swedish: memory] -
-

-

- Capture, connect, and retrieve your knowledge effortlessly with Minne -

- - -
-
-
-
-

Easy Capture

-

Save anything instantly - texts, links, images, and more

-
-
-
-
-
-

Smart Analysis

-

AI-powered content analysis and organization

-
-
-
-
-
-

Knowledge Graph

-

Visualize connections between your ideas

-
-
-
- - - - -
-
-
\ No newline at end of file diff --git a/crates/html-router/templates/index/index.html b/crates/html-router/templates/index/index.html index 8b93e9e..1cdf65c 100644 --- a/crates/html-router/templates/index/index.html +++ b/crates/html-router/templates/index/index.html @@ -3,9 +3,6 @@ {% if user %} {% include 'index/signed_in/base.html' %} {% else %} -{% include 'index/hero.html' %} -{% if not gdpr_accepted %} -{% include "gdpr.html" %} -{% endif %} +{% include 'auth/signin_form.html' %} {% endif %} {% endblock %} \ No newline at end of file diff --git a/todo.md b/todo.md index b326416..b31384d 100644 --- a/todo.md +++ b/todo.md @@ -2,9 +2,10 @@ \[\] configs primarily get envs \[\] filtering on categories \[\] integrate assets folder in release build -\[x] integrate templates in release build +\[\] make sure error messages render correctly \[\] markdown rendering in client \[\] openai api key in config +\[\] testing core functions \[\] three js graph explorer \[\] three js vector explorer \[x\] add user_id to ingress objects @@ -16,6 +17,7 @@ \[x\] gdpr \[x\] html ingression \[x\] hx-redirect +\[x\] integrate templates in release build \[x\] ios shortcut generation \[x\] job queue \[x\] link to ingressed urls or archives