2025-12-21 18:00:00 -08:00

A Now Page

I have decided to create a Now page for my website. Here is the official documentation for Now pages, but I decided to put my own spin on the idea. I have been considering adding a microblog page for my website, which would be a place that I can quickly add posts, something like a twtxt file, but I don't particularly like a permanent, endlessly long file for a microblog. I prefer treating microblog posts as temporary and ephemeral, that's the reason why I have my Mastodon posts delete themselves after a year.

I have created the following script for quickly and easily updating to my Now page and Mastodon at the same time from my terminal. This script compliments the blog.sh script I have created for building this website, which you can look at in the git repo.

All I need to do is run something like this:

post.sh "Extremely thoughtful message for my thousands of followers"

and my scripts will post my thoughts to Mastodon, update my Now page, update my RSS feed, and upload the files to my web server.

Post.sh script

#!/usr/bin/env bash

TIMESTAMP="$(date '+%Y-%m-%d %H:%M:%S %:z')"
ID="$(date -d "$TIMESTAMP" '+%Y%m%d%H%M%S')"
INPUT="$*"
CHAR_COUNT="$(printf '%s' "$INPUT" | wc -c)"
CHAR_LIMIT="500"
if [[ "$CHAR_COUNT" -eq 0 ]] || [[ "$CHAR_COUNT" -gt "$CHAR_LIMIT" ]]; then
	if [[ "$(command -v vipe)" = "" ]]; then
		printf 'Error: Unable to create post.  Character count is %s/%s' "$CHAR_COUNT" "$CHAR_LIMIT"
		printf 'Tip: Install moreutils for vipe command.'
		exit 1
	else
		POST="$(printf %s "$INPUT" | vipe)"
	fi
else
	POST="$INPUT"
fi
masto() {
	if [[ "$(command -v toot)" = "" ]]; then
		printf "Error: Unable to post to Mastodon, toot command not found.\n"
	else
		toot post "$POST"
	fi
}
now() {
	local THIS_BLOG_DIR
	THIS_BLOG_DIR="$HOME/Documents/blog"
	source "$THIS_BLOG_DIR/config.env"
	local THIS_NOW_DIR
	THIS_NOW_DIR="$THIS_BLOG_DIR/$NOW_DIR"
	local THIS_TEMPLATES_DIR
	THIS_TEMPLATES_DIR="$THIS_BLOG_DIR/$TEMPLATES_DIR"
	test -d "$THIS_NOW_DIR" || mkdir -p "$THIS_NOW_DIR"
	local HTML_DATE
	HTML_DATE="<p id=\"$ID\"><i class=\"date\"<$TIMESTAMP</i<</p<"
	local HTML_POST
	HTML_POST="<p<$(echo "$POST" | sed 's!\n!</p<<p<!g')</p<"
	printf '<article<\n<h1<Now</h1<\n%s\n%s\n