Home
ryah - August 13th, 2007 [entries|archive|friends|userinfo]
ryah

[ website | tiny clouds ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

August 13th, 2007

SqueezeBox [Aug. 13th, 2007|07:04 pm]
[Tags|, ]


SqueezeBox


A Ruby-Language Web Framework For Small Websites


"It has a logo, it must be awesome."


Version 0.0.0



Rails is too sophisticated to set up something simple like a quiz for livejournal or even a homepage and PHP is too ugly to even consider. SqueezeBox is little more Mongrel with file system based routing to eRubis templates. It's a quick and dirty (but not PHP dirty) solution for small websites.

There are several niceties added to this basic template + document root setup. Instead of putting your logic inside your template, like you would with PHP, SqueezeBox recognizes a separate logic file to be called before it loads the template. This allows you room to load ActiveRecord models or do calculations. These logic files return to the webserver the last line of their execution. (Its functional!) If render() is the last line, it will load the template associated with that logic file. If a string containing, say, JSON is returned, then the JSON will be the body of the response and the template ignored. In fact, any object that contains a read method can be returned and the server will stream the response.

A file called initialize.rb is loaded when the website starts, in there you can define classes or functions that will be used throughout the site. database.yml is looked for in case you plan on using ActiveRecord.

There are several predefined Ruby exceptions which correspond to common HTTP errors like NotFound and MethodNotAllowed, and Forbidden. For example one could do:
raise MethodNotAllowed unless @request.post?
Raising one of these exceptions will display a default error page - but these error pages can be overridden by placing a template at document_root/exceptions/not_found.erb or document_root/exceptions/method_not_allowed.erb. The default error message can be overridden at document_root/exceptions/index.erb.

My plan is to add the basic features necessary for every web application, cookies, sessions, logging, etc. I love Haml and will add support for it but beyond that I want to follow the thin server philosophy and do much: no plug-in framework, no generators, and certainly no authorization schemes. SqueezeBox is meant to be fast.

PLEASE TRY IT OUT! THANKS



SqueezeBox-0.0.0.tgz
svn repository

The tgz file contains an example application. Run it like this:
tar -zxvf SqueezeBox-0.0.0.tgz
cd SqueezeBox-0.0.0
bin/squeeze_box examples/quotes 


Much code was shamelessly taken from Zed Shaw, Ezra Zygmuntowicz, _Why, and others
x-posted here and here
Link2 comments|Leave a comment

navigation
[ viewing | August 13th, 2007 ]
[ go | Previous Day|Next Day ]

Advertisement