Skip to content

fractuscontext/fortune-svg

Repository files navigation

fortune-svg

./docs/cf-pages.gif

I have no idea what this is for.

Okay, fine. It's a Cloudflare Pages Function. It takes a text file full of terrible puns, picks one, and serves it as a terminal-themed SVG (or PNG!) so that archaic university email clients actually render it. Think of it as the legacy UNIX fortune program, but repackaged as a web endpoint to annoy your professors.

It also contains a concerning number of Serial Experiments Lain and Terry Davis GIFs for the 404 pages (see public/assets/404-gifs/). I will not be taking questions at this time.

Routes

GET /fortune
Rolls the dice. Put this in your <img> tag and hope it doesn't get you expelled.
GET /fortune?text=<text>
For when you want to fake a quote but still want that sweet terminal aesthetic.
GET /fortune?mode=png
Forces a PNG render via a statically bundled WebAssembly engine. For email clients that aggressively hate vectors.
GET /quote, GET /quotes
Aliases, because I couldn't decide what to name the file in functions/.

How to ruin your academic career

  1. Open public/assets/fortune/quotes.txt.
  2. Add your quotes. Delimit them with a % on its own line (standard fortune(6) format).
  3. Deploy it.
  4. Paste the image link into your email signature.
  5. To learn more about this step, read the README.

Development

i use nix, btw:

nix develop
pnpm install
pnpm run dev

Configuration

Variables are in wrangler.toml. If you need help configuring them, see README.

Deploy to Cloudflare Pages

  • Build command: pnpm gen
  • Build output directory: public

License

REUSE-compliant (MIT or CC0-1.0). Run reuse lint to verify.