#!/usr/bin/env bash # creates a local phlog entry # requires phlogmap, phlogrss and phlogsend # config src="$HOME/src/gopher/phlog/" editor="micro +1:1" mkdir -p "$src/$(date +%Y)" # save location pushd "$(pwd)" || exit # set up article mkdir -p "$HOME/.tmp" cd "$HOME/.tmp" || exit editfile="/tmp/phlogtmp.txt" articledate="$(date -R)" filedate="$(date +%Y-%m-%d-%H-%I)" article="/tmp/article.tmp" read -rp "Enter title: " title filetitle=$(echo "$title" | sed "s/ /-/g" | sed "s/[^A-Za-z0-9._-]//g") articlename="$filedate-$filetitle.txt" # edit text eval "$editor $editfile" cat "$editfile" > "$article" header="$title\n$articledate\n\n" sed -i "1s/^/$header/" "$article" dest="$src/$(date +%Y)/$articlename" mv "$article" "$dest" echo -e "\n\n␌" >> "$dest" rm $editfile clear cat "$dest" echo "--------------------------" read -rp "Do you want to correct this text? : " choix1 if [ "$choix1" != "n" ] ; then clear eval "$editor $dest" fi echo "Article saved as $dest" echo "--------------------------" read -rp "Update phlog gophermap, add to the rss feed, and upload it all? ; " choix2 if [ "$choix2" != "n" ] ; then phlogmap; phlogrss ; phlogsend fi # return popd || exit echo "Done."