Skip to content

Instantly share code, notes, and snippets.

@greatseth
Created September 9, 2008 00:28
Show Gist options
  • Save greatseth/9578 to your computer and use it in GitHub Desktop.
Save greatseth/9578 to your computer and use it in GitHub Desktop.
def timeline
setup_cred
# @htmlentities = HTMLEntities.new
@twitter = Twitter::Base.new *@cred
# @friends = twitter_api { @twitter.friends.map(&:name) }
# clear do
background white
@form = flow :margin => [0,0,0,5] do
background fail_to_white
@status = edit_box :width => -(10 + gutter), :height => 35, :margin => [5,5,5,0] do |s|
if s.text.chomp!
update_status
else
@counter.text = (size = s.text.size).zero? ? "" : size
@counter.style :stroke => (s.text.size > 140 ? red : @counter_default_stroke)
end
end
@counter_default_stroke = black
@counter = strong ""
para @counter, :size => 8, :margin => [0,8,0,0], :stroke => @counter_default_stroke
end
@timeline_stack = stack :height => 500, :scroll => true
@footer = flow :height => 28 do
background black
with_options :stroke => white, :size => 8, :margin => [0,4,5,0] do |m|
# TODO
# @collapsed = check do |c|
# end
# m.para "collapsed"
# XXX
# This used to work. Something changed in Shoes and now any
# time after the first load of timeline,
# the rendering gets fucked up when :reload_timeline fires.
# using :visit fixes this but fucks up other plans
# because it resets instance variables, which is a
# problem for how the @public check works.
@public = check do |c|
@which_timeline = (:public if c.checked?)
reload_timeline
# visit "/timeline"
end
m.para "public"
m.para " | ", link("setup", :click => "/setup")
end
end
# end # clear
###
reload_timeline
reset_status
every 60 do
reload_timeline
# visit "/timeline"
end unless testing_ui?
end
def reload_timeline
load_timeline
@timeline_stack.clear { populate_timeline }
# TODO fix this
# growl_latest
end
# Layout for timeline
def populate_timeline
@menus = {}
@timeline.each do |status|
@current_user = status.user
flow :margin => 0 do
zebra_stripe gray(0.9)
stack :width => -(45 + gutter) do
# para autolink(@htmlentities.decode(status.text)), :size => 9, :margin => 5
para autolink(status.text), :size => 9, :margin => 5
menu_for status
end
unless @last_user and @last_user.id == @current_user.id
stack :width => 45 do
avatar_for status.user
para link_to_profile(status.user), :size => 8, :align => "right", :margin => [0,0,5,5]
end
end
end
@last_user = @current_user
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment