Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/samples/expert-definr.rb
blob: 169e07a7740b8faf070270a38b9a65f024ce6e59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Shoes.app :title => "Dictionary, powered by Definr", :width => 370, :height => 320 do
  stack do
    background red, :height => 60
    flow :margin => 20 do
      caption "Define: ", :stroke => white
      @lookup = edit_line
      button "Go" do
        download "http://definr.com/definr/show/#{@lookup.text}" do |dl|
          doc = dl.response.body.gsub(' ', ' ').
              gsub(%r!(</a>|<br />|<a href.+?>)!, '').
              gsub(%r!\(http://.+?\)!, '').strip
          title, doc = doc.split(/\n+/, 2)
          @deft.replace title
          @defn.replace doc
        end
      end
    end
    stack :margin => 20 do
      @deft = subtitle "", :margin => 10
      @defn = para ""
    end
  end
end