20251221204224 push
This commit is contained in:
55
content/blog/now.html
Normal file
55
content/blog/now.html
Normal file
@@ -0,0 +1,55 @@
|
||||
<article>
|
||||
<header id="title-block-header">
|
||||
<p class="date">2025-12-21 18:00:00 -08:00</p>
|
||||
<h1 class="title">A Now Page</h1>
|
||||
</header>
|
||||
<p>I have decided to create <a href="/now/">a Now page</a> for my website. Here is <a href="https://indieweb.org/now">the official documentation</a> 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 href="https://github.com/buckket/twtxt">a twtxt file</a>, 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.</p>
|
||||
<p>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 <pre>blog.sh</pre> script I have created for building this website, which you can look at in <a href="https://git.0x212.com/iiogama/website">the git repo</a>.</p>
|
||||
<p>All I need to do is run <pre>post.sh "Extremely thoughtful message for my thousands of followers"</pre> and my scripts will post my thoughts to Mastodon, update my Now page, update <a href="/index.xml">my RSS feed</a>, and upload the files to my web server.</p>
|
||||
<h2>Post.sh script</h2>
|
||||
<pre>
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TIMESTAMP="$(date '+%Y-%m-%d %H:%M:%S %:z')"
|
||||
ID="$(date -d "$TIMESTAMP" '+%Y%m%d%H%M%S')"
|
||||
POST="$*"
|
||||
CHARCOUNT="$(printf '%s' "$POST" | wc -c)"
|
||||
CHARLIMIT="500"
|
||||
if [[ "$CHARCOUNT" -gt "$CHARLIMIT" ]]; then
|
||||
if [[ "$(command -v vipe)" = "" ]]; then
|
||||
printf 'Error: Unable to create post. Character count is %s/%s' "$CHARCOUNT" "$CHARLIMIT"
|
||||
printf 'Tip: Install moreutils for vipe command.'
|
||||
exit 1
|
||||
else
|
||||
printf %s "$POST" | vipe
|
||||
fi
|
||||
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><i class=\"date\">$TIMESTAMP</i></p>"
|
||||
local HTML_POST
|
||||
HTML_POST="<p>$(echo "$POST" | sed 's!\n!</p><p>!g')</p>"
|
||||
printf '<article>\n%s\n%s\n</article>' "$HTML_DATE" "$HTML_POST" > "$THIS_NOW_DIR/index.html"
|
||||
cp "$THIS_NOW_DIR/index.html" "$THIS_NOW_DIR/$ID.html"
|
||||
cd "$THIS_BLOG_DIR"
|
||||
just _push_blog
|
||||
}
|
||||
masto
|
||||
now
|
||||
</pre>
|
||||
</article>
|
||||
Reference in New Issue
Block a user