Skip to content

Commit

Permalink
Services up and running
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Nov 4, 2011
1 parent af006aa commit 31112aa
Show file tree
Hide file tree
Showing 18 changed files with 209 additions and 243 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
source 'http://rubygems.org'

gem 'rails', '3.1.1'
gem "gscraper", "~> 0.3.0"
gem "twitter", "~> 1.7.2"
gem "nokogiri", "~> 1.5.0"

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
Expand Down
28 changes: 28 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GEM
activesupport (= 3.1.1)
activesupport (3.1.1)
multi_json (~> 1.0)
addressable (2.2.6)
ansi (1.3.0)
arel (2.2.1)
builder (3.0.0)
Expand All @@ -42,18 +43,34 @@ GEM
erubis (2.7.0)
execjs (1.2.9)
multi_json (~> 1.0)
faraday (0.7.5)
addressable (~> 2.2.6)
multipart-post (~> 1.1.3)
rack (>= 1.1.0, < 2)
faraday_middleware (0.7.0)
faraday (~> 0.7.3)
gscraper (0.3.0)
json_pure (~> 1.4.0)
mechanize (~> 1.0.0)
hashie (1.1.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.16)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.1)
json_pure (1.4.6)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mechanize (1.0.0)
nokogiri (>= 1.2.1)
mime-types (1.17.2)
multi_json (1.0.3)
multi_xml (0.4.1)
multipart-post (1.1.3)
nokogiri (1.5.0)
polyglot (0.3.3)
rack (1.3.5)
rack-cache (1.1)
Expand Down Expand Up @@ -89,6 +106,7 @@ GEM
sass (>= 3.1.4)
sprockets (~> 2.0.0)
tilt (~> 1.3.2)
simple_oauth (0.1.5)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
Expand All @@ -101,6 +119,13 @@ GEM
polyglot (>= 0.3.1)
turn (0.8.3)
ansi
twitter (1.7.2)
faraday (~> 0.7.4)
faraday_middleware (~> 0.7.0)
hashie (~> 1.1.0)
multi_json (~> 1.0.0)
multi_xml (~> 0.4.0)
simple_oauth (~> 0.1.5)
tzinfo (0.3.30)
uglifier (1.0.4)
execjs (>= 0.3.0)
Expand All @@ -111,9 +136,12 @@ PLATFORMS

DEPENDENCIES
coffee-rails (~> 3.1.1)
gscraper (~> 0.3.0)
jquery-rails
nokogiri (~> 1.5.0)
rails (= 3.1.1)
sass-rails (~> 3.1.4)
sqlite3
turn
twitter (~> 1.7.2)
uglifier (>= 1.0.3)
3 changes: 3 additions & 0 deletions app/assets/javascripts/main.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
58 changes: 57 additions & 1 deletion app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,60 @@
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*/
*/
/*
*Overide the system defaults
*/

html, body, h1, #navlist { margin: 0; padding: 0; }

body
{
background: none repeat scroll 0 0 #000;
color: #FFF;
font-family: 'Open Sans', sans-serif;
font-size: 11px;
height: 100%;
}

a { text-decoration: none; color: red; }
a:hover { text-decoration: underline; }
p { color: #888; margin: 0; padding: 0; }

#container {
background-color: rgba(0,0,0,0.85);
color: white;
position: absolute;
top: 0;
left: 0;
padding: 20px;
}

#twitter img { float: left; }
#twitter h1 { vertical-align: center; }

iframe {
height: 100%;
width: 100%;
background-color: red;
}
#navlist { margin-top: 10px; }
#navlist li {
list-style-type: none;
margin: 0;
padding: 0;
}

#main {
margin-top: 200px;
text-align: center;
}
#main h1 { margin: 10px; }
#main input {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: 1px solid #CCC;

padding: 6px;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/main.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Main controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
56 changes: 56 additions & 0 deletions app/controllers/main_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
class MainController < ApplicationController
def index
redirect_to "/#{params[:twitter_id].first.gsub "@", ""}" if params[:twitter_id]
end

