#Feel free to re-use code
# => ~Mark Fayngersh

Shoes.setup do
  gem 'hpricot'
end

require 'hpricot'
require 'open-uri'

Shoes.app :title => "a wolfram alpha ruby frontend", :resizable => true do
  stack do
   background goldenrod
   title ":w|a => ruby"
  end
  stack :height => 58 do
    background darkslategray
    @input = edit_line "input......", :width => 400
    button "wolf" do
      doc = Hpricot(open(URI.escape("http://www1.wolframalpha.com/input/?i=#{@input.text}")))
      doc.at("div#results").search("div[@class='output'] img").each do |pod|
        @results.append do
          image pod.attributes['src']
        end
        debug pod
      end
    end
  end
  @results = stack do
    background white
    tagline "results"
  end
  stack :height => 30, :width => 140 do
    button "clear results" do
      @results.clear do
        background white
        tagline "results"
      end
    end
  end
end