Monday, September 24, 2007

My Love of Haml, Sass, and Standalone Sass

I love using Haml in all of my Rails apps; it makes writing templates much easier and feels more elegant to me, even though the code may be a unusual at first:
.content_box
%h1= link_to(@page_title,show_url(@audio.show))
= render :partial => 'display', :locals => { :audio => @audio }
= graphic_link(@audio.show,'show_default')
But half the joy of Haml comes from using its excellent stylesheet engine, Sass. Sass adds a powerful abstraction layer on top of CSS, letting you use constant variables and simple expressions, and handling a lot of nested selector drudgery. It really feels like magic to use:
.storyteller_summary
:width 300px
:margin= 0 !one_gutter 0.25em 0
:float left
:clear left

.storyteller_photo
:float left

a
img.photo
:float left
:margin= 0 !half_gutter !half_gutter 0

becomes

.storyteller_summary {
width: 300px;
margin: 0 10px 0.25em 0;
float: left;
clear: left; }
.storyteller_summary .storyteller_photo {
float: left; }
.storyteller_summary .storyteller_photo a img.photo {
float: left;
margin: 0 5px 5px 0; }
.storyteller_summary p {
margin: 0 10px 0.25em 0px; }
.storyteller_summary p .block_description {
display: block;
margin: 0;
padding: 0; }
.storyteller_summary p .inline_description {
display: inline; }
.storyteller_summary p a.audio_icon img {
display: inline;
float: none;
margin: 0;
padding: 0; }
.storyteller_summary p strong {
margin: 0; }
Which is a beautiful thing. Recently I hired an excellent designer from elance.com to redesign this blog; while I can't say I executed her design perfectly, I got pretty close, and it really helped to use Sass in standalone mode. I had been using it exclusively as a Rails plugin, but as a gem it performs great as well. I wrote this little helper script to handle the transformation:
#!/usr/local/bin/ruby
require 'rubygems'
gem 'haml'
require 'sass'

template = IO.read('subelsky.sass')
open('subelsky.css','w+') { |file| file.write(Sass::Engine.new(template).render) }

Thursday, September 20, 2007

random_data gem released

I just released my first Ruby gem. I have a library of functions that I use for generating realistic data so I can have more meaningful examples to work with during development. So I used the newgem generator and hoe to package it all into a gem called random_data.

It provides a Random singleton class with a series of methods for generating random test data including names, mailing addresses, dates, phone numbers, e-mail addresses, and text. This lets you quickly mock up realistic looking data for informal testing.

Instead of:
>> foo.name = "John Doe"
You get:

>>
foo.name = "#{Random.firstname} #{Random.initial} #{Random.lastname}"
>> foo.name
=> "Miriam R. Xichuan"


The gem also includes code for phone numbers, e-mail addresses, physical addresses, and (primitive) text generation.

You can install it via:

sudo gem install random_data
For more details and full documentation, visit the rubyforge site.

Wednesday, September 5, 2007

What's an improv class like?

A couple of weeks ago Fox 45 came and did a segment on BIG's training program called "Challenge Yourself", where the lovely Patrice Harris took a one-hour version of our seven week training program. See the video below.

The video does a good job of showing the essence of what classes are like, except that they naturally focused on the zaniest moments of the class -- we spend just as much time working on other kinds of theatrical expression and making realistic scenes. Nonetheless I think it shows how much fun we have. Thanks to Fox 45 for covering us!

To view the video, visit the Fox 45 website, then click on the "Improv" option on the right-hand "Video List" menu.