# show all options
default:
  just --list --unsorted

# build html from markdown
html:
  pandoc -f markdown+autolink_bare_uris -t html --standalone -H templates/header-includes.html --toc -o www/index.html src/piblog.md

# build rss feed from journal
rss:
  #!/usr/bin/env sh
  exec > wwww/feed.xml
  echo "<rss version=\"2.0\"><channel><title>piblog</title>"
  echo "<link>http://tilde.town/~dozens/piblog/index.html</link><description>just a little log about my raspberry pi</description><atom:link rel=\"self\" type=\"application/rss+xml\" href=\"http://tilde.town/~dozens/piblog/feed.xml\"/>"
  ed -s !'markdown src/piblog.md' << HEREDOC | recfmt -f templates/feeditem.template | m4
  /BEGIN/ka
  /END/kb
  1,'ad
  'b,d
  g/^<h2>/+s/^/note: /
  v/^note/s/^/+ /
  %s/+ <h2>/<h2>/
  %s_^<h2><time>\(.*\)</time> - \(.*\)</h2>_\\
  time: \1\\
  title: \2_
  g/^+ $/d
  ,w /dev/stdout
  Q
  HEREDOC
  echo '</channel></rss>'

# watch for changes
watch:
  ls src/piblog.md | entr just html

# build html and rss
build: html rss

# upload
up:
  rsync -zaP www/ tilde:public_html/piblog

# build and upload
all: build up