44 lines
1.3 KiB
Bash
Executable file
44 lines
1.3 KiB
Bash
Executable file
#!/bin/sh -e
|
|
|
|
mkdir -p ./posts
|
|
|
|
# get name and url and other values we need
|
|
read -p "Title of blog post: " postTitle
|
|
read -p "URL string for blog post: " postUrl
|
|
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
|
|
sed -i "s/<ul>/<ul>\n<li><a href=\"\/blog\/$postUrl\">$postTitle | $currentMonth $currentYear<\/a><\/li>/" blog.html
|
|
|
|
# create folder for the post in ./posts
|
|
mkdir -p ./posts/"$postUrl"
|
|
|
|
# prompt user for html for the post
|
|
"${EDITOR:-vi}" ./posts/"$postUrl"/post.html
|
|
|
|
# make the post a page
|
|
cat head.html ./posts/"$postUrl"/post.html foot.html > ./posts/"$postUrl"/index.html
|
|
rm ./posts/"$postUrl"/post.html
|
|
|
|
### 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
|