20251221205021 push

This commit is contained in:
2025-12-21 20:50:21 -08:00
parent ed3bf05c1a
commit 24a1a111b9
33 changed files with 44 additions and 42 deletions

View File

@@ -14,17 +14,19 @@
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
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' "$CHARCOUNT" "$CHARLIMIT"
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
printf %s "$POST" | vipe
POST="$(printf %s "$INPUT" | vipe)"
fi
else
POST="$INPUT"
fi
masto() {
if [[ "$(command -v toot)" = "" ]]; then
@@ -43,13 +45,13 @@ now() {
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>"
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%s\n%s\n</article>' "$HTML_DATE" "$HTML_POST" > "$THIS_NOW_DIR/index.html"
HTML_POST="<p<$(echo "$POST" | sed 's!\n!</p<<p<!g')</p<"
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
just _push-blog
}
masto
now