Skip to content

Commit

Permalink
setup friends list and fix permission scope on facebook auth
Browse files Browse the repository at this point in the history
  • Loading branch information
joshrendek committed Nov 27, 2011
1 parent da7a587 commit 4d129e2
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 35 deletions.
44 changes: 23 additions & 21 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gem "oa-oauth", :require => "omniauth/oauth"
gem "fb_graph" # DONT CONFUSE THIS WITH fbgraph
gem 'formtastic'
gem 'haml'
gem 'kaminari'

# Gems used only for assets and not required
# in production environments by default.
Expand All @@ -24,7 +25,7 @@ group :assets do
end


group :test do
group :test do
gem "database_cleaner"
gem 'cucumber'
gem 'cucumber-rails'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ GEM
thor (~> 0.14)
json (1.6.1)
json_pure (1.6.1)
kaminari (0.12.4)
rails (>= 3.0.0)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand Down Expand Up @@ -212,6 +214,7 @@ DEPENDENCIES
haml
hpricot
jquery-rails
kaminari
mysql2
oa-oauth
pg
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/facebook.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/
77 changes: 77 additions & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@
*= require_tree .
*/

.topbar-inner, .topbar .fill {
background: #333;
/* Old browsers */
background: -moz-linear-gradient(top, #066dab 0%, #084368 99%, #c5deea 100%) !important;
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #066dab), color-stop(99%, #084368), color-stop(100%, #c5deea)) !important;
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #066dab 0%, #084368 99%, #c5deea 100%) !important;
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #066dab 0%, #084368 99%, #c5deea 100%) !important;
/* Opera11.10+ */
background: -ms-linear-gradient(top, #066dab 0%, #084368 99%, #c5deea 100%) !important;
/* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#066dab', endColorstr='#066dab',GradientType=0 ) !important;
/* IE6-9 */
background: linear-gradient(top, #066dab 0%, #084368 99%, #c5deea 100%) !important;
/* W3C */
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

#auth {
float: right;
margin-top: 8px;
Expand Down Expand Up @@ -43,3 +65,58 @@ table.time_preferences {

#save_preferences {
}

.pagination{
height:36px;
margin:18px 0;

ul {
float:left;
margin:0;
border:1px solid #ddd;
border:1px solid rgba(0, 0, 0, 0.15);
-webkit-border-radius:3px;
-moz-border-radius:3px;
border-radius:3px;
-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow:0 1px 2px rgba(0, 0, 0, 0.05);
}
li {
display:inline;
}

span {
float:left;
padding:0 14px;
line-height:34px;
border-right:1px solid;
border-right-color:#ddd;
border-right-color:rgba(0, 0, 0, 0.15);
*border-right-color:#ddd;
text-decoration:none;
}
a:hover, .active a {
background-color:#c7eefe;
}
.disabled a, .disabled a:hover {
background-color:transparent;
color:#bfbfbf;
}
.next a {
border:0;
}
}


.facebook {
tr {
td {
padding-top: 15px;
img {
padding-top: 0px !important;
}
}
}
}

6 changes: 0 additions & 6 deletions app/assets/stylesheets/boot.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,6 @@ button.btn::-moz-focus-inner,input[type=submit].btn::-moz-focus-inner{padding:0;
.alert-message.block-message.error{background-color:#fddfde;border-color:#fbc7c6;}
.alert-message.block-message.success{background-color:#d1eed1;border-color:#bfe7bf;}
.alert-message.block-message.info{background-color:#ddf4fb;border-color:#c6edf9;}
.pagination{height:36px;margin:18px 0;}.pagination ul{float:left;margin:0;border:1px solid #ddd;border:1px solid rgba(0, 0, 0, 0.15);-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:0 1px 2px rgba(0, 0, 0, 0.05);}
.pagination li{display:inline;}
.pagination a{float:left;padding:0 14px;line-height:34px;border-right:1px solid;border-right-color:#ddd;border-right-color:rgba(0, 0, 0, 0.15);*border-right-color:#ddd;text-decoration:none;}
.pagination a:hover,.pagination .active a{background-color:#c7eefe;}
.pagination .disabled a,.pagination .disabled a:hover{background-color:transparent;color:#bfbfbf;}
.pagination .next a{border:0;}
.well{background-color:#f5f5f5;margin-bottom:20px;padding:19px;min-height:20px;border:1px solid #eee;border:1px solid rgba(0, 0, 0, 0.05);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);}
.modal-backdrop{background-color:rgba(0, 0, 0, 0.5);position:fixed;top:0;left:0;right:0;bottom:0;z-index:1000;}
.modal{position:fixed;top:50%;left:50%;z-index:2000;width:560px;margin:-280px 0 0 -250px;background-color:#ffffff;border:1px solid #999;border:1px solid rgba(0, 0, 0, 0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box;}
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/facebook.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the facebook controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
2 changes: 1 addition & 1 deletion app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class CoursesController < ApplicationController
# GET /courses
# GET /courses.json
def index
@courses = Course.limit(200)
@courses = Course.order('course_number ASC').page params[:page]

respond_to do |format|
format.html # index.html.haml
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/facebook_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class FacebookController < ApplicationController
def friends
@user = current_user
@friends = FbGraph::User.me(@user.authorizations.first.token).friends

end
end
2 changes: 2 additions & 0 deletions app/helpers/facebook_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module FacebookHelper
end
12 changes: 12 additions & 0 deletions app/views/facebook/friends.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%table.facebook
- @friends.each_with_index do |friend, i|
- if i % 5 == 0
%tr
%td=image_tag "https://graph.facebook.com/#{friend.identifier}/picture", :size => "24x24", :style => "float: left;"
%td=friend.name
- if Authorization.find_by_uid(friend.identifier)
%td
%span.label.notice Already Joined!
- else
%td=link_to "Invite", "#", :class => "btn success"
%td
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
=link_to "Home", "/"
- if current_user
%li
=link_to "Friends", "/"
=link_to "Friends", friends_path
%li
=link_to "My Courses", user_courses_path
%li
Expand All @@ -32,4 +32,4 @@
=link_to (image_tag "fb-login-button.png", :id =>"facebook"), user_omniauth_authorize_path(:facebook)
- flash.each do |name, msg|
= content_tag :div, raw("<p><center>" + msg + "</center></p>"), :class => "alert-message #{name}"
= yield
= yield
6 changes: 4 additions & 2 deletions app/views/shared/_courses.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%h1 Courses

= paginate @courses
%table{:class => "zebra-striped"}
%tr
%th Course Number
Expand Down Expand Up @@ -58,4 +58,6 @@
%td= course.begin_time.strftime("%I:%M %p")
%td= course.end_time.strftime("%I:%M %p")
%td= course.days
%td= course.college.college_tag.upcase
%td= course.college.college_tag.upcase

= paginate @courses
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@


if Rails.env.development?
config.omniauth :facebook, "158293190926436", "47e061745cd76ad3da3b037d5437ccf0"
config.omniauth :facebook, "158293190926436", "47e061745cd76ad3da3b037d5437ccf0", :scope => "publish_stream,user_likes,friends_likes,email,offline_access"
else
config.omniauth :facebook, "296119327071295", "84c55d153401a19df9aabe699fb9f308"
end
Expand Down
8 changes: 8 additions & 0 deletions config/initializers/kaminari_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Kaminari.configure do |config|
config.default_per_page = 25
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.param_name = :page
end
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Classly::Application.routes.draw do

get '/friends', :to => "facebook#friends"

get '/preferences', :to => "preferences#index"
post '/preferences/update', :to => "preferences#update"
Expand Down
9 changes: 9 additions & 0 deletions test/functional/facebook_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'test_helper'

class FacebookControllerTest < ActionController::TestCase
test "should get friends" do
get :friends
assert_response :success
end

end
4 changes: 4 additions & 0 deletions test/unit/helpers/facebook_helper_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'test_helper'

class FacebookHelperTest < ActionView::TestCase
end

0 comments on commit 4d129e2

Please sign in to comment.