# Written for FreeBSD make(1), or pmake. Not tested with GNU make.
POST_T = templates/template.html
INDEX_HEAD_T = templates/index_foot.html
INDEX_FOOT_T = templates/index_head.html
.PHONY: serve post clean
all: index.html
serve:
python3.7 -m http.server 3000
post:
@read -p "Title: " TITLE; \
read -p "Category: " CATEGORY; \
SHORT_DATE=`date +"%Y-%m-%d"`; \
LONG_DATE=`date +"%a, %d %b %Y"`; \
mkdir -p posts/$$CATEGORY; \
FILENAME=posts/$$CATEGORY/$$SHORT_DATE-`printf "$$TITLE" | tr -Cs "[:alnum:]" '-' | tr "[:upper:]" "[:lower:]"`.html; \
cp $(POST_T) $$FILENAME; \
sed -i '' "s/{{ title }}/$$TITLE/g" $$FILENAME; \
$$EDITOR $$FILENAME; \
sed -i '' "s##
$$LONG_DATE
\2