Webby on Heroku
The $20 a month more for beer dream
I've been hosting this blog on Slicehost for a while now. They have been a good host, but a full slice is more than I need these days.
The plan
After a bit of thinking, I realised I could pretty easily move this blog across to Heroku. It's just a bunch of static files created by Webby, so I figured a tiny Sinatra app would be just the trick.
The problem
Sinatra is perfect for these kind of tiny jobs, and ended up working without too much effort. I had a bit of a wrestle with Heroku initially. I couldn't seem to get heroku to read my articles. They were stored in a directory called "output".
The solution
After a while, I tried tried renaming the directory to "public". That seemed to do the trick. Heroku mentions that you can read the filesystem but I couldn't find too much mention of exactly what you can read. A directory called "public" seems like a pretty safe bet to be readable forever though. I told Webby to start buiding to the public directory instead. Here's my SiteFile:
SITE.blog_dir = "articles" SITE.output_dir = "public"
The app
After getting that working, the script worked on Heroku. It's just as simple as I'd hoped it would be.
require "rubygems" require "sinatra" DIR = 'public' set :public, DIR get '/' do read('index.html') end get '/articles/*' do read('articles', params["splat"], 'index.html') end def read(*parts) File.read(File.join([ DIR ] + parts)) end
Not much to it - read index.html for the root path, or read the article page for any article. It'd probably be possible to merge these into a single route, but it seems like that would just complicate things unecessarily.