Files
website/content/blog/now.html
2025-12-21 20:50:21 -08:00

60 lines
3.2 KiB
HTML

<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&#39;t particularly like a permanent, endlessly long file for a microblog. I prefer treating microblog posts as temporary and ephemeral, that&apos;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 blog.sh 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 something like this:</p>
<pre>post.sh &quot;Extremely thoughtful message for my thousands of followers&quot;</pre>
<p>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=&quot;$(date &apos;+%Y-%m-%d %H:%M:%S %:z&apos;)&quot;
ID=&quot;$(date -d &quot;$TIMESTAMP&quot; &apos;+%Y%m%d%H%M%S&apos;)&quot;
INPUT=&quot;$*&quot;
CHAR_COUNT=&quot;$(printf &apos;%s&apos; &quot;$INPUT&quot; | wc -c)&quot;
CHAR_LIMIT=&quot;500&quot;
if [[ &quot;$CHAR_COUNT&quot; -eq 0 ]] || [[ &quot;$CHAR_COUNT&quot; -gt &quot;$CHAR_LIMIT&quot; ]]; then
if [[ &quot;$(command -v vipe)&quot; = &quot;&quot; ]]; then
printf &apos;Error: Unable to create post. Character count is %s/%s&apos; &quot;$CHAR_COUNT&quot; &quot;$CHAR_LIMIT&quot;
printf &apos;Tip: Install moreutils for vipe command.&apos;
exit 1
else
POST=&quot;$(printf %s &quot;$INPUT&quot; | vipe)&quot;
fi
else
POST=&quot;$INPUT&quot;
fi
masto() {
if [[ &quot;$(command -v toot)&quot; = &quot;&quot; ]]; then
printf &quot;Error: Unable to post to Mastodon, toot command not found.\n&quot;
else
toot post &quot;$POST&quot;
fi
}
now() {
local THIS_BLOG_DIR
THIS_BLOG_DIR=&quot;$HOME/Documents/blog&quot;
source &quot;$THIS_BLOG_DIR/config.env&quot;
local THIS_NOW_DIR
THIS_NOW_DIR=&quot;$THIS_BLOG_DIR/$NOW_DIR&quot;
local THIS_TEMPLATES_DIR
THIS_TEMPLATES_DIR=&quot;$THIS_BLOG_DIR/$TEMPLATES_DIR&quot;
test -d &quot;$THIS_NOW_DIR&quot; || mkdir -p &quot;$THIS_NOW_DIR&quot;
local HTML_DATE
HTML_DATE=&quot;&lt;p id=\&quot;$ID\&quot;&gt;&lt;i class=\&quot;date\&quot;&lt;$TIMESTAMP&lt;/i&lt;&lt;/p&lt;&quot;
local HTML_POST
HTML_POST=&quot;&lt;p&lt;$(echo &quot;$POST&quot; | sed &apos;s!\n!&lt;/p&lt;&lt;p&lt;!g&apos;)&lt;/p&lt;&quot;
printf &apos;&lt;article&lt;\n&lt;h1&lt;Now&lt;/h1&lt;\n%s\n%s\n</article&lt;&apos; &quot;$HTML_DATE&quot; &quot;$HTML_POST&quot; &lt; &quot;$THIS_NOW_DIR/index.html&quot;
cp &quot;$THIS_NOW_DIR/index.html&quot; &quot;$THIS_NOW_DIR/$ID.html&quot;
cd &quot;$THIS_BLOG_DIR&quot;
just _push-blog
}
masto
now
</pre>
</article>