def show
@twitter = params[:twitter_id]
user = Twitter.user @twitter
@timezone = user.time_zone
@avatar = user.profile_image_url
@url = user.url
@name = user.name
@location = user.location

@sites = {
:aboutme => "http://about.me/#{@twitter}",
:github => "http://github.com/#{@twitter}",
:twitter => "https://twitter.com/#{@twitter}",
:facebook => "http://facebook.com/#{@twitter}",
:gravatar => "http://en.gravatar.com/#{@twitter}",
:blogspot => "http://#{@twitter}.blogspot.com",
:disqus => "http://disqus.com/#{@twitter}",
:wordpress => "http://#{@twitter}.wordpress.com",
:tumblr => "http://#{@twitter}.tumblr.com",
:deviantart => "http://#{@twitter}.deviantart.com",
:picasa => "http://picasaweb.google.com/#{@twitter}",
:flickr => "http://flickr.com/#{@twitter}",
:lastfm => "http://last.fm/user/#{@twitter}",
:soundcloud => "http://soundcloud.com/#{@twitter}",
:hulu => "http://hulu.com/profiles/#{@twitter}",
:ustream => "http://ustream.tv/user/#{@twitter}",
:vimeo => "http://vimeo.com/#{@twitter}",
:digg => "http://digg.com/users/#{@twitter}",
:foursquare => "http://foursquare.com/#{@twitter}",
:stumbleupon => "http://stumbleupon.com/stumbler/#{@twitter}",
:twitpic => "http://twitpic.com/photos/#{@twitter}",
:yfrog => "http://yfrog.com/user/#{@twitter}/profile",
:linkedin => "http://www.linkedin.com/in/#{@twitter}",
}

#aboutme = search("site:about.me \"#{@twitter}\" #{name}")
#if aboutme
# doc = Nokogiri::HTML(open(aboutme))
# raise doc
#end
#linkedin = search("site:linkedin.com \"#{@twitter}\"")
end

private

def search(query)
q = GScraper::Search.query(:query => query)
"#{q.top_result.url.scheme}://#{q.top_result.url.host}#{q.top_result.url.path}"
end

end
3 changes: 3 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
module ApplicationHelper
def get_target(key)
[:facebook, :github, :flickr, :hulu, :picasa, :twitter].include?(key) ? "_blank" : "iframe_a"
end
end
2 changes: 2 additions & 0 deletions app/helpers/main_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module MainHelper
end
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<title>Panopticode</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
Expand Down
1 change: 1 addition & 0 deletions app/views/main/default.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Click on a profile to view it!
7 changes: 7 additions & 0 deletions app/views/main/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="main">
<h1>Enter your Twitter username</h1>
<%= form_tag do %>
<%= text_field :twitter_id, nil %>
<%= submit_tag "Go!" %>
<% end %>
</div>
14 changes: 14 additions & 0 deletions app/views/main/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div id="container">
<h1>@<%= @twitter %></h1>
<p><%= @name %></p>
<p><%= @timezone %></p>
<p><%= @location %></p>

<ul id="navlist">
<% @sites.sort.each do |key, value| %>
<li><%= link_to key.capitalize, value, :target => get_target(key) %></li>
<% end %>
</ul>
</div>

<iframe src="http://<%= @twitter %>.com" name="iframe_a"></iframe>
6 changes: 5 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Panopticode::Application.routes.draw do
post "/" => "main#index"
get "/default" => "main#default"
get "/:twitter_id" => "main#show"
root :to => "main#index"
# The priority is based upon order of creation:
# first created -> highest priority.

Expand All @@ -16,7 +20,7 @@
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# get 'shortn'
# post 'toggle'
# end
#
Expand Down
3 changes: 3 additions & 0 deletions lib/tasks/search.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
task :search => :environment do
twitter_id = "excid3"
end
5 changes: 5 additions & 0 deletions lib/tasks/search.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
STDOUT.sync = true

task :search => :environment do

end
Loading

0 comments on commit 31112aa

Please sign in to comment.