make dashboard only hold newest quote for now

This commit is contained in:
2026-04-08 02:21:10 +02:00
parent 386118de7d
commit 6906cec2c3

View File

@@ -1,13 +1,12 @@
use axum::extract::Request;
use chrono::{DateTime, Utc};
use maud::{Markup, PreEscaped, html};
use uuid::Uuid;
use crate::{
database::{self},
error::CompositeError,
persons::{Name, Person},
quotes::{Quote, QuoteLine},
persons::Person,
quotes::Quote,
tags::Tag,
users::{User, auth::UserAuthenticate},
web::{
@@ -33,7 +32,7 @@ pub async fn page(req: Request) -> Result<Markup, CompositeError> {
html!(
(nav(u.as_ref(), req.uri().path()))
div class="mx-auto max-w-4xl mt-4 grid grid-cols-1 sm:grid-cols-2 gap-4" {
div class="mx-auto max-w-4xl px-2 mt-4 grid grid-cols-1 --sm:grid-cols-2 gap-4" {
div class="flex flex-col" {
p {"Newest Quote"}
@if let Some(q) = newest_quote {
@@ -46,13 +45,13 @@ pub async fn page(req: Request) -> Result<Markup, CompositeError> {
p class="text-neutral-500 font-light mb-4" {"No quotes yet."}
}
}
div class="flex flex-col" {
p {"Quote of the Day"}
p class="text-neutral-500 font-light mb-4" {"This quote was voiced a year ago today."}
div class="flex-1 [&>div]:h-full" {(quote(&sample_quote_2()))}
}
// div class="flex flex-col" {
// p {"Quote of the Day"} // maybe "Quote of the Moment" instead? idk, this algorithm needs to be crazy
// p class="text-neutral-500 font-light mb-4" {"This quote was voiced a year ago today."}
// div class="flex-1 [&>div]:h-full" {(quote(&sample_quote_2()))}
// }
}
div class="mx-auto max-w-4xl mt-4" {
div class="mx-auto max-w-4xl px-2 mt-4" {
p class="mb-2" {"Quick access"}
div class="flex gap-4" {
@for (title, url, icon) in LINKS {
@@ -66,7 +65,7 @@ pub async fn page(req: Request) -> Result<Markup, CompositeError> {
}
}
div class="mx-auto max-w-4xl mt-4 flex flex-row gap-2" {
div class="mx-auto max-w-4xl px-2 mt-4 flex flex-row gap-2" {
(chip(html!({
@match Quote::total_count(&conn) {
Ok(count) => {(count) " QUOTES TOTAL"},
@@ -98,41 +97,6 @@ pub async fn page(req: Request) -> Result<Markup, CompositeError> {
))
}
fn sample_quote_2() -> Quote {
Quote {
id: Uuid::now_v7(),
public: true,
location: Some(String::from("Discord VC")),
context: Some(String::from("O narysowanej dziewczynie")),
created_by: Uuid::max(),
timestamp: DateTime::from(Utc::now()),
lines: vec![
QuoteLine {
id: Uuid::now_v7(),
content: String::from("Czy tu proporcje są zachowane?"),
attribution: Name {
id: Uuid::now_v7(),
created_by: Uuid::max(),
person_id: Uuid::now_v7(),
is_primary: true,
name: String::from("Adam"),
},
},
QuoteLine {
id: Uuid::now_v7(),
content: String::from("Adam, ona nie ma kolan."),
attribution: Name {
id: Uuid::nil(),
created_by: Uuid::max(),
person_id: Uuid::now_v7(),
is_primary: true,
name: String::from("Mollin"),
},
},
],
}
}
fn format_time_ago(dt: DateTime<Utc>) -> String {
let secs = Utc::now().signed_duration_since(dt).num_seconds();
match secs {