Re.Mark

My Life As A Blog

Ruby Tuesday #12 : Twitter on Shoes

with one comment

Last week I hoped I would have finished my Twitter client in Shoes by now.  Unfortunately, I ran into some issues with Shoes (such as redraws where every control ends up superimposed on top of itself but pushed out to the left and down.)  The most serious of these issues is its frequent reluctance to allow me to enter text into text boxes (or edit_lines in shoe parlance.)  I’ve found that if I click off the Shoes window and back in, it will let me enter text and click buttons.  Not ideal, but it seems to work – I even managed to tweet using my new client.  So, without further ado, here is the code:

require 'Twitter'

Shoes.app :title => "Twitter Shoes", :height => 750, :width => 750 do
    flow :margin => 10 do
         stack :width => 700, :height => 90, :top => 10, :left => 10 do
            flow :margin => 5 do
                para "Username"
                @username = edit_line :height => 30, :width => 120, :left => 100
            end
            flow :margin => 5 do

            end
            flow :margin => 5 do
                para "Password"
                @password = edit_line :secret => true, :height => 30, :width => 120, :left => 100
            end
        end
        stack :height => 90, :top => 100, :left =>10, :width => 700 do
            flow :margin => 5 do
                para "Status", :top => 10
                @status = edit_line :height => 30, :width => 270, :left => 100, :top => 10
                button "Update", :height => 30, :width => 100, :left => 400, :top => 10 do
                    username = @username.text
                    password = @password.text
                    status = @status.text
                    if username.empty?
                        alert "You must enter a username."
                    elsif password.empty?
                        alert "You must enter a password."
                    elsif status.empty?
                        alert "You must provide a status."
                    else
                        client.update(status, username, password)
                    end
                end
                button "Update Timeline", :height => 30, :width => 120, :left => 550, :top => 10 do
                    username = @username.text
                    password = @password.text
                    if username.empty?
                        alert "You must enter a username."
                    elsif password.empty?
                        alert "You must enter a password."
                    else
                        timeline = ""
                        translator.xml_to_tweets(client.download_friends_timeline(username, password)).each do |tweet|
                            timeline << "#{tweet.user.screen_name} says #{tweet.text}\n\n"
                        end
                        @tweets.replace timeline
                    end
                end
            end
        end
        stack :height => 550, :top => 200, :width => 700, :margin => 10, :left => 10 do
            background "#eee"
            @tweets = para ""
        end
    end
end

You can also download it here.  Most of the changes are in the layout.  I started the layout from scratch.  I'd suggest reading the manual that you can find here.  It's not exactly comprehensive, but it points you in the right direction.  If you're like me, you'll find that changing one value has unexpected and seemingly unconnected consequences.  Still, by changing one thing at a time and sticking to a very basic design I got there.

So, you can tweet from Shoes.  Shoes uses Ruby and has some intriguing ideas (like the HTMLish layout concepts), but there's a lot to be said for a good visual designer with drag and drop.   Gets the same job done more quickly.  Add the ability to edit by hand and we're all happy.  I'm still in search of my ideal Twitter client, though...

About these ads

Written by remark

July 1, 2008 at 6:34 pm

One Response

Subscribe to comments with RSS.

  1. I still love Google Talk as a Twitter client, if only Twitter’d restore IM service..

    Ina

    July 4, 2008 at 7:04 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: