Poems render their titles in a separate div, creation dates added and displayed.

This commit is contained in:
Ada Werefox 2023-04-08 12:40:57 -05:00
parent 202979973f
commit bcf1b36a6b
34 changed files with 102 additions and 60 deletions

View File

@ -1,3 +1,7 @@
fn main() { use void_be::web_app_backend;
println!("Hello, world!");
#[rocket::main]
async fn main() -> Result<(), rocket::Error> {
let _rocket = web_app_backend::build_rocket().await.launch().await;
Ok(())
} }

13
templates/index.html.hbs Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>{{app_title}}</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="UTF-8" />
{{{style_include}}}
</head>
<body>
<div id="main">{{{test}}}</div>
</body>
</html>

View File

@ -1,14 +1,40 @@
pub fn add(left: usize, right: usize) -> usize {
left + right //! # Rust Letter Backend
//!
//! `rust_letter_be` handles the backend execution using Rocket.
#[macro_use]
extern crate rocket;
/// A module that handles the backend for the site.
pub mod web_app_backend {
use rocket::fs::FileServer;
use rocket::{Rocket, Build};
use rocket_dyn_templates::{Template, context};
use void_fe::void_app::{self, VirtualDom};
#[get("/")]
async fn index() -> Template {
let mut vdom = VirtualDom::new(void_app::App);
let _ = vdom.rebuild();
let output = dioxus_ssr::render(&vdom);
Template::render(
"index",
context! {
app_title: "A Letter to the Void",
style_include: "<link href=/styles/tailwind.min.css rel=stylesheet />",
test: &output
},
)
} }
#[cfg(test)] /// This runs `rocket::build()` with the needed mounts and routes.
mod tests { pub async fn build_rocket() -> Rocket<Build> {
use super::*; rocket::build()
.mount("/images", FileServer::from("public/images"))
#[test] .mount("/styles", FileServer::from("public/styles"))
fn it_works() { .mount("/fonts", FileServer::from("public/fonts"))
let result = add(2, 2); .mount("/", routes![index]).attach(Template::fairing())
assert_eq!(result, 4);
} }
} }

View File

