103 lines
2.5 KiB
Plaintext
103 lines
2.5 KiB
Plaintext
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 [r]eading): " typeshort
|
|
read -p "title: " title
|
|
read -p "episode? " episode
|
|
tmpfile=$(mktemp)
|
|
$EDITOR "$tmpfile"
|
|
body=$(< "$tmpfile")
|
|
case "$typeshort" in
|
|
"o") type="podcast";;
|
|
"l") type="listening";;
|
|
"w") type="watching";;
|
|
"p") type="playing";;
|
|
"r") type="reading";;
|
|
*) echo "Unknown type!"; exit 1;;
|
|
esac
|
|
cat "$tmpfile"
|
|
read -p "[p]ublish or [d]raft: " flags
|
|
case "$flags" in
|
|
"d") flags="draft";;
|
|
"p") flags="published";;
|
|
*) echo "Unknown type!"; exit 1;;
|
|
esac
|
|
recins --verbose -t review \
|
|
-f "type" -v "$type" \
|
|
-f "title" -v "$title" \
|
|
-f "flags" -v "$flags" \
|
|
-f "episode" -v "$episode" \
|
|
-f "body" -v "$body" \
|
|
{{database}}
|
|
rm "$tmpfile"
|
|
alias n := new
|
|
|
|
# update recfeed
|
|
recfeed:
|
|
recset --verbose db/feed.rec -t feed \
|
|
-f "updated" -s "`date -Iseconds`"
|
|
recset --verbose db/feed.rec -t item \
|
|
-f "published" -s "`date -Iseconds`"
|
|
|
|
# rec -> json
|
|
@_json:
|
|
bin/abbr.sh {{database}} \
|
|
| recsel -e 'flags ~ "published"' \
|
|
| sed 's/\*\([^*]*\)\*/<em>\1<\/em>/g' \
|
|
| sed 's,http[s]*://[^ ]*,<a href="&">&</a>,g' \
|
|
| 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 recfeed rss
|
|
recset db/feed.rec -t feed -f updated -s `date -Iseconds` \
|
|
&& recset db/feed.rec -t item -f published -s `date -Iseconds`
|
|
|
|
# upload
|
|
up:
|
|
rsync -azP --exclude=.git www/ tilde:public_html/consume/
|
|
|
|
# build and upload
|
|
all: build up
|
|
|
|
# show posting frequency
|
|
sparkline:
|
|
#!/bin/zsh
|
|
for year in `recsel {{database}} -P created -C | xargs -I {} gdate -d"{}" +"%Y" | uniq`
|
|
do
|
|
printf "$year: "
|
|
join -j 2 -t' ' -e "0" -o 2.1 -a1 \
|
|
<(for month in `seq 1 12`; do printf "%d %d-%02d\n" 0 $year $month; done) \
|
|
<(recsel {{database}} -P created -e "created >> '$(gdate -d"$year-01-01")' && created << '$(gdate -d"$year-12-31 +1 days")'" -C \
|
|
| while read d; do gdate -d $d +"%Y-%m"; done \
|
|
| uniq -c \
|
|
| sed 's/^ *//') \
|
|
| xargs sparkline
|
|
done
|
|
|
|
# show drafts
|
|
drafts:
|
|
recsel -e 'flags ~ "draft"' {{database}} -p title,created,body
|