#!/bin/sh note=$1; token="423420a2d7df3240254ced2fb29df2a72b07632ad4d7e0e98e44cfb1cda0b0aef8abe80034bb757d8c30917efe34ef31fdc57d50dfbbdb0e481467ebf4018cdc"; # Setup cd ~/Documentos # Download once curl -s "http://localhost:41184/notes/${note}?token=${token}" | jq -r '.body' | tee ~/Documentos/${note}.md; # Upload: while inotifywait ~/Documentos/${note}.md; do curl \ -s \ -X PUT \ -d "$(jq -sR '{body:.}' ${note}.md)" \ "http://localhost:41184/notes/${note}?token=${token}" | jq -r 'del(.body)' ; pandoc \ -s \ --template artigo-fdusp \ -f markdown \ -t html5 \ -o ~/Documentos/${note%.md}.html \ ~/Documentos/${note}.md ; case "$2" in latex) pandoc \ -f markdown \ -t latex \ -o ~/Documentos/${note}.pdf \ --pdf-engine=lualatex \ -N \ --toc \ -s \ -V date=$(date -Is) \ -V toc-title="Sumário" \ --template artigo-fdusp \ -V mainfont="DejaVu Serif" \ -V lang=pt-br \ -V margin=1in \ -V documentclass="article" \ -V classoption="oneside" \ -V papersize=a4 \ ~/Documentos/${note}.md ;; html) wkhtmltopdf ~/Documentos/${note}.html ~/Documentos/${note}.pdf ;; esac done; # Download: # while (true); do # curl -s "http://localhost:41184/notes/${note}?token=${token}" | jq -r '.body' | tee ~/Documentos/${note}.md | pandoc -s --template artigo-fdusp -f markdown -t html5 -o ~/Documentos/${note%.md}.html ; # date -Is ; # sleep 3; # done #