ols.wtf / blog / meta-a-blog-post-about-this-blog

[Meta] a blog post about this blog

Oliver Leaver-Smith <oliver@leaversmith.com> on 2022-10-26 16:10:10

I've written a new blogging system, and frankly it is pretty cool. Let's start things off with a fantastic meta post, all about how this blog is generated.

Starting off: it's based on email. You heard that right. I have been playing around with "email to x" systems for a while now, starting with random little tagged notes and most recently a process for saving articles to read later.

Blog posts are emailed to my blog mailing list ~ols/blog@lists.sr.ht by me and me alone (for now, I might add others that can publish at a later date). My special email address is subscribed as a consumer of the mailing list and runs a couple of applications when it receives a message.

BLOG_DIR=/var/www/htdocs/ols.wtf/blog /usr/local/bin/mlblg &&
/usr/local/bin/index.sh"

What mlblg does is parse the email for subject, sender, date, and body and fabricates a blog post from that. There are more details contained in the repo itself (although naturally documentation is light) which you are free to browse.

The index.sh shell script is similar to previous aggregators I have made use of in the past and just collates all *.html pages from a specific directory and builds a simple index for them

#!/usr/bin/env bash

PUBLIC_HTML_DIR="/var/www/htdocs/ols.wtf/blog"
HTML_FILE="$PUBLIC_HTML_DIR/index.html"

cat $PUBLIC_HTML_DIR/HEADER > $HTML_FILE

ls -t $PUBLIC_HTML_DIR/*.html | grep -v index.html | while read file ;
do echo "<a href=\"$(echo $file | awk -F '/' '{print $NF}')\">$(grep
"<h1" $file | head -1)</a>" ; grep "<p>" $file | head -1 ; done >>
$HTML_FILE

cat $PUBLIC_HTML_DIR/FOOTER >> $HTML_FILE

So really this is it. Devilishly simple actually, and yet another fantastic usecase for plain text email, mailing lists, and self-hosting. Next step is what I have seen ~afontaine suggest which is having a separate mailing list for blog comments which are populated on the blog page itself. For now though, I am content with a public inbox mailing list which is referenced on every page of this blog.