@ -1,5 +1,4 @@
# im on repeat # im on repeat
[Audio reading](https://cloud.werefox.dev/s/dq5ccm5QqmMF4GB) [Audio reading](https://cloud.werefox.dev/s/dq5ccm5QqmMF4GB)
Death is like a memory. Ceaseless, and comforting\ Death is like a memory. Ceaseless, and comforting\

View File

@ -1,5 +1,4 @@
# Iced Coffee # Iced Coffee
[Listen to the song on Soundcloud](https://soundcloud.com/alexis-werefox/iced-coffee/s-5SgBwPrLwyR) [Listen to the song on Soundcloud](https://soundcloud.com/alexis-werefox/iced-coffee/s-5SgBwPrLwyR)
*Iced coffee on a cold Winter's day* \ *Iced coffee on a cold Winter's day* \

View File

@ -1,5 +1,4 @@
# Sweetheart, Sweet Tea # Sweetheart, Sweet Tea
Do you remember? \ Do you remember? \
The first time that we had met \ The first time that we had met \
Oh, I'm sure I don't regret that memory \ Oh, I'm sure I don't regret that memory \

View File

@ -1,5 +1,4 @@
# Writing Myself Into My Own Grave (“Ill never be happy”) # Writing Myself Into My Own Grave (“Ill never be happy”)
*You should keep your distance*\ *You should keep your distance*\
*You should never stay*\ *You should never stay*\
*You should learn your lesson*\ *You should learn your lesson*\

View File

@ -1,5 +1,4 @@
# Introductions # Introductions
Hi! I'm Alice, and um... Uh.\ Hi! I'm Alice, and um... Uh.\
I have something I wanna say, I guess... I have something I wanna say, I guess...

View File

@ -1,5 +1,4 @@
# Molded Hearts and Melted Love # Molded Hearts and Melted Love
*Authors Note: This song/poem has heavy overtones of relationship abuse. Please be aware of that before you read.* *Authors Note: This song/poem has heavy overtones of relationship abuse. Please be aware of that before you read.*
Ive never been the one to think Im waiting on their time\ Ive never been the one to think Im waiting on their time\

View File

@ -1,5 +1,4 @@
# Poetry to the Void # Poetry to the Void
*Author's note: here's a bit of freeform poetry I wrote a while back that I thought I'd share. I know it doesn't flow super well, but I'm proud of it, and I think it's good sometimes to write stuff that's a bit off beat when it's meaningful to do so* *Author's note: here's a bit of freeform poetry I wrote a while back that I thought I'd share. I know it doesn't flow super well, but I'm proud of it, and I think it's good sometimes to write stuff that's a bit off beat when it's meaningful to do so*
Empty hearts and empty sheets \ Empty hearts and empty sheets \

View File

@ -1,5 +1,4 @@
# A Moment's Rest at a Peaceful Shore # A Moment's Rest at a Peaceful Shore
The wind calms, the storm in my mind settles\ The wind calms, the storm in my mind settles\
The static pervading off the edges of my mind's perspective finally begins to focus itself into a clearer darkness The static pervading off the edges of my mind's perspective finally begins to focus itself into a clearer darkness

View File

@ -1,5 +1,4 @@
# Black Rose, Gray Skies # Black Rose, Gray Skies
**[Intro]**\ **[Intro]**\
Black rose, thorns sharp and trapped inside a clear vessel\ Black rose, thorns sharp and trapped inside a clear vessel\
Petals falling, won't you please come and save this wilting weed\ Petals falling, won't you please come and save this wilting weed\

View File

@ -1,5 +1,4 @@
# Bittersweet, Cheers # Bittersweet, Cheers
**[Intro]**\ **[Intro]**\
*things are gonna change, yeah*\ *things are gonna change, yeah*\
*things are gonna change*\ *things are gonna change*\

View File

@ -1,5 +1,4 @@
# Notification High # Notification High
**[Chorus]**\ **[Chorus]**\
*I'm hot, I'm cool, I'm the best you've ever seen*\ *I'm hot, I'm cool, I'm the best you've ever seen*\
*not my ego, not a brag, just the facts up on the screen*\ *not my ego, not a brag, just the facts up on the screen*\

View File

@ -1,5 +1,4 @@
# Echoes # Echoes
**[Verse 1]** **[Verse 1]**
*Echoes*\ *Echoes*\

View File

@ -1,5 +1,4 @@
# "You'll Grow Out Of This" # "You'll Grow Out Of This"
**[Verse 1]** **[Verse 1]**
*I write songs I'll never sing*\ *I write songs I'll never sing*\

View File

@ -1,5 +1,4 @@
# Foxes Are Predators # Foxes Are Predators
*I used to think about the monsters underneath my bed*\ *I used to think about the monsters underneath my bed*\
*Hiding in the darkness, now they're stuck inside my head*\ *Hiding in the darkness, now they're stuck inside my head*\
*Why does everything I write feel like a call for help?*\ *Why does everything I write feel like a call for help?*\

View File

@ -1,5 +1,4 @@
# Missing The Mark # Missing The Mark
*Lately I've been thinking 'bout how miserable I've been*\ *Lately I've been thinking 'bout how miserable I've been*\
*Sadness never comforts me, but it's been my best friend*\ *Sadness never comforts me, but it's been my best friend*\
*And I could write more lines 'bout how I wish I could see*\ *And I could write more lines 'bout how I wish I could see*\

View File

@ -1,5 +1,4 @@
# Support Class # Support Class
*Words like knives carving thoughts into the pages of my life*\ *Words like knives carving thoughts into the pages of my life*\
*Like scattered scraps of paper torn and fluttering in the wind*\ *Like scattered scraps of paper torn and fluttering in the wind*\
*So too am I temporary and fleeting* *So too am I temporary and fleeting*

View File

@ -1,5 +1,4 @@
# I Wish I Wore My Garters # I Wish I Wore My Garters
*I hate my bedroom door*\ *I hate my bedroom door*\
*I have to try a couple times to push it open*\ *I have to try a couple times to push it open*\
*I hate to feel like I'm confined*\ *I hate to feel like I'm confined*\

View File

@ -1,5 +1,4 @@
# Since When Did Winter End # Since When Did Winter End
*Im a mess*\ *Im a mess*\
*A disaster, but I see it in a better light now than I did before*\ *A disaster, but I see it in a better light now than I did before*\
*Im a mess*\ *Im a mess*\

View File

@ -1,5 +1,4 @@
# She's Not Who She Used To Be # She's Not Who She Used To Be
*She looks in the mirror and likes what she sees*\ *She looks in the mirror and likes what she sees*\
*It's obvious she's not who she used to be*\ *It's obvious she's not who she used to be*\
*Thought she had her life found out by 14*\ *Thought she had her life found out by 14*\

View File

@ -1,5 +1,4 @@
# Probably Bad For You # Probably Bad For You
*When did all the lights begin to fade away?*\ *When did all the lights begin to fade away?*\
*I see them now, I see them now*\ *I see them now, I see them now*\
*When did you decide to leave me hurt this way?*\ *When did you decide to leave me hurt this way?*\

View File

@ -1,5 +1,4 @@
# Filtered Thoughts # Filtered Thoughts
*Sometimes I wonder if I could write to save my life*\ *Sometimes I wonder if I could write to save my life*\
*Sometimes I wonder if all the effort's worth the strife*\ *Sometimes I wonder if all the effort's worth the strife*\
*I've been down this road before and now the twists are turns are pleasant*\ *I've been down this road before and now the twists are turns are pleasant*\

View File

@ -1,5 +1,4 @@
# I can never see past next week # I can never see past next week
*A moment of peace in a busy world of busy people*\ *A moment of peace in a busy world of busy people*\
*Staring out the window, the view of the balcony just blissfully capturing what my heart feels*\ *Staring out the window, the view of the balcony just blissfully capturing what my heart feels*\
*Though the loving embrace of the morning sun shines on me again, I can't help but let those thoughts intrude*\ *Though the loving embrace of the morning sun shines on me again, I can't help but let those thoughts intrude*\

View File

@ -1,5 +1,4 @@
# 27 # 27
**27**\ **27**\
*I used to think that day was just a far off dream for me*\ *I used to think that day was just a far off dream for me*\
*Dreading when I wake because I can't see past next week*\ *Dreading when I wake because I can't see past next week*\

View File

@ -1,5 +1,4 @@
# They Said I Could Be Anything When I Grew Up, But I Was Already A Girl (I'm Living Proof) # They Said I Could Be Anything When I Grew Up, But I Was Already A Girl (I'm Living Proof)
*I still can't see past next week\ *I still can't see past next week\
It feels like an eternity and I\ It feels like an eternity and I\
Can't keep waiting up\ Can't keep waiting up\

View File

@ -1,5 +1,4 @@
# Drop Kicked From Senselessness # Drop Kicked From Senselessness
*Soft, muttered frequencies on the periphery of my subconscious*\ *Soft, muttered frequencies on the periphery of my subconscious*\
*A tune I used to hear that flickers its presence*\ *A tune I used to hear that flickers its presence*\
*Giving me leverage of which to confine myself within the most secluded of spaces*\ *Giving me leverage of which to confine myself within the most secluded of spaces*\

View File

@ -1,5 +1,4 @@
# What do you mean you're not gay, you fucking dated me # What do you mean you're not gay, you fucking dated me
*Waiting on you to blink me to life*\ *Waiting on you to blink me to life*\
*She said I'm her backup [gal] in the end*\ *She said I'm her backup [gal] in the end*\
*I've never been one to pull away*\ *I've never been one to pull away*\

View File

@ -1,5 +1,4 @@
# Senseless Murmurs of the Estranged (~~The~~ Last Night) # Senseless Murmurs of the Estranged (~~The~~ Last Night)
*Slithering fangs and pointy tails*\ *Slithering fangs and pointy tails*\
*Tell me if I'm not feeling well*\ *Tell me if I'm not feeling well*\
*My mindscape's hazard lights sing symphonies that plead me not to crash*\ *My mindscape's hazard lights sing symphonies that plead me not to crash*\

View File

@ -1,4 +1,4 @@
let m,p,ls,lss,sp,d,t,c,s,sl,op,i,e,z,index,value,ns,n,ptr,many,text,event_name,len,root,id,field,bubbles,tmpl_id;const evt = [];const attr = [];const ns_cache = []; let m,p,ls,lss,sp,d,t,c,s,sl,op,i,e,z,text,ptr,n,field,value,root,len,tmpl_id,index,many,id,event_name,bubbles,ns;const evt = [];const attr = [];const ns_cache = [];
class ListenerMap { class ListenerMap {
constructor(root) { constructor(root) {
// bubbling events can listen at the root element // bubbling events can listen at the root element

View File

@ -7,8 +7,6 @@
/// A module that handles the functions needed /// A module that handles the functions needed
/// to render the site. /// to render the site.
pub mod void_app { pub mod void_app {
use std::borrow::Borrow;
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types // import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
pub use dioxus::prelude::*; pub use dioxus::prelude::*;
use rust_embed::RustEmbed; use rust_embed::RustEmbed;
@ -18,9 +16,22 @@ pub mod void_app {
// pub poems: Vec<String>, // pub poems: Vec<String>,
// } // }
#[derive(PartialEq, Props)]
struct PoemData {
title: String,
content: String,
creation_date: String,
}
#[derive(PartialEq, Props)]
struct PoemTitle {
title: String,
}
#[derive(PartialEq, Props)] #[derive(PartialEq, Props)]
struct PoemContent { struct PoemContent {
content: String, content: String,
creation_date: String,
} }
#[derive(RustEmbed)] #[derive(RustEmbed)]
#[folder = "data/poems"] #[folder = "data/poems"]
@ -32,20 +43,42 @@ pub mod void_app {
div { class: "min-h-screen font-nerd bg-alice-werefox-grey-light dark:bg-alice-werefox-grey", div { class: "min-h-screen font-nerd bg-alice-werefox-grey-light dark:bg-alice-werefox-grey",
div { class: "container space-y-4 mx-auto p-4", div { class: "container space-y-4 mx-auto p-4",
Poems::iter().map(|p| { Poems::iter().map(|p| {
let creation_date = String::from(String::from("<br>Written on: ") + p.split("_").next().unwrap());
let poem_content = Poems::get(&p).expect("Found poem {&p:?}"); let poem_content = Poems::get(&p).expect("Found poem {&p:?}");
let poem_to_str = std::str::from_utf8(poem_content.data.as_ref()).expect("Content is valid UT8."); let mut poem_to_str = std::str::from_utf8(poem_content.data.as_ref()).expect("Title is valid UT8.").lines();
let poem_to_html_string = markdown::to_html(poem_to_str); let poem_title = poem_to_str.next().unwrap();
rsx!{ MakePoem{ content: poem_to_html_string } } let poem_content = poem_to_str.into_iter().collect::<Vec<&str>>().join("\n");
let poem_title_to_html_string = markdown::to_html(poem_title);
let poem_content_to_html_string = markdown::to_html(poem_content.as_str());
rsx!{ MakePoem{ title: poem_title_to_html_string, content: poem_content_to_html_string, creation_date: creation_date } }
}) })
} }
} }
)) ))
} }
#[cfg(any(target_family = "unix", target_family = "windows"))]
fn RenderPoemTitle(cx: Scope<PoemTitle>) -> Element {
cx.render(rsx!(
span { class: "mx-auto max-w-fit flex justify-center bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4",
"{cx.props.title}"
}
))
}
#[cfg(target_family = "wasm")]
fn RenderPoemTitle(cx: Scope<PoemTitle>) -> Element {
cx.render(rsx!(
p { class: "mx-auto max-w-fit flex justify-center bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4",
dangerous_inner_html: "{cx.props.title}",
}
))
}
#[cfg(any(target_family = "unix", target_family = "windows"))] #[cfg(any(target_family = "unix", target_family = "windows"))]
fn RenderPoemElement(cx: Scope<PoemContent>) -> Element { fn RenderPoemElement(cx: Scope<PoemContent>) -> Element {
cx.render(rsx!( cx.render(rsx!(
div { class: "font-nerd flex flex-col space-y-4 mx-4 py-4", "{cx.props.content}" } div { class: "font-nerd flex flex-col space-y-4 mx-4 py-4", "{cx.props.content}{cx.props.creation_date}" }
)) ))
} }
@ -53,21 +86,19 @@ pub mod void_app {
fn RenderPoemElement(cx: Scope<PoemContent>) -> Element { fn RenderPoemElement(cx: Scope<PoemContent>) -> Element {
cx.render(rsx!(div { cx.render(rsx!(div {
class: "font-nerd flex flex-col space-y-4 mx-4 py-4", class: "font-nerd flex flex-col space-y-4 mx-4 py-4",
dangerous_inner_html: "{cx.props.content}" dangerous_inner_html: "{cx.props.content}{cx.props.creation_date}"
})) }))
} }
fn MakePoem(cx: Scope<PoemContent>) -> Element { fn MakePoem(cx: Scope<PoemData>) -> Element {
cx.render(rsx!( cx.render(rsx!(
div { class: "flex-col space-y-4", div { class: "flex-col space-y-4",
p { class: "mx-auto max-w-fit flex justify-center bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4", RenderPoemTitle { title: cx.props.title.clone() }
"POEM NAME HERE"
}
details { class: "mx-auto max-w-fit space-y-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4", details { class: "mx-auto max-w-fit space-y-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4",
summary { class: "flex justify-center border-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4", summary { class: "flex justify-center border-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4",
"Open" "Open"
} }
RenderPoemElement { content: cx.props.content.clone() } RenderPoemElement { content: cx.props.content.clone(), creation_date: cx.props.creation_date.clone() }
} }
} }
)) ))

View File

@ -8,10 +8,5 @@ fn main() {
wasm_logger::init(wasm_logger::Config::default()); wasm_logger::init(wasm_logger::Config::default());
console_error_panic_hook::set_once(); console_error_panic_hook::set_once();
// let mut content = Vec::new();
// for f in Poems::iter() {
// content.push(markdown::to_html(&f));
// }
dioxus_web::launch(void_app::App); dioxus_web::launch(void_app::App);
} }