Compare commits
3 Commits
fe03b17cb9
...
35932da2f7
| Author | SHA1 | Date | |
|---|---|---|---|
| 35932da2f7 | |||
|
34f48c2b3d
|
|||
|
66c4065059
|
@@ -14,6 +14,7 @@ pub const REFERENCE_SPLASHES: &[&str] = &[
|
|||||||
"memory palace",
|
"memory palace",
|
||||||
"take a break sometimes",
|
"take a break sometimes",
|
||||||
"segmentation fault (jk)",
|
"segmentation fault (jk)",
|
||||||
|
"over 100 lines of git history!",
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn envlogger_write_format(buf: &mut Formatter, rec: &Record) -> io::Result<()> {
|
pub fn envlogger_write_format(buf: &mut Formatter, rec: &Record) -> io::Result<()> {
|
||||||
|
|||||||
@@ -127,6 +127,18 @@ impl Quote {
|
|||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn get_random(conn: &Connection) -> Result<Option<Quote>, QuoteError> {
|
||||||
|
let id: Option<Uuid> = conn
|
||||||
|
.query_row("SELECT id FROM quotes ORDER BY RANDOM() LIMIT 1", (), |r| {
|
||||||
|
r.get(0)
|
||||||
|
})
|
||||||
|
.optional()?;
|
||||||
|
|
||||||
|
match id {
|
||||||
|
Some(id) => Ok(Some(Self::get_by_id(conn, id)?)),
|
||||||
|
None => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn get_chronological_offset(
|
pub fn get_chronological_offset(
|
||||||
conn: &Connection,
|
conn: &Connection,
|
||||||
offset: i64,
|
offset: i64,
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ pub async fn page(req: Request) -> Result<Markup, CompositeError> {
|
|||||||
Some(_) => Quote::get_newest(&conn)?,
|
Some(_) => Quote::get_newest(&conn)?,
|
||||||
None => Quote::get_newest_public(&conn)?,
|
None => Quote::get_newest_public(&conn)?,
|
||||||
};
|
};
|
||||||
|
let random_quote = match u {
|
||||||
|
Some(_) => Quote::get_random(&conn)?,
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
Ok(base(
|
Ok(base(
|
||||||
"Dashboard | Mnemosyne",
|
"Dashboard | Mnemosyne",
|
||||||
@@ -38,21 +42,26 @@ pub async fn page(req: Request) -> Result<Markup, CompositeError> {
|
|||||||
div class="mx-auto max-w-4xl px-2 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 {
|
||||||
p class="text-neutral-500 font-light mb-4" {
|
p class="text-neutral-500 font-light mb-4" {
|
||||||
"This just in! This quote was added "
|
"This just in! This quote was added "
|
||||||
(format_time_ago(q.get_creation_timestamp())) " ago."
|
(format_time_ago(q.get_creation_timestamp())) " ago."
|
||||||
}
|
}
|
||||||
div class="flex-1 [&>div]:h-full" {(quote(&q))}
|
div class="flex-1 [&>div]:h-full" {(quote(q))}
|
||||||
} @else {
|
} @else {
|
||||||
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" {
|
@if let Some(q) = random_quote {
|
||||||
// p {"Quote of the Day"} // maybe "Quote of the Moment" instead? idk, this algorithm needs to be crazy
|
div class="flex flex-col" {
|
||||||
// p class="text-neutral-500 font-light mb-4" {"This quote was voiced a year ago today."}
|
p {"Random Quote"}
|
||||||
// div class="flex-1 [&>div]:h-full" {(quote(&sample_quote_2()))}
|
p class="text-neutral-500 font-light mb-4" {
|
||||||
// }
|
"This quote was added "
|
||||||
|
(format_time_ago(q.get_creation_timestamp())) " ago."
|
||||||
|
}
|
||||||
|
div class="flex-1 [&>div]:h-full" {(quote(&q))}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
div class="mx-auto max-w-4xl px-2 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"}
|
||||||
|
|||||||
Reference in New Issue
Block a user