2019-06-26 - Restructuring the phlog - part 3 | |
Home | |
Back to phlog | |
I started restructuring my phlog a few days ago, and today I | |
finished it. | |
I don't have to create the folder structure by hand anymore, nor | |
I have to write the gophermaps myself: a small set of groff | |
macros is taking care of that, together with a small Python | |
script which iterates over the post files, invoking troff as | |
needed, creating the folders, and generating the archives. | |
I update the root gophermap (which contains the text of the | |
latest post) with a short ed script, which looks for two | |
markers, `# latest - start' and `# latest - end', deletes all | |
the lines between them, and adds the text of the latest post | |
(which my Python script conveniently leaves in a `latest' | |
gophermap in a format amenable to inclusion). | |
I spent way too much time for my tastes on this, as I had to | |
debug a few issues that popped up because I'm used to the GNU | |
versions of the various tools I used (sed, shell, even ed). | |
A few things I learned: | |
- the NetBSD version of ed doesn't have comments (#), and its | |
read command (r ...) either doesn't do tilde expansion or | |
doesn't follow symlinks. I solved the former issue by | |
shelling out for the comments (*very* inefficient, but I | |
really don't want to leave ed scripts lying around | |
uncommented - they might try to take over the world or some | |
such), and the latter by reading *not* from a file, but from | |
the output of a cat invocation. | |
- the NetBSD version of sed doesn't have character escapes for | |
the replacements (e.g., you can't do s/@@/\t/), so you need | |
to insert the raw characters in there, and it also expects | |
the file parameter to be passed *after* its options (e.g., | |
-i, -e '...'). | |