Skip to content

Instantly share code, notes, and snippets.

@jahands
Created November 12, 2015 16:26
Show Gist options
  • Save jahands/68723c588e848c5a5e94 to your computer and use it in GitHub Desktop.
Save jahands/68723c588e848c5a5e94 to your computer and use it in GitHub Desktop.
WorkFlowy -> Git -> Rendered HTML
#!/bin/bash
# Don't want to do a few things if DEBUG=="debug"
DEBUG=$1
# CD to the directory containing the notes repo.
cd /home/gitworkflowy/gitwf
if [ "$DEBUG" != "debug" ]; then
./main # Source: https://github.com/jacobhands/gitworkflowy/blob/master/main.go
fi
cd notes # The repo where we keep the notes including WorkFlowy.md
# Generate new file name.
# This generates a random file name so the public link isn't guessable.
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 128 | head -n 1)
FILENAME="_i_${NEW_UUID}_i_.html"
# This is the replacement string for replacing the old filename with new.
SUBSTR="s/_i_.*_i_.html/$FILENAME/g"
echo "NEW SUBSTR == " $SUBSTR
# The folder to put the rendered html file in (eg. the public nginx folder.)
EXPORT_PATH_BASE="/usr/share/nginx/html/render.git.example.com/workflowy/i"
EXPORT_PATH="$EXPORT_PATH_BASE/$FILENAME"
# Remove the old html rendered file.
rm $EXPORT_PATH_BASE/*
# grip renders markdown to github-like html.
# See https://github.com/joeyespo/grip
grip WorkFlowy.md --wide --export $EXPORT_PATH --title="WorkFlowy.md"
# pull from origin before editing
git pull
# Set the new link in the README.md to make the secret URL accessable to us.
sed -i -e $SUBSTR README.md
# Do git stuff
# Grab the date for use in the commit message.
DATE=$(date -u +"on %Y.%m.%d @ %H:%M UTC")
if [ "$DEBUG" != "debug" ]; then
git add WorkFlowy.md
git add README.md
git commit -m "[Auto] Update WorkFlowy.md - $DATE"
git push # Push back to origin.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment