Source for
git clone git://
Log | Files | Refs | README | LICENSE

commit cf670de12685a94e7a53f0a126ae77cbf548cf91 (patch)
parent f9b80aba83efba919e0678fefcb01e24119d40c6
Author: Alex Karle <>
Date:   Thu, 25 Feb 2021 15:42:40 -0500

gopher: Add small mdoc -> gopher generation script

In my time off this week, I took a deep dive on gopher, and it's a
really cool niche blogging space! I intend to host all my posts there,
which is pretty easy because mdoc(7) translates nicely to ascii with

This patch adds a script to generate a *very* primitive gopherhole for
use with gophernicus. The key elements are:

1. Generates a TXT file for each blog post / page
2. Moves the blogs to phlog/
3. Sets the mtime of the blog posts so that the default DIR view shows

I hope to expand on this in future commits by creating a gophermap for
the blog(7) page with links to the content (rather than just using the
DIR view). But for now... we're live!

Diffstat: | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/ b/ @@ -0,0 +1,32 @@ +#!/bin/sh +# generates my gopherhole based on the checkout of the files +# in the html area +set -e + +WWW=/var/www/htdocs/akcom +DEPLOY=/var/gopher +PHLOG=$DEPLOY/phlog + +# First generate the content +for f in $WWW/*.7; do + # col -b to strip backspace underlines, see mandoc(1) + mandoc -Tascii -Owidth=72 $f | col -b > $PHLOG/`basename $f .7`.txt +done + +# Remove/move some non-phlog cruft +mv $PHLOG/intro.txt $DEPLOY/intro.txt +rm $PHLOG/template.txt + +# Set the mtimes so they show nicely in the directory listing +# by parsing the .Dd lines using grep(1) and date(1) +# TODO: create a real gophermap for this directory based on blog(7) +for f in $PHLOG/*.txt; do + grep '\.Dd' $WWW/`basename $f .txt`.7 \ + | grep -v Mdocdate \ + | sed "s#\.Dd #$f #" +done > /tmp/mtimes + +IFS=" " # tab to split file/date for read (see ksh(1)) +while read f d; do + touch -m -d `date -j -f "%b %d, %Y" "+%Y-%m-%dT%H:%M:%S" "$d"` "$f" +done < /tmp/mtimes