From 9bb2b1d06caa55426b647859cc4720dfb2b25882 Mon Sep 17 00:00:00 2001 From: dozens Date: Tue, 3 Oct 2023 13:47:30 -0600 Subject: [PATCH] init commit --- README.md | 41 +++++++++++++++- db/database.rec | 13 +++++ justfile | 62 ++++++++++++++++++++++++ templates/feed.mustache | 26 ++++++++++ templates/html.mustache | 102 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 db/database.rec create mode 100644 justfile create mode 100644 templates/feed.mustache create mode 100644 templates/html.mustache diff --git a/README.md b/README.md index c70315d..6d50371 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,42 @@ # consump -a convoluted pipeline of transformations that creates an html log of tv shows, podcasts, and music from a plain text database. +> it's like goodreads for *x* + +CC BY 4.0 2023 + +## about + +a convoluted pipeline of transformations that creates an html log of tv shows, podcasts, and music from a plain text database. + +this is what powers + +## features + +- plain text database! +- ed? +- produces html/css/javascript (js for filtering content type; css for lookin good; html because don't you want to read it??) +- rss feed + +## dependencies + +- recutils: +- mustache: +- csvjson (csvkit): +- jq: +- (optional) just: + +## getting started + +1. install dependencies + +2. update `templates/feed.mustache` and `templates/html.mustache` to include your own links and information for the generated rss and html. update the `up` recipe in the justfile to put the generated files wherever you want them. + +3. run `just new`. or copy the 'new' script from the justfile into a bash file and run it. NOTE: this script runs ed(1), because that's what I like. If you are not familiar with ed(1), change that part of the script to use $EDITOR. If you would *like* to be familiar with ed(1) then check out the links listed below. + +4. `just html` and `just rss` will build the html and rss respectively. Again, you can cobble these together from the justfile into a bash script if you don't have/want to install just. `just build` will assemble both the html and the rss. + +## resources + +- https://elly.town/d/blog/2015-10-03-ed-tutorial.txt +- http://tilde.town/wiki/learn/editors/ed.html +- https://tube.tchncs.de/w/g1ZKSzvDaqbpWQQgxGfW3z diff --git a/db/database.rec b/db/database.rec new file mode 100644 index 0000000..4079f45 --- /dev/null +++ b/db/database.rec @@ -0,0 +1,13 @@ +%rec: review +%doc: a review of some media i consumed +%key: id +%unique: id +%type: id int +%type: created date +%type: episode,title line +%typedef: type enum podcast listening watching playing +%auto: id created +%mandatory: title body +%allowed: id created type title episode body +%sort: created + diff --git a/justfile b/justfile new file mode 100644 index 0000000..1933e5e --- /dev/null +++ b/justfile @@ -0,0 +1,62 @@ +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:

/' -e 's/^\+ /+

/' -e '/

/ 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 diff --git a/templates/feed.mustache b/templates/feed.mustache new file mode 100644 index 0000000..f998a69 --- /dev/null +++ b/templates/feed.mustache @@ -0,0 +1,26 @@ + + + + dozens consumes + https://tilde.town/~dozens/consume/index.html + shows movies games podcasts and music + + {{#data}} + + <![CDATA[{{title}}]]> + https://tilde.town/~dozens/consume/index.html#{{id}} + {{created}} + https://tilde.town/~dozens/consume/index.html#{{id}} + + {{created}}

+ {{#episode}} +

Episode: {{.}}

+ {{/episode}} + {{{body}}} + ]]> + + + {{/data}} + + diff --git a/templates/html.mustache b/templates/html.mustache new file mode 100644 index 0000000..d64b52f --- /dev/null +++ b/templates/html.mustache @@ -0,0 +1,102 @@ + + + + + + + consump + + + +
+ +

All The Media I Consume

+

except for books

+
+
+ {{#data}} +
+

{{title}}

+

+ + + {{created}} + + {{#episode}} + | Episode: {{.}} + {{/episode}} + +

+ {{{body}}} +
+ {{/data}} +
+ + + + +