update to latest gleam package versions and add several weeks lol

This commit is contained in:
graphiteisaac 2025-05-27 13:09:47 +10:00
parent d073b9305d
commit d372300575
15 changed files with 308 additions and 64 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -14,15 +14,16 @@ target = "javascript"
# https://gleam.run/writing-gleam/gleam-toml/. # https://gleam.run/writing-gleam/gleam-toml/.
[dependencies] [dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0" gleam_stdlib = ">= 0.60.0 and < 2.0.0"
jot = ">= 2.0.0 and < 3.0.0" jot = ">= 5.0.0 and < 6.0.0"
simplifile = ">= 2.2.0 and < 3.0.0" simplifile = ">= 2.2.0 and < 3.0.0"
lustre = ">= 4.6.3 and < 5.0.0" lustre = ">= 5.1.0 and < 6.0.0"
birl = ">= 1.8.0 and < 2.0.0" birl = ">= 1.8.0 and < 2.0.0"
argv = ">= 1.0.2 and < 2.0.0" argv = ">= 1.0.2 and < 2.0.0"
glen = ">= 2.2.1 and < 3.0.0" # glen = ">= 2.2.1 and < 3.0.0"
gleam_javascript = ">= 0.13.0 and < 1.0.0" gleam_javascript = ">= 1.0.0 and < 2.0.0"
glen_node = ">= 0.0.2 and < 1.0.0" gleam_time = ">= 1.2.0 and < 2.0.0"
# glen_node = ">= 0.0.2 and < 1.0.0"
[dev-dependencies] [dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0" gleeunit = ">= 1.0.0 and < 2.0.0"

View file

@ -4,36 +4,31 @@
packages = [ packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" }, { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "birl", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "2AC7BA26F998E3DFADDB657148BD5DDFE966958AD4D6D6957DD0D22E5B56C400" }, { name = "birl", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "2AC7BA26F998E3DFADDB657148BD5DDFE966958AD4D6D6957DD0D22E5B56C400" },
{ name = "conversation", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib"], otp_app = "conversation", source = "hex", outer_checksum = "908B46F60444442785A495197D482558AD8B849C3714A38FAA1940358CC8CCCD" }, { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
{ name = "filepath", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "67A6D15FB39EEB69DD31F8C145BB5A421790581BD6AA14B33D64D5A55DBD6587" }, { name = "gleam_erlang", version = "0.34.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "0C38F2A128BAA0CEF17C3000BD2097EB80634E239CE31A86400C4416A5D0FDCC" },
{ name = "gleam_community_ansi", version = "1.4.2", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_regexp", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "479DEDC748D08B310C9FEB9C4CBEC46B95C874F7F4F2844304D6D20CA78A8BB5" }, { name = "gleam_javascript", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "EF6C77A506F026C6FB37941889477CD5E4234FCD4337FF0E9384E297CB8F97EB" },
{ name = "gleam_community_colour", version = "1.4.1", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "386CB9B01B33371538672EEA8A6375A0A0ADEF41F17C86DDCB81C92AD00DA610" }, { name = "gleam_json", version = "3.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "5BA154440B22D9800955B1AB854282FA37B97F30F409D76B0824D0A60C934188" },
{ name = "gleam_erlang", version = "0.33.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "A1D26B80F01901B59AABEE3475DD4C18D27D58FA5C897D922FCB9B099749C064" }, { name = "gleam_otp", version = "0.16.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "50DA1539FC8E8FA09924EB36A67A2BBB0AD6B27BCDED5A7EF627057CF69D035E" },
{ name = "gleam_http", version = "3.7.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "8A70D2F70BB7CFEB5DF048A2183FFBA91AF6D4CF5798504841744A16999E33D2" }, { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
{ name = "gleam_javascript", version = "0.13.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "F98328FCF573DA6F3A35D7F6CB3F9FF19FD5224CCBA9151FCBEAA0B983AF2F58" }, { name = "gleam_stdlib", version = "0.60.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "621D600BB134BC239CB2537630899817B1A42E60A1D46C5E9F3FAE39F88C800B" },
{ name = "gleam_json", version = "2.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C55C5C2B318533A8072D221C5E06E5A75711C129E420DD1CE463342106012E5D" }, { name = "gleam_time", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "D71F1AFF7FEB534FF55E5DC58E534E9201BA75A444619788A2E4DEA4EBD87D16" },
{ name = "gleam_otp", version = "0.16.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "FA0EB761339749B4E82D63016C6A18C4E6662DA05BAB6F1346F9AF2E679E301A" },
{ name = "gleam_regexp", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "A3655FDD288571E90EE9C4009B719FEF59FA16AFCDF3952A76A125AF23CF1592" },
{ name = "gleam_stdlib", version = "0.52.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "50703862DF26453B277688FFCDBE9DD4AC45B3BD9742C0B370DB62BC1629A07D" },
{ name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" }, { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" }, { name = "gleeunit", version = "1.3.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "A7DD6C07B7DA49A6E28796058AA89E651D233B357D5607006D70619CD89DAAAB" },
{ name = "glen", version = "2.2.1", build_tools = ["gleam"], requirements = ["conversation", "filepath", "gleam_community_ansi", "gleam_http", "gleam_javascript", "gleam_stdlib", "marceau"], otp_app = "glen", source = "hex", outer_checksum = "836E324CD4604E19C04469156F3CAD71A5E26619582D2257DC6CD7B8D97D174E" }, { name = "houdini", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "houdini", source = "hex", outer_checksum = "5BA517E5179F132F0471CB314F27FE210A10407387DA1EA4F6FD084F74469FC2" },
{ name = "glen_node", version = "0.0.2", build_tools = ["gleam"], requirements = ["gleam_javascript", "glen"], otp_app = "glen_node", source = "hex", outer_checksum = "D2157D1E38B0963945E55F99E8C3F95FDA494DD1D3DF8DBF3A3744C4E501EA80" }, { name = "jot", version = "5.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "houdini", "splitter"], otp_app = "jot", source = "hex", outer_checksum = "2C1B30CC00B0D79F904028F48229C0BB354F3C1BC05EE99D4F3D423E223D85BF" },
{ name = "jot", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "jot", source = "hex", outer_checksum = "81E61DA896901BFC0522DCFB14C661B6C70F0664C01D8B461F5F9B1A9E965FD4" }, { name = "lustre", version = "5.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib", "houdini"], otp_app = "lustre", source = "hex", outer_checksum = "A0ADD4D936A49EE2CEBB8070F39058009122F0321D4B5445843D56E54875ECD8" },
{ name = "lustre", version = "4.6.3", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "BDF833368F6C8F152F948D5B6A79866E9881CB80CB66C0685B3327E7DCBFB12F" },
{ name = "marceau", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "2D1C27504BEF45005F5DFB18591F8610FB4BFA91744878210BDC464412EC44E9" },
{ name = "ranger", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "ranger", source = "hex", outer_checksum = "C8988E8F8CDBD3E7F4D8F2E663EF76490390899C2B2885A6432E942495B3E854" }, { name = "ranger", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "ranger", source = "hex", outer_checksum = "C8988E8F8CDBD3E7F4D8F2E663EF76490390899C2B2885A6432E942495B3E854" },
{ name = "simplifile", version = "2.2.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0DFABEF7DC7A9E2FF4BB27B108034E60C81BEBFCB7AB816B9E7E18ED4503ACD8" }, { name = "simplifile", version = "2.2.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "C88E0EE2D509F6D86EB55161D631657675AA7684DAB83822F7E59EB93D9A60E3" },
{ name = "splitter", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "128FC521EE33B0012E3E64D5B55168586BC1B9C8D7B0D0CA223B68B0D770A547" },
] ]
[requirements] [requirements]
argv = { version = ">= 1.0.2 and < 2.0.0" } argv = { version = ">= 1.0.2 and < 2.0.0" }
birl = { version = ">= 1.8.0 and < 2.0.0" } birl = { version = ">= 1.8.0 and < 2.0.0" }
gleam_javascript = { version = ">= 0.13.0 and < 1.0.0" } gleam_javascript = { version = ">= 1.0.0 and < 2.0.0" }
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" } gleam_stdlib = { version = ">= 0.60.0 and < 2.0.0" }
gleam_time = { version = ">= 1.2.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" } gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
glen = { version = ">= 2.2.1 and < 3.0.0" } jot = { version = ">= 5.0.0 and < 6.0.0" }
glen_node = { version = ">= 0.0.2 and < 1.0.0" } lustre = { version = ">= 5.1.0 and < 6.0.0" }
jot = { version = ">= 2.0.0 and < 3.0.0" }
lustre = { version = ">= 4.6.3 and < 5.0.0" }
simplifile = { version = ">= 2.2.0 and < 3.0.0" } simplifile = { version = ">= 2.2.0 and < 3.0.0" }

View file

@ -1,8 +1,8 @@
{ {
"name": "promptbox", "name": "promptbox",
"type": "module", "type": "module",
"version": "1.0.0", "version": "1.1.0",
"description": "[![Package Version](https://img.shields.io/hexpm/v/promptbox)](https://hex.pm/packages/promptbox) [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/promptbox/)", "description": "",
"main": "index.js", "main": "index.js",
"directories": { "directories": {
"test": "test" "test": "test"
@ -15,7 +15,7 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@chouqueth/gleam": "^1.7.0" "@chouqueth/gleam": "^1.9.0"
}, },
"dependencies": { "dependencies": {
"@tailwindcss/postcss": "^4.0.1", "@tailwindcss/postcss": "^4.0.1",

39
priv/posts/flight.md Normal file
View file

@ -0,0 +1,39 @@
---
title: Flight
week: 14
date: 2025-04-08
---
precisely folded, in a pack,\
strapped on tight to adventurer's back:\
this daredevil I serve,\
as we fall, twist, and swerve
I'm gripped by her brain,\
always up in this plane:\
in my strength she can trust,\
leaning back, a strong gust
we fall, free and wild,\
lucidity like a child:\
my time coming soon,\
together, we're attuned
all at once, familiar tug,\
I spread out, a broad rug:\
the wind beneath my sails,\
slowed, the view details
down lower we float,\
no longer remote:\
we land safe on the shore,\
fold and reset me once more
+++
I leap with hand on withers as my guide\
To hoist myself atop his scaly back\
I find my place there saddled forward loin\
Now braced with hand on pommel stapped to crest
With small squeeze I sign for a swift rise\
A bold rush to great hight by wings beat\
I'm struck by the sharp bite of cold wind\
And weights ease that lifts me in deep dive

23
priv/posts/obsession.md Normal file
View file

@ -0,0 +1,23 @@
---
title: Obsession
week: 17
date: 2025-04-29
---
the rolling thought of\
everything, that keeps me up at\
night, led by errant\
realities, that are not so\
real, deranged --\
obsessive, wondering as to my\
fate, which others don't\
consider, it could all end\
tomorrow, I will feel\
better
+++
An itch that just doesn't fade\
Even if scratch is made\
Till my skin is frayed
I ignored, though it stayed\
Even when thoughts strayed\
My obsession unswayed

View file

@ -1,7 +1,7 @@
--- ---
title: Secret Garden title: Secret Garden
week: 13 week: 13
date: 2024-04-01 date: 2025-04-01
--- ---
The landscape was filled with hidings aplenty. Even though strange happenings often occurred here, curious people came in droves each summer. Lush greens and vibrant purples blanketed rich earth. Trees hushed solemnly. What if they found out what was drawing them all in?\ The landscape was filled with hidings aplenty. Even though strange happenings often occurred here, curious people came in droves each summer. Lush greens and vibrant purples blanketed rich earth. Trees hushed solemnly. What if they found out what was drawing them all in?\
"This place is incredible," I heard my next victims exclaim. After their footsteps stilled, I lurched out and grabbed them, two unexpecting lovers. Leaves crunched under heavy foot as I dragged them back to my home. The garden around us laughed wickedly, another story to savour. "This place is incredible," I heard my next victims exclaim. After their footsteps stilled, I lurched out and grabbed them, two unexpecting lovers. Leaves crunched under heavy foot as I dragged them back to my home. The garden around us laughed wickedly, another story to savour.

38
priv/posts/souvenir.md Normal file
View file

@ -0,0 +1,38 @@
---
title: Souvenir
week: 18
date: 2025-05-06
---
purple elephant cup,\
rock from the office\
alien planet magnet,\
crystals, here before us
amongst my life,\
I find these things,\
wherever I dare go\
when I'm in strife,\
their memory clings,\
not really just for show
leftover lego pieces,\
skirt from Vanuatu\
worked-on wooden box,\
trinkets, I bought two
deep and hidden,\
they hide away,\
pretend to disappear\
history unwritten,\
hard to convey,\
a lifelong souvenir
+++
A plush ape of joy immature\
Tropical lamps to help endure\
Twisted glass of latent allure\
And golden flakes that's so unsure
All these items held souvenir\
For memories kept ever dear\
Recalling times no longer here\
So the feelings can persevere

51
priv/posts/susceptible.md Normal file
View file

@ -0,0 +1,51 @@
---
title: Susceptible
week: 16
date: 2025-04-22
---
you are not immune,\
your blind spots will prevail -\
the evil's out to get us,\
hook, thorn, lie and trail
'I'm not the problem,' you say with pride,\
to anyone who listens -\
but while you turn your back to them,\
they're pulling out munitions
'I don't think there's an issue,'\
you declare without a search -\
it's easy to miss the war\
from up there on that perch
'these people just complain too much,'\
you moan and whinge and spout -\
how lucky you are to live a life\
with little to grumble about
'supports are good, I guess,\
but some people are just bludging,'\
when all this push comes to shove,\
it's you that we'll be judging
look within, think for yourself,\
you've been far too susceptible\
in ignorance you may feel bliss,\
but disregard proves unacceptable
+++
Dressed up nice, but why I'm unsure\
To mourn a man I met not knew\
Yet I'll attend and act mature\
And show grief even if untrue
Sitting worried how it appears\
Given the lack of woe I've shown\
I see her there, eyes full of tears\
Such I feel welling in my own\
In this I discover new fears\
Of a world where I'm not alone
An effect which I was aware\
Yet for myself was skeptical\
In this bizarre awkward affair\
I've found myself susceptible

39
priv/posts/violence.md Normal file
View file

@ -0,0 +1,39 @@
---
title: Violence
week: 15
date: 2025-04-15
---
I don't want to write about violence\
it's much too hard to think about\
all the pain and hurt we give each other\
concealed with hate and doubt
a raging river, the endless stream\
we all fall in sometimes\
perpetrator, victim too\
complex connection paradigms
it's normal here, will always be\
at least that's how it seems\
so many find this status quo\
is something of their dreams
mild mannered monsters\
hiding in plain sight\
they lie in wait, unknowing\
they'll set your life alight
+++
An act so vile\
Not done to one\
But rather left\
To quell an it
The triumph felt\
May quench the fear\
Of notions found\
On premise false
But if allowed\
To declass one\
The wound that's dealt\
Will shackle all

34
priv/posts/voyage.md Normal file
View file

@ -0,0 +1,34 @@
---
title: Voyage
week: 19
date: 2025-05-13
---
humongous high beam waves\
crashing with a roar\
lashing on our hull\
beneath the cabin floor
across the sea we travel\
destinations not so near\
this voyage gently carried\
by unrelenting fear
land on the horizon\
speaks out to us with hope\
peered at from afar\
with brass and glass turned scope
the ending's now in sight\
as we wash up by the dock\
bashed and bruised and battered\
our sea-torn home-bound flock
+++
Sails filled with billows, spurring our bows breach\
The morns brisk wind brings waves of frigid spray\
Maintaining course, sail trimmed for a beam reach.\
Our only trace a wake in quick decay
At nights fall surrounded by glistening\
The starry reflections on moving seas\
But ye beware of late night listening\
The sirens song turns sweet the bitter breeze

View file

@ -1,4 +1,4 @@
import birl import gleam/time/calendar
import lustre import lustre
import lustre/element/html import lustre/element/html
import promptbox/parser import promptbox/parser
@ -29,7 +29,7 @@ fn view(_model) {
slug: "ebben-flow", slug: "ebben-flow",
title: "ebben flow", title: "ebben flow",
week: 1, week: 1,
date: birl.now(), date: calendar.Date(1970, calendar.January, 1),
post_p: "No", post_p: "No",
post_j: "OK", post_j: "OK",
), ),

View file

@ -1,9 +1,9 @@
import birl
import gleam/dict import gleam/dict
import gleam/int import gleam/int
import gleam/list import gleam/list
import gleam/result import gleam/result
import gleam/string import gleam/string
import gleam/time/calendar
import jot import jot
pub type Post { pub type Post {
@ -11,7 +11,7 @@ pub type Post {
slug: String, slug: String,
title: String, title: String,
week: Int, week: Int,
date: birl.Time, date: calendar.Date,
post_p: String, post_p: String,
post_j: String, post_j: String,
) )
@ -19,6 +19,7 @@ pub type Post {
pub fn parse_post(slug: String, content: String) -> Post { pub fn parse_post(slug: String, content: String) -> Post {
let assert [_, frontmatter, posts] = string.split(content, "---\n") let assert [_, frontmatter, posts] = string.split(content, "---\n")
let frontmatter = let frontmatter =
frontmatter frontmatter
|> string.split("\n") |> string.split("\n")
@ -27,7 +28,8 @@ pub fn parse_post(slug: String, content: String) -> Post {
False -> Error(Nil) False -> Error(Nil)
True -> { True -> {
let assert [key, value] = let assert [key, value] =
string.split(entry, ":") |> list.map(string.trim) string.split(entry, ":")
|> list.map(string.trim)
Ok(#(key, value)) Ok(#(key, value))
} }
@ -49,9 +51,25 @@ pub fn parse_post(slug: String, content: String) -> Post {
|> result.try(int.parse) |> result.try(int.parse)
|> result.unwrap(-1), |> result.unwrap(-1),
date: dict.get(frontmatter, "date") date: dict.get(frontmatter, "date")
|> result.try(birl.parse) |> result.try(parse_date)
|> result.unwrap(birl.now()), |> result.unwrap(calendar.Date(1970, calendar.January, 1)),
post_p:, post_p:,
post_j:, post_j:,
) )
} }
fn parse_date(time_str: String) -> Result(calendar.Date, Nil) {
case
time_str
|> string.split("-")
|> list.filter_map(int.parse)
{
[year, month, date]
if year > 2000 && month > 0 && month < 13 && date > 0 && date < 31
-> {
let assert Ok(month) = calendar.month_from_int(month)
Ok(calendar.Date(year, month, date))
}
_ -> Error(Nil)
}
}

View file

@ -1,6 +1,7 @@
import gleam/int import gleam/int
import gleam/list import gleam/list
import lustre/attribute.{attribute, class} import lustre/attribute.{attribute, class}
import lustre/element
import lustre/element/html import lustre/element/html
import promptbox/parser import promptbox/parser
@ -35,15 +36,19 @@ pub fn individual(post: parser.Post) {
fn prompt_element(post: parser.Post) { fn prompt_element(post: parser.Post) {
html.article([class("post py-8"), attribute.id(post.slug)], [ html.article([class("post py-8"), attribute.id(post.slug)], [
html.h2([class("prompt_title text-center text-4xl font-bold italic mb-1")], [html.text(post.title)]), html.h2([class("prompt_title text-center text-4xl font-bold italic mb-1")], [
html.h5([class("prompt_week text-center italic text-slate-700 mb-5")], [html.text("Week " <> int.to_string(post.week))]), html.a([attribute.href("/prompts/" <> post.slug)], [html.text(post.title)]),
]),
html.h5([class("prompt_week text-center italic text-slate-700 mb-5")], [
html.text("Week " <> int.to_string(post.week)),
]),
html.div([class("flex flex-col")], [ html.div([class("flex flex-col")], [
html.article([class("prose text-left")], [ html.article([class("prose text-left")], [
html.div([attribute("dangerous-unescaped-html", post.post_p)], []), element.unsafe_raw_html("", "div", [], post.post_p),
html.cite([class("text-slate-800")], [html.text("~ P")]), html.cite([class("text-slate-800")], [html.text("~ P")]),
]), ]),
html.article([class("prose text-right self-end")], [ html.article([class("prose text-right self-end")], [
html.div([attribute("dangerous-unescaped-html", post.post_j)], []), element.unsafe_raw_html("", "div", [], post.post_j),
html.cite([class("text-slate-800")], [html.text("~ J")]), html.cite([class("text-slate-800")], [html.text("~ J")]),
]), ]),
]), ]),

View file

@ -1,6 +1,4 @@
import birl import gleam/time/calendar
import gleam/io
import gleam/result
import gleeunit import gleeunit
import gleeunit/should import gleeunit/should
import lustre/element import lustre/element
@ -13,21 +11,24 @@ pub fn main() {
gleeunit.main() gleeunit.main()
} }
// gleeunit test functions end in `_test` pub fn parse_basic_post_test() {
pub fn hello_world_test() { "---
let post = title: a title
simplifile.read("./priv/posts/ebb_and_flow.md") week: 1
|> result.unwrap("") date: 2025-01-01
|> parser.parse_post("ebb_and_flow") ---
|> io.debug Post content 1
+++
io.debug(birl.to_date_string(post.date)) Post content 2"
|> parser.parse_post("a-title", _)
files.read_all_posts() |> should.equal(parser.Post(
|> io.debug slug: "a-title",
title: "a title",
1 week: 1,
|> should.equal(1) date: calendar.Date(2025, calendar.January, 1),
post_p: "<p>Post content 1</p>\n",
post_j: "<p>Post content 2</p>\n",
))
} }
pub fn generate_test() { pub fn generate_test() {