code over config
Joshua HawxwellA long (long) time ago I wrote something called henshin to generate static sites. It solved the problem that jekyll wasn’t generic enough, there wasn’t much to configure. Well actually there was, but…
Anyway, it quickly became this insane annoyance to (remember how to) setup in a
useful manner. Instead of using yaml to configure it you used ruby — because
it is so much richer — which lead to you reïmplementing parts of henshin in
a magic init.rb
file.
Reading through the code scares me sometimes…
module Henshin
class File
# @abstract You will want to implement {#raw_text}, {#path} and maybe
# {#text}.
#
# This class implements all the functionality that is required to build or
# serve a file. {Abstract} instances do not relate to a file in the file
# system, use {Physical} in this case.
class Abstract
include Henshin::Helpers, Safety, Comparable
extend Attributes
In the end I never even used it to make sites. It was always going to be quicker to write a little script than look back and work out how henshin was even meant to work.
Fast-forward to a few months ago and I decided to extract some of the common logic in scripts I’d written for generating little sites, for example hawx.me/stuff. These usually ended up being a few hundred lines of ruby that read some input, ran that through some templates and spat out some html.
A couple had the ability to serve the site locally and push it to a web server. These are generally the messy parts so I pulled them out into serveable and publishable, which do about 80% of the hard work of writing a script to generate a static site.
The great thing about this approach is that you don’t have to remember how to customise the available template engines, or how to change the way posts are read, or … anything. You only need to understand how two small gems work, the 20% glue code in between for generating the html is yours.
Code over config.