jdan / tinman

A tiny static-ready blog engine based on the toto library
http://jdan.github.io/tinman/the-shiniest-blog-engine-in-oz
MIT License
34 stars 0 forks source link

Live reload #1

Open jdan opened 9 years ago

jdan commented 9 years ago

Currently you need to restart a server or rebuild every time you edit a file, this gets annoying pretty quickly.

Tinman should watch for files and:

I'm thinking we add a simple --live option for this. I don't know if it should be the default behavior.

allofthenorthwood commented 9 years ago

Installing inotify tools and running the server using this ./tinman-server bash file instead of tinman server has worked in the interim. :)

#! /bin/bash
DIRECTORY_TO_OBSERVE="."
function block_for_change {
  inotifywait -r \
    -e modify,move,create,delete \
    $DIRECTORY_TO_OBSERVE
}

TINMAN_PID=""

function build {
  kill $TINMAN_PID
  tinman server &
  TINMAN_PID=$!
}

build
while block_for_change; do
  build
done
jdan commented 9 years ago

@MichelleTodd yeah tinman server as a concept is a bit silly, isn't it? If anything it should just spin up a simple static server instead of loading some templates into memory like it does now.

I think a combination of tinman build and tinman build --watch could replace it all together. Live-reloading on the client would be nifty too :)