I do a few development jobs on the side for friends. One such friend got in touch with me about a week ago wanting me to add a form emailer to his static html site (I developed it using Webby). My first thought was to set it up as a Rails app, but that seemed a little overkill for adding a single feature, especially when Webby gives me layouts for static pages and with Rails I'd have to put a solution for that together. Then I thought about using Widget Finger, but I really didn't want to push him to pay for it, especially not when I already had the site hosted on a virtual private server that we have for Hello Theory.
That's when it hit me. I could use Webby to generate an app that was mostly static, but that used Sinatra to handle the form emailer. Starting with my original Webby site, here's how I did it.
First, I added a folder to the project's content folder named public, and moved all of the existing content files into that folder.
mkdir content/public
mv content/* content/public
Next, I added a new Rackup file (config.ru) to the content folder based on these directions.
require 'rubygems'
require 'sinatra'
root_dir = File.dirname(__FILE__)
set :environment, ENV['RACK_ENV'].to_sym
set :root, root_dir
set :app_file, File.join(root_dir, 'simgins.rb')
disable :run
run Sinatra::Application
I set up my Sinatra script to send email using Pony and tested it. There's a great example of using Pony to send email with Sinatra in the Sinatra FAQ.
Finally, I deployed using Webby's deploy feature:
webby deploy
The combination seems to be working like a charm, and keeps things way simpler for static page development than Rails would have. One small issue that I have is that I haven't come up with a good way to touch the tmp/restart.txt file to get Passenger to reload the app each time I deploy, but I've got a few ideas on that.