Poems render their titles in a separate div, creation dates added and displayed.
This commit is contained in:
parent
202979973f
commit
bcf1b36a6b
@ -1,3 +1,7 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use void_be::web_app_backend;
|
||||
|
||||
#[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
13
templates/index.html.hbs
Normal 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>
|
@ -1,14 +1,40 @@
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
//! # Rust Letter Backend
|
||||
//!
|
||||
//! `rust_letter_be` handles the backend execution using Rocket.
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
#[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
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// This runs `rocket::build()` with the needed mounts and routes.
|
||||
pub async fn build_rocket() -> Rocket<Build> {
|
||||
rocket::build()
|
||||
.mount("/images", FileServer::from("public/images"))
|
||||
.mount("/styles", FileServer::from("public/styles"))
|
||||
.mount("/fonts", FileServer::from("public/fonts"))
|
||||
.mount("/", routes![index]).attach(Template::fairing())
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
# im on repeat
|
||||
|
||||
[Audio reading](https://cloud.werefox.dev/s/dq5ccm5QqmMF4GB)
|
||||
|
||||
Death is like a memory. Ceaseless, and comforting\
|
@ -1,5 +1,4 @@
|
||||
# Iced Coffee
|
||||
|
||||
[Listen to the song on Soundcloud](https://soundcloud.com/alexis-werefox/iced-coffee/s-5SgBwPrLwyR)
|
||||
|
||||
*Iced coffee on a cold Winter's day* \
|
@ -1,5 +1,4 @@
|
||||
# Sweetheart, Sweet Tea
|
||||
|
||||
Do you remember? \
|
||||
The first time that we had met \
|
||||
Oh, I'm sure I don't regret that memory \
|
@ -1,5 +1,4 @@
|
||||
# Writing Myself Into My Own Grave (“I’ll never be happy”)
|
||||
|
||||
*You should keep your distance*\
|
||||
*You should never stay*\
|
||||
*You should learn your lesson*\
|
@ -1,5 +1,4 @@
|
||||
# Introductions
|
||||
|
||||
Hi! I'm Alice, and um... Uh.\
|
||||
I have something I wanna say, I guess...
|
||||
|
@ -1,5 +1,4 @@
|
||||
# Molded Hearts and Melted Love
|
||||
|
||||
*Author’s Note: This song/poem has heavy overtones of relationship abuse. Please be aware of that before you read.*
|
||||
|
||||
I’ve never been the one to think I’m waiting on their time\
|
@ -1,5 +1,4 @@
|
||||
# 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*
|
||||
|
||||
Empty hearts and empty sheets \
|
@ -1,5 +1,4 @@
|
||||
# A Moment's Rest at a Peaceful Shore
|
||||
|
||||
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
|
||||
|
@ -1,5 +1,4 @@
|
||||
# Black Rose, Gray Skies
|
||||
|
||||
**[Intro]**\
|
||||
Black rose, thorns sharp and trapped inside a clear vessel\
|
||||
Petals falling, won't you please come and save this wilting weed\
|
@ -1,5 +1,4 @@
|
||||
# Bittersweet, Cheers
|
||||
|
||||
**[Intro]**\
|
||||
*things are gonna change, yeah*\
|
||||
*things are gonna change*\
|
@ -1,5 +1,4 @@
|
||||
# Notification High
|
||||
|
||||
**[Chorus]**\
|
||||
*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*\
|
@ -1,5 +1,4 @@
|
||||
# Echoes
|
||||
|
||||
**[Verse 1]**
|
||||
|
||||
*Echoes*\
|
@ -1,5 +1,4 @@
|
||||
# "You'll Grow Out Of This"
|
||||
|
||||
**[Verse 1]**
|
||||
|
||||
*I write songs I'll never sing*\
|
@ -1,5 +1,4 @@
|
||||
# Foxes Are Predators
|
||||
|
||||
*I used to think about the monsters underneath my bed*\
|
||||
*Hiding in the darkness, now they're stuck inside my head*\
|
||||
*Why does everything I write feel like a call for help?*\
|
@ -1,5 +1,4 @@
|
||||
# Missing The Mark
|
||||
|
||||
*Lately I've been thinking 'bout how miserable I've been*\
|
||||
*Sadness never comforts me, but it's been my best friend*\
|
||||
*And I could write more lines 'bout how I wish I could see*\
|
@ -1,5 +1,4 @@
|
||||
# Support Class
|
||||
|
||||
*Words like knives carving thoughts into the pages of my life*\
|
||||
*Like scattered scraps of paper torn and fluttering in the wind*\
|
||||
*So too am I temporary and fleeting*
|
@ -1,5 +1,4 @@
|
||||
# I Wish I Wore My Garters
|
||||
|
||||
*I hate my bedroom door*\
|
||||
*I have to try a couple times to push it open*\
|
||||
*I hate to feel like I'm confined*\
|
@ -1,5 +1,4 @@
|
||||
# Since When Did Winter End
|
||||
|
||||
*I’m a mess*\
|
||||
*A disaster, but I see it in a better light now than I did before*\
|
||||
*I’m a mess*\
|
@ -1,5 +1,4 @@
|
||||
# She's Not Who She Used To Be
|
||||
|
||||
*She looks in the mirror and likes what she sees*\
|
||||
*It's obvious she's not who she used to be*\
|
||||
*Thought she had her life found out by 14*\
|
@ -1,5 +1,4 @@
|
||||
# Probably Bad For You
|
||||
|
||||
*When did all the lights begin to fade away?*\
|
||||
*I see them now, I see them now*\
|
||||
*When did you decide to leave me hurt this way?*\
|
@ -1,5 +1,4 @@
|
||||
# Filtered Thoughts
|
||||
|
||||
*Sometimes I wonder if I could write to save my life*\
|
||||
*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*\
|
@ -1,5 +1,4 @@
|
||||
# I can never see past next week
|
||||
|
||||
*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*\
|
||||
*Though the loving embrace of the morning sun shines on me again, I can't help but let those thoughts intrude*\
|
@ -1,5 +1,4 @@
|
||||
# 27
|
||||
|
||||
**27**\
|
||||
*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*\
|
@ -1,5 +1,4 @@
|
||||
# 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\
|
||||
It feels like an eternity and I\
|
||||
Can't keep waiting up\
|
@ -1,5 +1,4 @@
|
||||
# Drop Kicked From Senselessness
|
||||
|
||||
*Soft, muttered frequencies on the periphery of my subconscious*\
|
||||
*A tune I used to hear that flickers its presence*\
|
||||
*Giving me leverage of which to confine myself within the most secluded of spaces*\
|
@ -1,5 +1,4 @@
|
||||
# What do you mean you're not gay, you fucking dated me
|
||||
|
||||
*Waiting on you to blink me to life*\
|
||||
*She said I'm her backup [gal] in the end*\
|
||||
*I've never been one to pull away*\
|
@ -1,5 +1,4 @@
|
||||
# Senseless Murmurs of the Estranged (~~The~~ Last Night)
|
||||
|
||||
*Slithering fangs and pointy tails*\
|
||||
*Tell me if I'm not feeling well*\
|
||||
*My mindscape's hazard lights sing symphonies that plead me not to crash*\
|
@ -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 {
|
||||
constructor(root) {
|
||||
// bubbling events can listen at the root element
|
||||
|
BIN
void-fe/dist/assets/dioxus/void-werefox-cafe_bg.wasm
vendored
BIN
void-fe/dist/assets/dioxus/void-werefox-cafe_bg.wasm
vendored
Binary file not shown.
@ -7,8 +7,6 @@
|
||||
/// A module that handles the functions needed
|
||||
/// to render the site.
|
||||
pub mod void_app {
|
||||
use std::borrow::Borrow;
|
||||
|
||||
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
|
||||
pub use dioxus::prelude::*;
|
||||
use rust_embed::RustEmbed;
|
||||
@ -18,9 +16,22 @@ pub mod void_app {
|
||||
// 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)]
|
||||
struct PoemContent {
|
||||
content: String,
|
||||
creation_date: String,
|
||||
}
|
||||
#[derive(RustEmbed)]
|
||||
#[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: "container space-y-4 mx-auto p-4",
|
||||
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_to_str = std::str::from_utf8(poem_content.data.as_ref()).expect("Content is valid UT8.");
|
||||
let poem_to_html_string = markdown::to_html(poem_to_str);
|
||||
rsx!{ MakePoem{ content: poem_to_html_string } }
|
||||
let mut poem_to_str = std::str::from_utf8(poem_content.data.as_ref()).expect("Title is valid UT8.").lines();
|
||||
let poem_title = poem_to_str.next().unwrap();
|
||||
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"))]
|
||||
fn RenderPoemElement(cx: Scope<PoemContent>) -> Element {
|
||||
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 {
|
||||
cx.render(rsx!(div {
|
||||
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!(
|
||||
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",
|
||||
"POEM NAME HERE"
|
||||
}
|
||||
RenderPoemTitle { title: cx.props.title.clone() }
|
||||
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",
|
||||
"Open"
|
||||
}
|
||||
RenderPoemElement { content: cx.props.content.clone() }
|
||||
RenderPoemElement { content: cx.props.content.clone(), creation_date: cx.props.creation_date.clone() }
|
||||
}
|
||||
}
|
||||
))
|
||||
|
@ -8,10 +8,5 @@ fn main() {
|
||||
wasm_logger::init(wasm_logger::Config::default());
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user