Permalink
Browse files

Cleaned up app.rb

  • Loading branch information...
1 parent c2e7153 commit 4e7014352ddf12056d87f473ced2026a484ee93b @bfaloona bfaloona committed Nov 9, 2011
Showing with 22 additions and 12 deletions.
  1. +7 −10 lib/app.rb
  2. +8 −0 views/followers.haml
  3. +7 −2 views/index.haml
View
@@ -7,25 +7,22 @@ class TwitterInfo < Sinatra::Application
set :views, settings.root + '/../views'
get '/' do
- '<html><body>Append a twitter username on the url to display
- how many followers the user has.<br/> For example:<br/><a href=\'/user/burtlo\'>/user/<strong>burtlo</strong></a>
- </body></html>'
+ haml :index
end
- get /^\/user\/(\S+)$/ do |user|
-
- @user = user
+ get '/user/:username' do
+ @user = params[:username]
user_id = Twitter.user(@user).id
-
followers = Twitter.follower_ids(user_id).ids
-
@num_followers = followers.length
- haml :index
+
+ haml :followers
+
end
post // do
- [500, nil, 'Whoa. Sorry. No POSTs allowed.']
+ halt 500, 'Whoa. Sorry. No POSTs allowed.'
end
end
View
@@ -0,0 +1,8 @@
+%html
+ %head
+ %title Twitter Info Application
+
+ %body
+ %h4 #{@user}
+
+ %h1 #{@num_followers}
View
@@ -3,6 +3,11 @@
%title Twitter Info Application
%body
- %h4 #{@user}
+ %h2 Welcome
- %h1 #{@num_followers}
+ %p
+ Append a twitter username on the url to display how many followers the user has
+ %br
+ For example:
+ %br
+ %a{:href => '/user/burtlo'} /user/burtlo

0 comments on commit 4e70143

Please sign in to comment.