Skip to content

Commit

Permalink
feat: dump
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbchron committed Dec 13, 2024
1 parent 147fbfc commit 2eeb2ef
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ lib-package = "site-frontend"
site-root = "target/site"
site-pkg-dir = "pkg"

style-file = "crates/site-app/style/main.scss"
style-file = "crates/site-app/style/main.css"
assets-dir = "crates/site-app/public"

site-addr = "127.0.0.1:3000"
reload-port = 3001

browserquery = "defaults"

tailwind-input-file = "crates/site-app/style/main.scss"
tailwind-input-file = "crates/site-app/style/main.css"
tailwind-config-file = "crates/site-app/style/tailwind/tailwind.config.js"

# set by cargo-leptos
Expand Down
2 changes: 1 addition & 1 deletion content/posts/a-new-rust-job-runner.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "A New Rust Job Runner"
written_on: "09/07/24"
written_on: "2024.09.07"
public: false
---

Expand Down
2 changes: 1 addition & 1 deletion content/posts/building-this-blog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Building this blog: A Space Odyssey"
written_on: "28/01/24"
written_on: "2024.01.28"
public: true
---

Expand Down
2 changes: 1 addition & 1 deletion content/posts/fully-procedural-interactions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Fully Procedural Interactions in Games"
written_on: "08/08/24"
written_on: "2024.08.08"
public: true
---

Expand Down
51 changes: 51 additions & 0 deletions content/posts/jsonp-who-asked.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "jsonp - Who Asked?"
written_on: "2024.11.23"
public: true
---

Often I need to prettify JSON.
I probably don't need to justify that need to you.
For many years I have used the site [jsonprettify.com](https://jsonprettify.com), which does the job well.
It doesn't look quite how I would have it look, but it's fit for purpose and allows formatting at different levels of expansion.

Recently, I (mistakenly) thought it had gone down.
This was most likely due to me misremembering the URL on a new machine that didn't remember it for me, but I'm in too deep now to back out anyways.

Finding my favorite tool missing, there's only one real solution.
Build it myself.

## Down the hole

The construction started off pretty simple.
I have been using Rust for the web for the last couple years, and though it changes frequently, I have found that temporarily forsaking JS has made it impossible to pick up again, so here we are.
Leptos has been my tool of choice, and since I'm a Nix stan, I package it with Nix.
All this I have been able to borrow from previous projects of mine.

The main functionality wasn't so difficult either.
The only hurdle is trying not to perform too many copies and not to skip frames when dealing with large payloads.
I found that the HTML `<textarea>` tag produces far more latency than my code when receiving a large payload anyways (about 12 frames at 60fps compared to my 3-4 frames), so I'm not too concerned about it.

`v0.1` was all well and good until I decided to deploy it.
My tradition has been to build it into an OCI image using Nix and then ship it off to [Fly.io](https://fly.io) in a GitHub action, but this time I hesitated.
I have been wanting to move to [CloudFlare Workers](https://workers.cloudflare.com/) as my primary Leptos deployment strategy, since it's free until 100,000 requests per month, and it fits most of my apps.

## Wrangling `wrangler`
`wrangler` is a pain in my ass.
It's the CF workers et al. deployment tool, and it's a JS app.
It doesn't seem like there's a community effort to circumvent it at all.
It itself is fine, but it's packaged poorly within Nix.
On `aarch64-linux` (hello to my Asahi brothers), it doesn't build, complaining something about MUSL `libc.so.1` being missing.

After 15 wasted hours, I dropped it for a week.
After a week, 10 minutes and 2 line additions fixed the problem.

I need to do more research on the `wrangler` build process so that I can squish it down into the Nix ecosystem and forget about it, but I'm satisfied for now.
I need to let my executive energy regenerate before I return to this problem again.

## It works!
This project -- dubbed `jsonp` but unrelated to the weird pre-CORS JS technique [JSONP](https://en.wikipedia.org/wiki/JSONP) -- is now live at [`https://jsonp.org/`](https://jsonp.org/).
Feel free to use it, and direct your feedback to the [GitHub issues page](https://github.com/johnbchron/jsonp/issues).
You can see the planned features there.

Thanks for reading!
2 changes: 1 addition & 1 deletion content/posts/strongly-typed-ids-in-surrealdb.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Strongly-typed IDs in SurrealDB"
written_on: "18/03/24"
written_on: "2024.03.18"
public: true
---

Expand Down
Binary file not shown.
8 changes: 4 additions & 4 deletions crates/site-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ pub fn App() -> impl IntoView {
rel="preload" href="/fonts/IosevkaCustom-Regular.ttf"
as_="font" type_="font/ttf" crossorigin="anonymous"
/>
<leptos_meta::Link
rel="preload" href="/fonts/IosevkaCustom-Bold.ttf"
as_="font" type_="font/ttf" crossorigin="anonymous"
/>
// <leptos_meta::Link
// rel="preload" href="/fonts/IosevkaCustom-Bold.ttf"
// as_="font" type_="font/ttf" crossorigin="anonymous"
// />
<leptos_meta::Link
rel="preload" href="/fonts/IosevkaCustom-Italic.ttf"
as_="font" type_="font/ttf" crossorigin="anonymous"
Expand Down
1 change: 0 additions & 1 deletion crates/site-app/src/posts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ pub async fn get_all_posts() -> Result<Vec<Post>, ServerFnError> {
.collect::<String>();
a.cmp(&b)
});
posts.reverse();

Ok(posts)
}
Expand Down
22 changes: 19 additions & 3 deletions crates/site-app/style/fonts.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
@font-face {
font-family: 'Iosevka Custom';
font-display: swap;
font-weight: 100 900;
font-weight: 400;
font-style: normal;
src:
url('/fonts/IosevkaCustom-Regular.ttf') format('truetype')
url('/fonts/IosevkaCustom-Bold.ttf') format('truetype')
url('/fonts/IosevkaCustom-Regular.ttf') format('truetype');
}

@font-face {
font-family: 'Iosevka Custom';
font-display: swap;
font-weight: 400;
font-style: italic;
src:
url('/fonts/IosevkaCustom-Italic.ttf') format('truetype');
}

@font-face {
font-family: 'Iosevka Custom';
font-display: swap;
font-weight: 600;
font-style: normal;
src:
url('/fonts/IosevkaCustom-Bold.ttf') format('truetype');
}

@font-face {
font-family: 'FiraSans';
font-display: swap;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/site-app/style/tailwind/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
],
theme: {
fontFamily: {
'sans': ['FiraSans', 'ui-sans-serif', 'system-ui', 'sans-serif', "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"],
'sans': ['Iosevka Custom', 'ui-sans-serif', 'system-ui', 'sans-serif', "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"],
'mono': ['Iosevka Custom', 'ui-monospace', 'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas', "Liberation Mono", "Courier New", 'monospace'],
},
extend: {
Expand Down

0 comments on commit 2eeb2ef

Please sign in to comment.