From d450e3bfb8468c617f14ad12dd98fb697ff10580 Mon Sep 17 00:00:00 2001 From: tslil clingman <> Date: Wed, 21 Apr 2021 14:52:08 -0400 Subject: compiling l-3.space for the web --- log-210421-1.gmi | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 log-210421-1.gmi (limited to 'log-210421-1.gmi') diff --git a/log-210421-1.gmi b/log-210421-1.gmi new file mode 100644 index 0000000..7685471 --- /dev/null +++ b/log-210421-1.gmi @@ -0,0 +1,55 @@ +Time-stamp: <2021-04-21 18h50 UTC> + +# l-3.space is now automatically compiled to the web + +Using a combination of git hooks, a python script, and some shell glue it is now possible to view an HTML version of l-3.space over the web⁰. + +=> https://l-3.space + +This is a short post to detail how i implemented it, and lament the things that didn't work. + +## I'm not in the best time-line (yet) + +I would have liked to have been able to set up a gemini-to-http server and proxied it in. The first thing i found was ddevault's Kineto. + +=> https://git.sr.ht/~sircmpwn/kineto kineto + +It's written in Go, about which i have some reservations, but one of it's modules has a hard version requirement *on Go itself*! Debian does not package a ``new enough'' version, so i can't use this code. To me this is frankly unbelievable, and i'm still not sure i even understand what a version of a ``programming language'' could mean. If this is a question of libraries or something, then perhaps call it such, but the compiler gleefully reports ``Go version 1.15 required'' ... + +There's also tslocum's Xenia. + +=> https://code.rocketnine.space/tslocum/xenia tslocum's Xenia + +Unfortunately i couldn't quite work out what this is supposed to be, or how it works, so i ended up doing this the wrong way. + +## The wrong way + +I came across a gemtext-to-html converter and decided that i could reasonably modify it to generate usable HTML output directly. As l-3.space exists as a repository on the hosting machine, i opted to add the following snippet to `.git/hooks/post-update' to (re)generate the HTML every time i pushed a change to the capsule. + +``` +echo Generating HTML site +for g in /var/gemini/l-3.space/content/*.gmi; do + html_out="/var/www/l-3.space/$(basename $g .gmi).html" + gmi2html.py /home/$USER/gemini-capsules/l-3.space/html_header.html \ + /home/$USER/gemini-capsules/l-3.space/html_footer.html \ + "$g" "$html_out"; + chmod 644 "$html_out" +done +``` + +Here gmi2html.py is the name of the script. You can find the original version and my modified version using the below links. + +=> https://github.com/huntingb/gemtext-html-converter hunterb's original version, convert_gemtext_file.py +=> gemini://l-3.space/gmi2html.py my modified version, gmi2htmly.py + +## A fun story about licensing + +Originally hunterb had made the code available, but had forgotten to include a license. Fortunately, there was a listed contact email address. I wrote to hunterb, explaining that i want to make use of the script, change it, share my changes, and allow others to do the same. I asked whether they would be willing to release the code under a license which afforded me these freedoms ... + +they said yes! + +The code is now available under the terms of the GNU GPL v3! + +--- + +⁰ though of course, why would you -- cgit v1.3.1