2023-11-22 04:17:13 +00:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
|
|
mkdir -p ./posts
|
|
|
|
|
|
|
|
# get name and url and other values we need
|
2024-05-11 01:27:31 +00:00
|
|
|
printf "Title of blog post: "
|
|
|
|
read -r postTitle
|
|
|
|
printf "URL string for blog post: "
|
|
|
|
read -r postUrl
|
2023-11-22 04:17:13 +00:00
|
|
|
fullUrl='https:\/\/stillgreenmoss\.net\/blog\/'"$postUrl"
|
|
|
|
currentMonth=$(date +%B)
|
|
|
|
currentYear=$(date +%Y)
|
|
|
|
postDate=$(date --rfc-3339=date)
|
|
|
|
rssDate="$postDate"T00:00:00Z
|
|
|
|
|
|
|
|
# create link to post on blog.html
|
2023-12-16 00:54:15 +00:00
|
|
|
sed -i "s/<ul><!--boop-->/<ul><!--boop-->\n<li><a href=\"\/blog\/$postUrl\">$postTitle | $currentMonth $currentYear<\/a><\/li>/" blog.html
|
2023-11-22 04:17:13 +00:00
|
|
|
|
|
|
|
# create folder for the post in ./posts
|
|
|
|
mkdir -p ./posts/"$postUrl"
|
|
|
|
|
|
|
|
# prompt user for html for the post
|
|
|
|
"${EDITOR:-vi}" ./posts/"$postUrl"/post.html
|
|
|
|
|
2024-05-11 01:27:31 +00:00
|
|
|
# put post in the place it lives
|
|
|
|
mv ./posts/"$postUrl"/post.html ./posts/"$postUrl"/index.html
|
2023-11-22 04:17:13 +00:00
|
|
|
|
|
|
|
### update atom feed
|
|
|
|
|
|
|
|
# make new entry
|
|
|
|
cp ./feed/entry-template.atom ./feed/new-entry.atom
|
|
|
|
sed -i "s/TITLE/$postTitle/" ./feed/new-entry.atom
|
|
|
|
sed -i "s/URL/$fullUrl/g" ./feed/new-entry.atom
|
|
|
|
sed -i "s/UPDATED/$rssDate/" ./feed/new-entry.atom
|
|
|
|
|
|
|
|
# add entry to body.atom
|
|
|
|
cat ./feed/new-entry.atom ./feed/body.atom > ./feed/new-body.atom
|
|
|
|
mv ./feed/new-body.atom ./feed/body.atom
|
|
|
|
rm ./feed/new-entry.atom
|
|
|
|
|
|
|
|
# update date in head.atom
|
|
|
|
sed "s/UPDATED/$rssDate/" ./feed/head-template.atom > ./feed/head.atom
|
|
|
|
|
|
|
|
# make the whole feed
|
|
|
|
cat ./feed/head.atom ./feed/body.atom ./feed/foot.atom > ./feed/feed.atom
|