mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-27 03:08:41 +02:00
refactoring route names
This commit is contained in:
121
assets/style.css
121
assets/style.css
@@ -877,57 +877,6 @@ html {
|
|||||||
content: var(--tw-content);
|
content: var(--tw-content);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
border-radius: var(--rounded-box, 1rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card:focus {
|
|
||||||
outline: 2px solid transparent;
|
|
||||||
outline-offset: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card figure {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card.image-full {
|
|
||||||
display: grid;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card.image-full:before {
|
|
||||||
position: relative;
|
|
||||||
content: "";
|
|
||||||
z-index: 10;
|
|
||||||
border-radius: var(--rounded-box, 1rem);
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity)));
|
|
||||||
opacity: 0.75;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card.image-full:before,
|
|
||||||
.card.image-full > * {
|
|
||||||
grid-column-start: 1;
|
|
||||||
grid-row-start: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card.image-full > figure img {
|
|
||||||
height: 100%;
|
|
||||||
-o-object-fit: cover;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card.image-full > .card-body {
|
|
||||||
position: relative;
|
|
||||||
z-index: 20;
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: var(--fallback-nc,oklch(var(--nc)/var(--tw-text-opacity)));
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat {
|
.chat {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
@@ -1215,34 +1164,6 @@ html {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
|
||||||
display: grid;
|
|
||||||
width: 100%;
|
|
||||||
grid-auto-flow: row;
|
|
||||||
place-items: start;
|
|
||||||
-moz-column-gap: 1rem;
|
|
||||||
column-gap: 1rem;
|
|
||||||
row-gap: 2.5rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
line-height: 1.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer > * {
|
|
||||||
display: grid;
|
|
||||||
place-items: start;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 48rem) {
|
|
||||||
.footer {
|
|
||||||
grid-auto-flow: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-center {
|
|
||||||
grid-auto-flow: row dense;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-control {
|
.form-control {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -1579,44 +1500,6 @@ html {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.card :where(figure:first-child) {
|
|
||||||
overflow: hidden;
|
|
||||||
border-start-start-radius: inherit;
|
|
||||||
border-start-end-radius: inherit;
|
|
||||||
border-end-start-radius: unset;
|
|
||||||
border-end-end-radius: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card :where(figure:last-child) {
|
|
||||||
overflow: hidden;
|
|
||||||
border-start-start-radius: unset;
|
|
||||||
border-start-end-radius: unset;
|
|
||||||
border-end-start-radius: inherit;
|
|
||||||
border-end-end-radius: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card:focus-visible {
|
|
||||||
outline: 2px solid currentColor;
|
|
||||||
outline-offset: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card.bordered {
|
|
||||||
border-width: 1px;
|
|
||||||
--tw-border-opacity: 1;
|
|
||||||
border-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity)));
|
|
||||||
}
|
|
||||||
|
|
||||||
.card.compact .card-body {
|
|
||||||
padding: 1rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
line-height: 1.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card.image-full :where(figure) {
|
|
||||||
overflow: hidden;
|
|
||||||
border-radius: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox:focus {
|
.checkbox:focus {
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
@@ -2178,10 +2061,6 @@ html {
|
|||||||
border-top-right-radius: 0px;
|
border-top-right-radius: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.border {
|
|
||||||
border-width: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-transparent {
|
.border-transparent {
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ use zettle_db::{
|
|||||||
queue_length::queue_length_handler,
|
queue_length::queue_length_handler,
|
||||||
},
|
},
|
||||||
html::{
|
html::{
|
||||||
auth::{show_signup_form, signup_handler},
|
|
||||||
index::index_handler,
|
index::index_handler,
|
||||||
search_result::search_result_handler,
|
search_result::search_result_handler,
|
||||||
|
signup::{process_signup_and_show_verification, show_signup_form},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AppState,
|
AppState,
|
||||||
@@ -147,7 +147,10 @@ fn html_routes(
|
|||||||
Router::new()
|
Router::new()
|
||||||
.route("/", get(index_handler))
|
.route("/", get(index_handler))
|
||||||
.route("/search", get(search_result_handler))
|
.route("/search", get(search_result_handler))
|
||||||
.route("/signup", get(show_signup_form).post(signup_handler))
|
.route(
|
||||||
|
"/signup",
|
||||||
|
get(show_signup_form).post(process_signup_and_show_verification),
|
||||||
|
)
|
||||||
.nest_service("/assets", ServeDir::new("assets/"))
|
.nest_service("/assets", ServeDir::new("assets/"))
|
||||||
.layer(
|
.layer(
|
||||||
AuthSessionLayer::<User, String, SessionSurrealPool<Any>, Surreal<Any>>::new(Some(
|
AuthSessionLayer::<User, String, SessionSurrealPool<Any>, Surreal<Any>>::new(Some(
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ use std::sync::Arc;
|
|||||||
use axum::response::Html;
|
use axum::response::Html;
|
||||||
use minijinja_autoreload::AutoReloader;
|
use minijinja_autoreload::AutoReloader;
|
||||||
|
|
||||||
pub mod auth;
|
|
||||||
pub mod index;
|
pub mod index;
|
||||||
pub mod search_result;
|
pub mod search_result;
|
||||||
|
pub mod signin;
|
||||||
|
pub mod signup;
|
||||||
|
|
||||||
pub trait PageData {
|
pub trait PageData {
|
||||||
fn template_name() -> &'static str;
|
fn template_name() -> &'static str;
|
||||||
|
|||||||
56
src/server/routes/html/signin.rs
Normal file
56
src/server/routes/html/signin.rs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
use axum::{
|
||||||
|
extract::State,
|
||||||
|
response::{IntoResponse, Redirect},
|
||||||
|
Form,
|
||||||
|
};
|
||||||
|
use axum_htmx::HxBoosted;
|
||||||
|
use axum_session_auth::AuthSession;
|
||||||
|
use axum_session_surreal::SessionSurrealPool;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use surrealdb::{engine::any::Any, Surreal};
|
||||||
|
|
||||||
|
use crate::{error::ApiError, server::AppState, storage::types::user::User};
|
||||||
|
|
||||||
|
use super::{render_block, render_template};
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub struct SignupParams {
|
||||||
|
pub email: String,
|
||||||
|
pub password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct PageData {
|
||||||
|
// name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn show_login_form(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
|
||||||
|
HxBoosted(boosted): HxBoosted,
|
||||||
|
) -> Result<impl IntoResponse, ApiError> {
|
||||||
|
if auth.is_authenticated() {
|
||||||
|
return Ok(Redirect::to("/").into_response());
|
||||||
|
}
|
||||||
|
let output = match boosted {
|
||||||
|
true => render_block(
|
||||||
|
"auth/signup_form.html",
|
||||||
|
"body",
|
||||||
|
PageData {},
|
||||||
|
state.templates,
|
||||||
|
)?,
|
||||||
|
false => render_template("auth/signup_form.html", PageData {}, state.templates)?,
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(output.into_response())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn authenticate_user(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
|
||||||
|
Form(form): Form<SignupParams>,
|
||||||
|
) -> Result<impl IntoResponse, ApiError> {
|
||||||
|
let user = User::create_new(form.email, form.password, &state.surreal_db_client).await?;
|
||||||
|
auth.login_user(user.id);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -45,7 +45,7 @@ pub async fn show_signup_form(
|
|||||||
Ok(output.into_response())
|
Ok(output.into_response())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn signup_handler(
|
pub async fn process_signup_and_show_verification(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
|
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
|
||||||
Form(form): Form<SignupParams>,
|
Form(form): Form<SignupParams>,
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
content: [
|
content: [
|
||||||
'./templates/**/*'
|
'./templates/**/*',
|
||||||
|
'!./templates/email/**/*'
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {},
|
extend: {},
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
</label>
|
</label>
|
||||||
<input type="password" name="password" placeholder="Create a password" class="input input-bordered w-full"
|
<input type="password" name="password" placeholder="Create a password" class="input input-bordered w-full"
|
||||||
required minlength="8" />
|
required minlength="8" />
|
||||||
<input type="password" name="confirm_password" placeholder="Confirm your password"
|
|
||||||
class="input mt-2 input-bordered w-full" required minlength="8" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-control mt-6">
|
<div class="form-control mt-6">
|
||||||
|
|||||||
Reference in New Issue
Block a user