#!/bin/sh -e

if [ -z "$1" ]; then
	thought=$(cat | xargs)
elif [ -f "$1" ]; then
	thought=$(cat "$1" | xargs)
else
	thought="$*"
fi

date=$(date)
html_fmt='\t\t\t\t<h3>'"${date}"'<\/h3>\
\t\t\t\t<p>\
\t\t\t\t\t'"${thought}"'\
\t\t\t\t<\/p>\
'
gmi_fmt='\
\
## '"${date}"'\
\
'"${thought}"

sed -i '' -e '/<!-- thoughts here -->$/{n;s/^/'"${html_fmt}"'/;}' \
	"$HOME"/dev/web/jozanofastora.xyz/thoughts.html
git -C "$HOME"/dev/web/jozanofastora-www add -u
git -C "$HOME"/dev/web/jozanofastora-www commit -m "Thought: ${date}"
git -C "$HOME"/dev/web/jozanofastora-www push

sed -i '' -e '15i '"${gmi_fmt}" \
	"$HOME"/dev/web/jozan_gemini/thoughts.gmi
git -C "$HOME"/dev/web/jozanofastora-gemini add -u
git -C "$HOME"/dev/web/jozanofastora-gemini commit -m "Thought: ${date}"
git -C "$HOME"/dev/web/jozanofastora-gemini push

vps