Created
October 4, 2008 13:50
-
-
Save ecarnevale/14750 to your computer and use it in GitHub Desktop.
A tributeto http://domokun.tumblr.com and an attempt to play with downloads in Shoes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Domokun.rb | |
# | |
# Created by Emanuel Carnevale on 2008-08-30. | |
# Copyright (c) 2008 emanuelcarnevale.com. All rights reserved. | |
# | |
require "hpricot" | |
require 'open-uri' | |
Shoes.app(:title => "Domo nom nom", :width => 550, :height => 600, :resizeable => false) do | |
stroke black | |
prefix = "http://static.emanuelcarnevale.com/domokun/" | |
status = para "" | |
#To avoid using static.emanuelcarnevale.com as a file repository, | |
#uncomment the following lines and comment the first download command. | |
# | |
#background "domo-kun.gif" | |
#image prefix + "home.gif" do | |
# alert "Made my Emanuel Carnevale as a tribute to http://domonomnom.tumblr.com" | |
#end | |
#show_food "shoes_nom.png", "Shoes nom nom nom" | |
download prefix + "domo-kun.gif", :save => "domo-kun.gif", | |
:start => proc { |dl| status.text = "Connecting..." }, | |
:progress => proc { |dl| status.text = "#{dl.percent}% complete" }, | |
:finish => proc { |dl| status.remove | |
background "domo-kun.gif" | |
image prefix + "home.gif" do | |
alert "Made my Emanuel Carnevale as a tribute to http://domonomnom.tumblr.com" | |
end | |
show_food prefix + "shoes_nom.png", "Shoes nom nom nom" | |
}, | |
:error => proc { |dl, err| status.text = "Error: #{err}" } | |
every(20) do | |
doc = Hpricot(open("http://domonomnom.tumblr.com/random")) | |
img=doc.search("//img[@class='nomnom']") | |
new_text = doc.search("//div[@class='caption']/p/a") | |
download img.first.attributes['src'], :save => "food.png" do |dl| | |
show_food "food.png", new_text.first.inner_html | |
end | |
end | |
def show_food image_name, voice_text | |
begin | |
@food.path = image_name | |
@voice_text.text = voice_text | |
rescue Exception => e | |
@food = image image_name | |
@food.move(174,161) | |
voice = flow :width => 111,:height => 41 do | |
@voice_text = inscription(voice_text) | |
end | |
voice.move(174+206+25,161-30) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment