Permalink
Browse files

Committing the rest of the existing app.

  • Loading branch information...
1 parent 4aacd9c commit b3396cff31627775fc498e492fe03bc0726305ce @apike committed Jan 2, 2010
Showing with 55,117 additions and 0 deletions.
  1. +10 −0 Rakefile
  2. +15 −0 app/controllers/application.rb
  3. +63 −0 app/controllers/default_controller.rb
  4. +68 −0 app/controllers/scan_controller.rb
  5. +3 −0 app/helpers/application_helper.rb
  6. +2 −0 app/helpers/home_helper.rb
  7. +2 −0 app/helpers/login_helper.rb
  8. +2 −0 app/helpers/scan_helper.rb
  9. BIN app/views/.DS_Store
  10. +23 −0 app/views/default/about.html.erb
  11. +8 −0 app/views/default/index.html.erb
  12. +13 −0 app/views/layouts/_choices.erb
  13. +46 −0 app/views/layouts/application.html.erb
  14. +11 −0 app/views/scan/index.html.erb
  15. +30 −0 app/views/scan/single.html.erb
  16. +109 −0 config/boot.rb
  17. +22 −0 config/database.yml
  18. +84 −0 config/environment.rb
  19. +19 −0 config/environments/development.rb
  20. +24 −0 config/environments/production.rb
  21. +22 −0 config/environments/test.rb
  22. +10 −0 config/initializers/inflections.rb
  23. +5 −0 config/initializers/mime_types.rb
  24. +17 −0 config/initializers/new_rails_defaults.rb
  25. +5 −0 config/locales/en.yml
  26. +45 −0 config/routes.rb
  27. BIN db/development.sqlite3
  28. +16 −0 db/migrate/20091126050405_create_sessions.rb
  29. BIN db/production.sqlite3
  30. +24 −0 db/schema.rb
  31. +5 −0 doc/README_FOR_APP
  32. +38,097 −0 log/development.log
  33. +1,367 −0 log/production.log
  34. 0 log/server.log
  35. 0 log/test.log
  36. +6,680 −0 profile1.txt
  37. BIN public/.DS_Store
  38. +31 −0 public/404.html
  39. +30 −0 public/422.html
  40. +33 −0 public/500.html
  41. +10 −0 public/dispatch.cgi
  42. +24 −0 public/dispatch.fcgi
  43. +10 −0 public/dispatch.rb
  44. 0 public/favicon.gif
  45. BIN public/favicon.ico
  46. BIN public/images/about_headline.png
  47. BIN public/images/bird2bird.png
  48. BIN public/images/heaviest_headline.png
  49. BIN public/images/icons/count.png
  50. BIN public/images/icons/favorites.png
  51. BIN public/images/icons/hashes.png
  52. BIN public/images/icons/links.png
  53. BIN public/images/icons/mentions.png
  54. BIN public/images/icons/meta.png
  55. BIN public/images/loader.gif
  56. BIN public/images/rails.gif
  57. BIN public/images/scan.png
  58. BIN public/images/spinner.gif
  59. BIN public/images/test.gif
  60. BIN public/images/testing.jpg
  61. BIN public/images/too_many_tweets.png
  62. BIN public/images/twitter_sign_in.png
  63. BIN public/images/unladen-square.png
  64. BIN public/images/unladen_logo.png
  65. +382 −0 public/javascripts/application.js
  66. +963 −0 public/javascripts/controls.js
  67. +973 −0 public/javascripts/dragdrop.js
  68. +1,128 −0 public/javascripts/effects.js
  69. +4,320 −0 public/javascripts/prototype.js
  70. +5 −0 public/robots.txt
  71. +209 −0 public/stylesheets/unladen.css
  72. +4 −0 script/about
  73. +3 −0 script/console
  74. +3 −0 script/dbconsole
  75. +3 −0 script/destroy
  76. +3 −0 script/generate
  77. +3 −0 script/performance/benchmarker
  78. +3 −0 script/performance/profiler
  79. +3 −0 script/performance/request
  80. +3 −0 script/plugin
  81. +3 −0 script/process/inspector
  82. +3 −0 script/process/reaper
  83. +3 −0 script/process/spawner
  84. +3 −0 script/runner
  85. +3 −0 script/server
  86. +8 −0 test/functional/home_controller_test.rb
  87. +8 −0 test/functional/login_controller_test.rb
  88. +8 −0 test/functional/scan_controller_test.rb
  89. +9 −0 test/performance/browsing_test.rb
  90. +38 −0 test/test_helper.rb
  91. 0 tmp/restart.txt
  92. +38 −0 todo.txt
View
@@ -0,0 +1,10 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
@@ -0,0 +1,15 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+
+ # See ActionController::RequestForgeryProtection for details
+ # Uncomment the :secret if you're not using the cookie session store
+ protect_from_forgery :secret => 'f1eaced6b43b7d18fdf7998e1264b7ed'
+
+ # See ActionController::Base for details
+ # Uncomment this to filter the contents of submitted sensitive data parameters
+ # from your application log (in this case, all fields with names like "password").
+ # filter_parameter_logging :password
+end
@@ -0,0 +1,63 @@
+class DefaultController < ApplicationController
+ def index
+ end
+
+ def login
+ require 'oauth'
+
+ consumer = get_consumer
+
+ # Get a request token from Twitter
+ begin
+ @request_token = consumer.get_request_token :oauth_callback => ('http://' + request.env['HTTP_HOST'] + '/default/oauth/')
+ rescue
+ render :text => "<p>Twitter couldn't give us an OAuth request token right now. Please try again later.</p><p>" + $!
+ return
+ end
+
+ # Store the request token's details for later
+ session[:request_token] = @request_token.token
+ session[:request_secret] = @request_token.secret
+
+ # Hand off to Twitter so the user can authorize us
+ redirect_to @request_token.authorize_url
+ end
+
+ def oauth
+ require 'oauth'
+ consumer = get_consumer
+
+ # Re-create the request token
+ @request_token = OAuth::RequestToken.new(consumer, session[:request_token], session[:request_secret])
+
+ # Convert the request token to an access token using the verifier Twitter gave us
+ begin
+ @access_token = @request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
+ rescue
+ render :text => "<p>Twitter couldn't verify your OAuth request token right now. Please try again later.</p><p>" + $!
+ return
+ end
+
+ # Store the token and secret that we need to make API calls
+ session[:oauth_token] = @access_token.token
+ session[:oauth_secret] = @access_token.secret
+
+ redirect_to '/scan/'
+ end
+
+ def logout
+ reset_session
+ redirect_to "/"
+ end
+
+ private
+
+ def get_consumer
+ OAuth::Consumer.new(
+ 'kU9aUc0zXGTRMd1oyknjyg',
+ 'LgLlHSCN27Rs5fTwAoxEFUc2MFAp3VGAdwjaGsRVws',
+ {:site => 'http://twitter.com'}
+ )
+ end
+
+end
@@ -0,0 +1,68 @@
+require 'grackle'
+require 'date'
+
+class ScanController < ApplicationController
+ def index
+ # Default scanner
+ end
+
+ def single
+ # User page
+ @user = params[:id]
+ end
+
+ def followed
+ # Everybody JSON
+ twitter_request("/statuses/home_timeline.json", true)
+ end
+
+ def user
+ # Call for user JSON
+
+ user = params[:u]
+
+ # Test for invalid twitter username
+ if (!user || user =~ /[^a-z0-9_]+/i)
+ render :text => "{twitter_error: 'Invalid username.'}"
+ else
+ twitter_request("/statuses/user_timeline/" + user + ".json", false)
+ end
+
+ end
+
+ private
+
+ def twitter_request(method, needs_auth)
+ page_size = 200
+ timeout = 20
+
+ page = params[:page] ? params[:page].to_i : 1
+ if page > 10
+ page = 10
+ end
+
+ begin
+ req = Net::HTTP::Get.new(method + "?count=#{page_size}&page=#{page}")
+
+ if (needs_auth)
+ consumer = OAuth::Consumer.new('kU9aUc0zXGTRMd1oyknjyg', 'LgLlHSCN27Rs5fTwAoxEFUc2MFAp3VGAdwjaGsRVws', {:site => 'http://twitter.com'})
+ access_token = OAuth::AccessToken.new(consumer, session[:oauth_token], session[:oauth_secret])
+ consumer.sign!(req, access_token)
+ end
+
+ res = Net::HTTP.new('twitter.com').start {|http|
+ http.read_timeout = timeout
+ http.request(req)
+ }
+ rescue => e
+ res = {}
+ res.code = "Network error - likely a timeout."
+ end
+
+ if res.code.to_i == 200
+ render :text => res.body
+ else
+ render :text => "{twitter_error: #{res.code}}"
+ end
+ end
+end
@@ -0,0 +1,3 @@
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module HomeHelper
+end
@@ -0,0 +1,2 @@
+module LoginHelper
+end
@@ -0,0 +1,2 @@
+module ScanHelper
+end
View
Binary file not shown.
@@ -0,0 +1,23 @@
+<h1><%= image_tag "about_headline.png" %></h1>
+
+<h2>Why?</h2>
+<p>Unladen Follow is based on the assumption that you actually read your tweets. If catching up on Twitter is taking a lot of time, or you're not able to catch up at all, unfollowing a couple select noisy people can make a huge difference.</p>
+
+<h2>How does it work?</h2>
+<p>Unladen Follow reads your tweet timeline, and analyzes each user's tweet frequency and content. It looks to measure cognitive load: how much time and thought it takes to read those tweets.</p>
+
+<h2>What is a Weekly Tweet Load Unit?</h2>
+<p>Each person you follow is rated in highly scientific Weekly Tweet Load Units (TLU). Your total TLUs are an indicator of how much noise you consume on Twitter every week, based on links, replies, hashtags, talking about Twitter itself, and simple tweet volume. If you favourite a tweet, it reduces the writer's TLU. Very roughly, a TLU takes one second to process, meaning consuming 1661 TLU costs you one day per year of reading Twitter.</p>
+
+<h2>Who is Robert Scoble?</h2>
+<p>Robert Scoble is a tech celebrity who posts a ridiculous amount of stuff on Twitter. Inspired by <a href='http://followcost.com/about/milliscoble'>Follow Cost's metric of milliscobles</a>, Unladen Follow relates your Tweet Load in terms of how many times over you could follow Scoble (which presumably you would not want to do.) On November 29, 2009, using 4 weeks of data, @scobleizer was averaging 250 TLU, which is used in this calculation.</p>
+
+<h2>Why do the numbers in the table not show what I expect?</h2>
+<p>The numbers in the details table for links, hashtags, etc. are not simple quantities. They have been weighted, normalized to one week, and then rounded to the nearest whole value.</p>
+
+
+<h2>What inspired this?</h2>
+<p>The first seed was planted by "Twitter Rank" sites that rank you based on how many @mentions, retweets, and other noisy activities you engaged in. I found myself wanting the opposite of these. The second seed was <a href='http://www.followcost.com/'>Follow Cost</a>, which I liked, but thought could use improved metrics and the ability to apply to my existing followers.
+
+<h2>How can I contact you?</h2>
+<p>I'd be happy to hear from you! You can tweet @apike, or you can use <a href='http://www.antipode.ca/contact/'>this contact form</a>.</p>
@@ -0,0 +1,8 @@
+<h1><%= image_tag "too_many_tweets.png" %></h1>
+<p>Cut the noise so you can appreciate the signal.</p>
+<p>Unladen Follow shows you whose tweets are clogging your timeline.</p>
+
+
+<p id='birds'><%= image_tag "bird2bird.png" %></p>
+
+<%= render :partial => 'layouts/choices' %>
@@ -0,0 +1,13 @@
+<div id='signin'>
+ <% if (session[:oauth_token]) %>
+ <a style='float: right' href='/scan/'>Analyze Now</a>
+ <% else %>
+ <a style='float: right' href='/default/login/'><%= image_tag "twitter_sign_in.png" %></a>
+ <% end %>
+
+ Analyze your followees:
+</div>
+
+<p style='text-align: center; margin: 5px'><i>~or~</i></p>
+
+<div id='signin'><form style='display: inline;float: right' onsubmit='return Unladen.user_jump();'><input type='text' id='jumpto' ></form>Analyze one Twitterer: </div>
@@ -0,0 +1,46 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+ <title>Unladen Follow - Twitter analyzer and unfollow helper</title>
+ <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" %>
+ <%= javascript_include_tag "application.js" %>
+ <meta name="viewport" content="width=550, user-scalable=yes">
+ <%= stylesheet_link_tag("unladen") %>
+</head>
+<body>
+
+<div id='spacing'>
+<div id='page'>
+
+ <div id='header'>
+ <a href='/'><%= image_tag "unladen_logo.png" %></a>
+ </div>
+
+ <div id='content'>
+ <%= yield %>
+ </div>
+
+ <div id='footer'>
+
+ <a href='/about/'>Learn More</a> - <a href='/scan/'>Analyze</a><br>
+ Brought to you by <a href='http://www.twitter.com/apike/'>@apike</a> of <a href='http://www.antipode.ca/'>Antipode</a>.
+ </div>
+
+</div>
+</div>
+
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try {
+var pageTracker = _gat._getTracker("UA-585700-3");
+pageTracker._trackPageview();
+} catch(err) {}</script>
+
+</body>
+</html>
@@ -0,0 +1,11 @@
+<h1><%= image_tag "heaviest_headline.png" %></h1>
+
+<div id='results'>
+ <span id='progress'></span>
+ <%= image_tag "loader.gif", :id => "loader" %>
+</div>
+
+
+<script>
+ Unladen.get_tweets();
+</script>
@@ -0,0 +1,30 @@
+<% @user = strip_tags @user %>
+
+<h2>Tweet Load for <%= @user %></h2>
+
+<div id='results'>
+ <div id='tlu'><%= image_tag "loader.gif", :id => "loader" %></div>
+
+ <div style='float: right; text-align: right'>
+ <img id='avatar' src=''><br>
+ <a id='link' href='#'></a>
+ </div>
+
+ <table id='single_results'>
+ <tr><td><%= image_tag "icons/count.png" %></td><td>Quantity</td><td id='volume'>-</td></tr>
+ <tr><td><%= image_tag "icons/hashes.png" %></td><td>Hashtags</td><td id='hashes'>-</td></tr>
+ <tr><td><%= image_tag "icons/links.png" %></td><td>Links</td><td id='links'>-</td></tr>
+ <tr><td><%= image_tag "icons/mentions.png" %></td><td>Mentions</td><td id='mentions'>-</td></tr>
+ <tr><td><%= image_tag "icons/meta.png" %></td><td>Metadiscussion</td><td id='meta'>-</td></tr>
+ </table>
+
+ <p id='weeks'><br></p>
+</div>
+
+<br><br>
+
+<%= render :partial => 'layouts/choices' %>
+
+<script>
+ Unladen.get_user("<%= @user %>");
+</script>
Oops, something went wrong.

0 comments on commit b3396cf

Please sign in to comment.