Friday, December 7, 2007

Baby Steps

Here's a no-frills Shoes app which shows you a text version of the "Shoes in its Entirety" documentation.

Copy and paste the code here:


class Entirety < Shoes
Shoes.app :width => 523, :height => 716 do
# teh data
ENTIRETY = YAML.load_file('samples/entirety.yaml')
# adapted from _why's book example; clunky results
entirety_hash = {}
ENTIRETY.each {|thing| entirety_hash[thing[0]] = thing[1]}

# teh dropdown
@box = list_box :items => ENTIRETY.map {|thing| thing[0]} do
contents.each { |option| option.hide if option.is_a? Shoes::Stack }
instance_variable_get("@#{@box.text.gsub(/ |\&/, "_")}").show
end

# teh infos
entirety_hash.each do |category, text|
instance_variable_set("@#{category.gsub(/ |\&/, "_")}", stack :hidden => true do
text.split(/\n+/).each do |p|
para p
end
end)
end
end
end



Or download it here: http://s3.amazonaws.com/giles/entirety.rb

The data file is here:

http://s3.amazonaws.com/giles/entirety.yaml