refactor: signin landing page

This commit is contained in:
Per Stark
2025-04-01 13:24:42 +02:00
parent 42798788a5
commit 89635cfd41
9 changed files with 59 additions and 131 deletions

View File

@@ -29,11 +29,11 @@ pub async fn show_signin_form(
} }
match boosted { match boosted {
true => Ok(TemplateResponse::new_partial( true => Ok(TemplateResponse::new_partial(
"auth/signin_form.html", "auth/signin_base.html",
"body", "body",
(), (),
)), )),
false => Ok(TemplateResponse::new_template("auth/signin_form.html", ())), false => Ok(TemplateResponse::new_template("auth/signin_base.html", ())),
} }
} }

View File

@@ -10,7 +10,7 @@ use crate::{
auth_middleware::RequireUser, auth_middleware::RequireUser,
response_middleware::{HtmlError, TemplateResponse}, response_middleware::{HtmlError, TemplateResponse},
}, },
AuthSessionType, SessionType, AuthSessionType,
}; };
use common::{ use common::{
error::AppError, error::AppError,
@@ -25,7 +25,6 @@ use crate::html_state::HtmlState;
#[derive(Serialize)] #[derive(Serialize)]
pub struct IndexPageData { pub struct IndexPageData {
gdpr_accepted: bool,
user: Option<User>, user: Option<User>,
latest_text_contents: Vec<TextContent>, latest_text_contents: Vec<TextContent>,
active_jobs: Vec<IngestionTask>, active_jobs: Vec<IngestionTask>,
@@ -34,34 +33,26 @@ pub struct IndexPageData {
pub async fn index_handler( pub async fn index_handler(
State(state): State<HtmlState>, State(state): State<HtmlState>,
auth: AuthSessionType, auth: AuthSessionType,
session: SessionType,
) -> Result<impl IntoResponse, HtmlError> { ) -> Result<impl IntoResponse, HtmlError> {
let gdpr_accepted = auth.current_user.is_some() | session.get("gdpr_accepted").unwrap_or(false); let Some(user) = auth.current_user else {
return Ok(TemplateResponse::new_template(
let active_jobs = match auth.current_user.is_some() { "index/index.html",
true => { IndexPageData {
User::get_unfinished_ingestion_tasks(&auth.current_user.clone().unwrap().id, &state.db) user: None,
.await? latest_text_contents: vec![],
} active_jobs: vec![],
false => vec![], },
));
}; };
let latest_text_contents = match auth.current_user.clone().is_some() { let active_jobs = User::get_unfinished_ingestion_tasks(&user.id, &state.db).await?;
true => {
User::get_latest_text_contents( let latest_text_contents = User::get_latest_text_contents(user.id.as_str(), &state.db).await?;
auth.current_user.clone().unwrap().id.as_str(),
&state.db,
)
.await?
}
false => vec![],
};
Ok(TemplateResponse::new_template( Ok(TemplateResponse::new_template(
"index/index.html", "index/index.html",
IndexPageData { IndexPageData {
gdpr_accepted, user: Some(user),
user: auth.current_user,
latest_text_contents, latest_text_contents,
active_jobs, active_jobs,
}, },

View File

@@ -25,19 +25,23 @@
<!-- Settings in Fieldset --> <!-- Settings in Fieldset -->
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
<fieldset class="fieldset p-4 shadow rounded-box"> {% block system_prompt_section %}
<legend class="fieldset-legend">Registration</legend> <div id="system_prompt_section">
<label class="fieldset-label"> <fieldset class="fieldset p-4 shadow rounded-box">
{% block registration_status_input %} <legend class="fieldset-legend">System Prompts</legend>
<form hx-patch="/toggle-registrations" hx-swap="outerHTML" hx-trigger="change"> <div class="flex gap-2 flex-col sm:flex-row">
<input name="registration_open" type="checkbox" class="checkbox" {% if settings.registrations_enabled <button type="button" class="btn btn-primary btn-sm" hx-get="/edit-query-prompt" hx-target="#modal"
%}checked{% endif %} /> hx-swap="innerHTML">
</form> Edit Query Prompt
{% endblock %} </button>
Enable Registrations <button type="button" class="btn btn-primary btn-sm" hx-get="/edit-ingestion-prompt" hx-target="#modal"
</label> hx-swap="innerHTML">
<div id="registration-status" class="text-sm mt-2"></div> Edit Ingestion Prompt
</fieldset> </button>
</div>
</fieldset>
</div>
{% endblock %}
<fieldset class="fieldset p-4 shadow rounded-box"> <fieldset class="fieldset p-4 shadow rounded-box">
<legend class="fieldset-legend">AI Models</legend> <legend class="fieldset-legend">AI Models</legend>
@@ -76,23 +80,20 @@
{% endblock %} {% endblock %}
</fieldset> </fieldset>
{% block system_prompt_section %} <fieldset class="fieldset p-4 shadow rounded-box">
<div id="system_prompt_section"> <legend class="fieldset-legend">Registration</legend>
<fieldset class="fieldset p-4 shadow rounded-box"> <label class="flex gap-4 text-center">
<legend class="fieldset-legend">System Prompts</legend> {% block registration_status_input %}
<div class="flex gap-2 flex-col sm:flex-row"> <form hx-patch="/toggle-registrations" hx-swap="outerHTML" hx-trigger="change">
<button type="button" class="btn btn-primary btn-sm" hx-get="/edit-query-prompt" hx-target="#modal" <input name="registration_open" type="checkbox" class="checkbox" {% if settings.registrations_enabled
hx-swap="innerHTML"> %}checked{% endif %} />
Edit Query Prompt </form>
</button> {% endblock %}
<button type="button" class="btn btn-primary btn-sm" hx-get="/edit-ingestion-prompt" hx-target="#modal" Enable Registrations
hx-swap="innerHTML"> </label>
Edit Ingestion Prompt <div id="registration-status" class="text-sm mt-2"></div>
</button> </fieldset>
</div>
</fieldset>
</div>
{% endblock %}
</div> </div>
</main> </main>
{% endblock %} {% endblock %}

View File

@@ -0,0 +1,6 @@
{% extends "head_base.html" %}
{% block body %}
<div class="min-h-[100dvh] flex">
{% include "auth/signin_form.html" %}
</div>
{% endblock %}

View File

@@ -1,12 +1,10 @@
{% extends "head_base.html" %}
{% block body %}
<style> <style>
form.htmx-request { form.htmx-request {
opacity: 0.5; opacity: 0.5;
} }
</style> </style>
<div class="min-h-[100dvh] container mx-auto px-4 sm:px-0 sm:max-w-md flex justify-center flex-col"> <div class="flex justify-center grow container mx-auto px-4 sm:px-0 sm:max-w-md flex justify-center flex-col">
<h1 <h1
class="text-5xl sm:text-6xl py-4 pt-10 font-bold bg-linear-to-r from-primary to-secondary text-center text-transparent bg-clip-text"> class="text-5xl sm:text-6xl py-4 pt-10 font-bold bg-linear-to-r from-primary to-secondary text-center text-transparent bg-clip-text">
Minne Minne
@@ -51,5 +49,4 @@
Don't have an account? Don't have an account?
<a href="/signup" hx-boost="true" class="link link-primary">Sign up</a> <a href="/signup" hx-boost="true" class="link link-primary">Sign up</a>
</div> </div>
</div> </div>
{% endblock %}

View File

@@ -1,15 +0,0 @@
<div id="gdpr-banner" class="fixed inset-x-0 mx-auto card max-w-(--breakpoint-sm) mb-2 bg-base-200 bottom-0">
<div class="card-body items-center text-center">
<p class="text-sm text-base-content"> We use cookies to enhance your experience. By continuing to visit this site,
you agree to
our use cookies.
<a href="/documentation/privacy-policy" class="link link-primary">Learn more</a>
</p>
<div class="card-actions justify-end mt-2">
<button class="btn btn-outline btn-sm text-base-content" hx-post="/gdpr/deny" hx-target="#gdpr-banner"
hx-swap="outerHTML">Deny</button>
<button class="btn btn-primary btn-sm" hx-post="/gdpr/accept" hx-target="#gdpr-banner"
hx-swap="outerHTML">Accept</button>
</div>
</div>
</div>

View File

@@ -1,51 +0,0 @@
<main class="hero grow flex justify-center ">
<div class="container hero-content text-center">
<div class="space-y-8">
<!-- Hero Section -->
<h1
class="text-5xl sm:text-6xl py-4 pt-10 font-extrabold bg-linear-to-r from-primary to-secondary text-transparent bg-clip-text font-satoshi">
Your Second Brain, Built to Remember
<div class="text-xl font-light mt-4">
Minne <span class="text-base-content opacity-70">/ˈmɪnɛ/ [Swedish: memory]</span>
</div>
</h1>
<p class="text-xl ">
Capture, connect, and retrieve your knowledge effortlessly with Minne
</p>
<!-- Features Grid -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 my-12">
<div class="card bg-base-100 shadow-hover">
<div class="card-body items-center">
<div class="skeleton h-32 w-32 rounded-full"></div>
<h3 class="card-title text-xl">Easy Capture</h3>
<p>Save anything instantly - texts, links, images, and more</p>
</div>
</div>
<div class="card bg-base-100 shadow-hover">
<div class="card-body items-center">
<div class="skeleton h-32 w-32 rounded-full"></div>
<h3 class="card-title text-xl">Smart Analysis</h3>
<p>AI-powered content analysis and organization</p>
</div>
</div>
<div class="card bg-base-100 shadow-hover">
<div class="card-body items-center">
<div class="skeleton h-32 w-32 rounded-full"></div>
<h3 class="card-title text-xl">Knowledge Graph</h3>
<p>Visualize connections between your ideas</p>
</div>
</div>
</div>
<!-- CTA -->
<div class="space-y-4">
<div class="flex justify-center gap-4">
<a class="btn btn-primary btn-lg" hx-boost="true" href="/signup">Get Started</a>
<a class="btn btn-outline btn-lg" hx-boost="true" href="/documentation">Learn More</a>
</div>
</div>
</div>
</div>
</main>

View File

@@ -3,9 +3,6 @@
{% if user %} {% if user %}
{% include 'index/signed_in/base.html' %} {% include 'index/signed_in/base.html' %}
{% else %} {% else %}
{% include 'index/hero.html' %} {% include 'auth/signin_form.html' %}
{% if not gdpr_accepted %}
{% include "gdpr.html" %}
{% endif %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@@ -2,9 +2,10 @@
\[\] configs primarily get envs \[\] configs primarily get envs
\[\] filtering on categories \[\] filtering on categories
\[\] integrate assets folder in release build \[\] integrate assets folder in release build
\[x] integrate templates in release build \[\] make sure error messages render correctly
\[\] markdown rendering in client \[\] markdown rendering in client
\[\] openai api key in config \[\] openai api key in config
\[\] testing core functions
\[\] three js graph explorer \[\] three js graph explorer
\[\] three js vector explorer \[\] three js vector explorer
\[x\] add user_id to ingress objects \[x\] add user_id to ingress objects
@@ -16,6 +17,7 @@
\[x\] gdpr \[x\] gdpr
\[x\] html ingression \[x\] html ingression
\[x\] hx-redirect \[x\] hx-redirect
\[x\] integrate templates in release build
\[x\] ios shortcut generation \[x\] ios shortcut generation
\[x\] job queue \[x\] job queue
\[x\] link to ingressed urls or archives \[x\] link to ingressed urls or archives