consump/justfile

63 lines
1.3 KiB
Plaintext
Raw Normal View History

2023-10-03 19:47:30 +00:00
database := "db/database.rec"
# show all commands
default:
just --list --unsorted
# create new entry
new:
#!/usr/bin/env sh
read -p "type (p[o]dcast [l]istening [w]atching [p]laying): " typeshort
read -p "title: " title
read -p "episode? " episode
echo "CAUTION: Incoming ed!"
tmpfile=$(mktemp)
ed "$tmpfile"
body=$(< "$tmpfile")
rm "$tmpfile"
case "$typeshort" in
"o") type="podcast";;
"l") type="listening";;
"w") type="watching";;
"p") type="playing";;
*) echo "Unknown type!"; exit 1;;
esac
recins --verbose -t review \
-f "type" -v "$type" \
-f "title" -v "$title" \
-f "episode" -v "$episode" \
-f "body" -v "$body" \
db/database.rec
# rec -> json
_json:
recsel -S created {{database}} \
| sed -e 's/^body: /body: <p>/' -e 's/^\+ /+ <p>/' -e '/<p>/ s/$/<\/p>/' \
| rec2csv \
| csvjson \
| jq 'reverse \
| map(.body |= gsub("\n"; "\n\n"))' \
| jq '. | { data: . }'
# html
html:
just _json \
| mustache - templates/html.mustache \
> www/index.html
# rss
rss:
just _json \
| mustache - templates/feed.mustache \
> www/feed.xml
# build html and rss
build: html rss
# upload
up:
rsync -azP --exclude=.git www/ tilde:public_html/consume/
# build and upload
all: build up