make dashboard only hold newest quote for now
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
use axum::extract::Request;
|
use axum::extract::Request;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use maud::{Markup, PreEscaped, html};
|
use maud::{Markup, PreEscaped, html};
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{self},
|
database::{self},
|
||||||
error::CompositeError,
|
error::CompositeError,
|
||||||
persons::{Name, Person},
|
persons::Person,
|
||||||
quotes::{Quote, QuoteLine},
|
quotes::Quote,
|
||||||
tags::Tag,
|
tags::Tag,
|
||||||
users::{User, auth::UserAuthenticate},
|
users::{User, auth::UserAuthenticate},
|
||||||
web::{
|
web::{
|
||||||
@@ -33,7 +32,7 @@ pub async fn page(req: Request) -> Result<Markup, CompositeError> {
|
|||||||
html!(
|
html!(
|
||||||
(nav(u.as_ref(), req.uri().path()))
|
(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" {
|
div class="flex flex-col" {
|
||||||
p {"Newest Quote"}
|
p {"Newest Quote"}
|
||||||
@if let Some(q) = 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."}
|
p class="text-neutral-500 font-light mb-4" {"No quotes yet."}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
div class="flex flex-col" {
|
// div class="flex flex-col" {
|
||||||
p {"Quote of the Day"}
|
// 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."}
|
// 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-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"}
|
p class="mb-2" {"Quick access"}
|
||||||
div class="flex gap-4" {
|
div class="flex gap-4" {
|
||||||
@for (title, url, icon) in LINKS {
|
@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!({
|
(chip(html!({
|
||||||
@match Quote::total_count(&conn) {
|
@match Quote::total_count(&conn) {
|
||||||
Ok(count) => {(count) " QUOTES TOTAL"},
|
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 {
|
fn format_time_ago(dt: DateTime<Utc>) -> String {
|
||||||
let secs = Utc::now().signed_duration_since(dt).num_seconds();
|
let secs = Utc::now().signed_duration_since(dt).num_seconds();
|
||||||
match secs {
|
match secs {
|
||||||
|
|||||||
Reference in New Issue
Block a user