💾 Archived View for thrig.me › software › blog-engine.gmi captured on 2024-05-10 at 12:00:13. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-11-14)
-=-=-=-=-=-=-
A description may be more useful than any code. Alternatives exist:
gemini://perso.pw/blog/articles/blog-workflow.gmi
Probably you should write your own that suits your needs. It's good programming practice, if anything. It also may take a few attempts to get it as simple as possible, especially if one is prone to overcomplicating things.
This script is glorified cp(1) that copies a given file into the blog directory tree using the current date. Nifty features are also to copy in local files mentioned in the blog file into the directory of the blog entry, and various sanity checking that the subject makes sense, etc.
The blog entries and any associated includes are usually fussed with under ~/tmp for a while. Usually I do not know what the subject and filename of the post will be, so the blog script lets those be specified. If no subject is given, the subject is taken from the first "# subject" line in the file. Or, the script errors out for me to fix that before it modifies anything on the filesystem.
A list of scripts in a particular directory are called with details about the new blog entry; these scripts handle updating the main index.gmi and so forth. This keeps a bunch of annoying logic out of the blog script, and allows new plugins that do new things to be added.
Then, rsync stuffs the files up onto the virtual host via a Makefile rule--since OpenBSD ships with make, why not use it?
check: @gmitool get gemini://thrig.me/%E8%A9%A6%E9%A9%97.gmi clean: git clean $PREVIEW --force -x sync: rsync --timeout=15 $PREVIEW -f'H /tmp' -f'P /tmp' --delete --delete-excluded -avz --exclude=.git\* --exclude=/Makefile . gh:/var/gemini/thrig.me/ update: gmitool get 'gemini://warmedal.se/~antenna/submit?gemini://thrig.me/blog/' .PHONY: check clean sync update
The PREVIEW environment variable can then be used to see what would change without actually doing so by passing a suitable flag for rsync. The "clean" rule is so things like *.core or ktrace.out can be removed. Probably these should get added to an rsync exclude-from file.
$ PREVIEW=-n make sync ...
The "gh" in the "gh:/var/gemini/thrig.me" rsync target is an alias for my "go home" host. This is set in the ~/.ssh/config file. (The "gh" host used to be in a rack in my apartment, but some number of years ago I stopped doing that. It was good for heating during the winter.)
Host thrig.me vultr gh Hostname 104.207.156.138 IdentityFile ...
The offline copy is a backup, and can be used locally
to view pages being modified:
$ ls blog-engine.gmi index.gmi w3m.gmi $ wv -l blog-engine.gmi gemini://thrig.me/software/blog-engine.gmi $ wv -t test -l blog-engine.gmi gemini://localhost/software/blog-engine.gmi
wv is an alias for the perhaps too complicated ow.c that can be found under
https://thrig.me/src/scripts.git
that uses the mapping
$ grep gemini ~/.ow/dirmap /var/gemini/(?<rest>.+) gemini://%{rest} /var/gemini/thrig.me(?:/(?<rest>.+))? gemini://localhost/%{rest} test
Another way to view what a file looks like is via the editor configuration, here for vi (there are two ^M after the % in the actual configuration file):
map \t :!amfora %
which merely maps backslash-t (for "try it out") to running a gemini browser on the filename. This however will not have the full features of a gemini server, autoindex in particular. One could also make a mapping of
map \y :!wv -t
to direct the URL of the file to the server on the localhost interface. But that will take longer, as instead of using a file on disk it must go though a gemini server. This is a custom version of vi, forked from the base version found on OpenBSD, and is delightfully lacking in features, and thus very fast.
How about some other software?
tags #blog