microblogging using shell and MMTT

Sometimes I feel the urge to share useless information with the world, like status updates of my projects and cool stuff I found (that is not worthy of the cool list), or to just rant about something. Obviously I have the articles section, but I want to keep it to longer and more serious articles. Obviously I could make a tweeter or a mastodon account, but that would be too easy. That’s why I wrote my own microblogging “platform” in few lines of shell.

Here you can see the whole script:

#!/bin/sh

FILES=`ls post--* | tac`
COUNT=`echo $FILES | wc -w`

I=$COUNT
for f in $FILES; do
    echo ""
    echo "<hr>"
    echo ""
    echo "<h2 id=\"$I\"><a href=\"#$I\">#$I</a></h2>"
    echo ""
    cat $f
    echo ""
    echo "[reply](mailto:${MAILING_LIST}@lists.sr.ht?subject=%23$I) [replies](https://lists.sr.ht/${MAILING_LIST}?search=%23$I)"
    echo ""

    I=$(( $I - 1 ))
done

It goes through all posts in the current folder (files prefixed with post--). It assigns a number to each of them. This number is used as the identifier of the post. Above the individual post it puts a heading, which redirects to the post in question (used for sharing).

Below the post, there are reply and replies links. For the replies I use sourcehut’s mailing lists. Clicking the reply link will open a new email, with the post’s number as the subject, in your mail client. The replies link will direct you to the search result of the post’s number.

To embed the posts into my web, I use MMTT. This is as easy as this:

# microblog

Welcome to my microblog. Here I share stuff at a higher volume. You can
subscribe to it's rss [feed](rss.xml). You can read about how this works
[here](/articles/shell-mmtt-microblogging.html).

{:: cd microblog; MAILING_LIST=~mrms/microblog-replies sh microblog.sh ::}

Then I just use my shell script for generating rss feeds to generate the feed for the microblog.

To easily publish new articles from my computer, I use this script:

#!/bin/sh

F=post--`date -Iseconds`.md
cat /dev/stdin > /tmp/$F
rsync /tmp/$F marek@mrms.cz:web/site/microblog

You can see the result here.

<< back

Other articles

4MB game jam 2023

via Marek Maskarinec's website October 24, 2023

Announcement: MMRE

via Marek Maskarinec's website October 24, 2023

My smartwatch experience

via Marek Maskarinec's website October 24, 2023

Generated by openring