SqueezeBox is a Ruby-language web framework for small websites.
Sometimes Rails is too sophisticated to set up something simple like a poll or quiz for livejournal. Squeeze Box is like 1995; it routes by the file system. Squeeze Box makes large projects painful but small ones simple.
Using SqueezeBox
Create a directory for your web page. There are two things to put in there
-
initialize.rb, will be called on to load external libraries, models, or anything else needed to use your site.
-
public/ the document root directory
Inside of public/ you place .erb files. The additionally you may place a .rb file of the same basename which contains code that will be called before your erb file loads.
Example:
Local Web
/mywebsite/public/happy.erb http://mywebsite.com/happy
/mywebsite/public/happy.rb
/mywebsite/public/index.erb http://mywebsite.com/
/mywebsite/public/index.rb
/mywebsite/public/blah/index.erb http://mywebsite.com/blah
/mywebsite/public/blah/index.rb
The last line of code of the .rb file, if it exists, is tells the SqueezeBox what to do with the request. Typically this command will be ‘render’ which means ‘render the .erb file with the same basename’ but it could just be a string of JSON or a redirect.
Example Application
Please look in examples/quotes for a complete application. To start this run the squeeze_box command with the examples/quotes directory as argument. Something like this:
lakshmi:~/Projects/squeeze_box% bin/squeeze_box -p 3000 examples/quotes
Squeeze Box running at http://0.0.0.0:3000
Root: /Users/ry/Projects/squeeze_box/examples/quotes
Future
My plan is to add the basic features necessary for every web application, cookies, sessions, logging. I love haml and will add support for it. Beyond that I want to follow the thin server philosophy and not touch anything else; no plug-in framework, no generators, and certainly no authorization schemes. I don’t even want to add ActiveRecord as a dependency. This is to be a spartan and dirty interface to mongrel. The SVN repo is at tinyclouds.org/svn/squeeze_box/trunk
Bug reports, patches, or comments are gladly accepted at [email protected]