Nanoc

I’ve migrated the site to nanoc. While entirely unnecessary, I also changed the style, binned all of the old code I wrote, and broke a couple pages in the process. Here’s some nice things nanoc does:

Filters

Nanoc has a great concept called filters. In the Rules DSL, they’re transformations applied to input to create output, and they’re very easy to write. Images on this site are now scaled and dithered/quantized on build, making it a doddle to change the size and palette of images while keeping the source image in-tree:

compile '/images/**/*' do
  filter :scale, size: 640
  filter :dither, palette: "f5f5f5,91a3aa,4c5671,050505"
  write @item.identifier.without_ext + '.jpg'
end

Deploy

nanoc has a deploy command. Granted, it’s just rsync I’m using. But it’s rather nice to have that bundled in. I wouldn’t expect it to be difficult to build in something like Bolt for remote deployment.

deploy:
  default:
    kind: rsync
    dst: "/var/www/html"
    options: [ '-aP', '--delete-after' ]

Line Numbers

nanoc bundles in CodeRay, and it can be triggered like any other filter:

filter :colorize_syntax, coderay: { line_numbers: :table }

I don’t post a lot of code on my site, usually just miscellaneous scripts I’d probably lose if I didn’t intentionally put them somewhere - but it’s nice to have line numbers with anchors (even if the anchors only work for the first code box).

Markdown

nanoc uses Kramdown to parse markdown into HTML. Which means I can go back to writing stuff in markdown instead of raw HTML. It’s never been a deterrent to writing content for this site. I really am just dumping idle thoughts into a bucket here. But markdown is much less work.

Conversion of existing articles was done with html-to-markdown, a bit of shell scripting to create article metadata, and some manual checking.

One downside

Sadly, this MVC to static-site change, coupled with the change from HTML ERB to markdown, does mean that pages like Alternative Date/Time Systems no longer works. I may be inclined to fix it at some point, though probably with client-side Javascript. If I can stomach it.