💾 Archived View for gmi.oaktal.com › tech › sh.gmi captured on 2023-01-29 at 02:27:03. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
I'm not sure what anyone else out on geminispace is using to build their capsules- whether it be manual static sites or a pile of CGI scripts- but I'm quite pleased with the solution I found for myself, and would like to share it.
My capsule is a static collection of preprocessed pages, and this is my preprocessor:
#! /bin/sh while read LINE; do eval echo \"$LINE\" done
With those five lines, I can now use my shell's process substitution to do anything. A directory listing is just `$(ls)`, and I could even run something like `$(ufetch)` if I wanted to.
Of course that's a bit of an oversimplification. I also have a wrapper script that recurses through my source directory and will only process changed files, but ultimately that wrapper script is just calling `pre < source.gmi > dest.gmi`. There's another library script that provides a quick shorthand for turning a directory listing into gemtext links as well, but again that's more of an extension to my preprocessor than anything. No matter what, all three of my scripts come to just 122 lines of shell script.
I'm not entirely sure why I felt the need to share my preprocessor. I don't mean to imply my method is superior, of course. I think it's more that I originally had these grand ideas for my gemini capsule and how I would generate my pages, before eventually settling down and writing something far more practical. I'm more than happy with what I have now, and would like to point out to anyone looking at starting their own capsule that it doesn't have to be complicated. Even manual pages are viable, and probably far better than what I'm trying to pull here.
For the curious, these are my wrapper and library scripts, respectively:
I make no claim that they are well written or a good idea. They are uncommented shell scripts, after all. I'm relying on proper isolation and user permissions to save my hide if something ever breaks or I manage to screw up and put `$(cat ~/.ssh/id_rsa)` in a gemtext page.