Using make to live-edit statocles posts on update

Tags:

When I write a blog entry, I usually end in the following loop:

  1. Write/update the .markdown file
  2. Regenerate the HTML using statocles build; this regenerates the whole site
  3. Refresh my browser to view the current page

Glueing together Mojo::File::ChangeNotify and App::Mojo::AssetReloader and a nice default rule using make for changed files makes updating the browser automatic and somewhat instant.

The Makefile

BLOGPOSTS=$(wildcard blog/*/*/*/*/*.markdown)
HTML=$(patsubst %.markdown,.statocles/build/%.html,$(BLOGPOSTS))

all: $(HTML)

%.html: $(patsubst $(patsubst .statocles/build/,,$<),.html,.markdown)
    statocles build

The main "problem" now is opening the loong URL in the browser manually. Having make also work with processes ( via /proc/(pid)/cmdline ) is something for a later day.

It would be great if statocles supported building a single page, but so far, I've resolved to rebuilding the whole site every time.