# \[ANN\] SqueezeBox, a simple file system based routing framewo

**URL:** <https://www.ruby-forum.com/t/ann-squeezebox-a-simple-file-system-based-routing-framewo/111953>\
**Category:** Rails\
**Created:** [August 13, 2007, 8:20pm UTC](https://www.ruby-forum.com/t/ann-squeezebox-a-simple-file-system-based-routing-framewo/111953 "2007-08-13T20:20:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RyRyRy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df788c/32.png) [@RyRyRy](https://www.ruby-forum.com/u/RyRyRy)\
**Post date:** [August 13, 2007, 8:20pm UTC](https://www.ruby-forum.com/t/ann-squeezebox-a-simple-file-system-based-routing-framewo/111953/1 "2007-08-13T20:20:45Z")

</div>

SqueezeBox is a simple file system based routing framework for erubis  
templates.

It aims for a couple of niceties as well:

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. 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 SqueezeBox will  
stream the response. (This cute behavior is stolen from Merb.)

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 the 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, for  
example, 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. (Another behavior stolen from  
Merb)

Please try it out! Thanks!

[http://four.livejournal.com/789870.html](http://four.livejournal.com/789870.html)  
[http://s3.amazonaws.com/four.livejournal/20070813/SqueezeBox-0.0.0.tgz](http://s3.amazonaws.com/four.livejournal/20070813/SqueezeBox-0.0.0.tgz)  
[http://tinyclouds.org/svn/squeeze\_box/trunk](http://tinyclouds.org/svn/squeeze_box/trunk)

ry
