Skip to content

Commit

Permalink
Removing Facebook
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Sep 26, 2011
1 parent 733666b commit 1f59963
Show file tree
Hide file tree
Showing 22 changed files with 23 additions and 305 deletions.
Binary file modified app/assets/images/slide1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions app/assets/javascripts/main.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ $(document).ready ->

if( $("#tweet").length > 0)
$("#tweet").attr('checked', enabled)
if( $("#facebook").length > 0)
$("#facebook").attr('checked', enabled)

textarea.keypress(updateTickyboxes).keyup(updateTickyboxes)

Expand All @@ -105,5 +103,3 @@ $(document).ready ->

if( $("#tweet").length > 0)
$("#tweet").change(recordTickyboxChange)
if( $("#facebook").length > 0)
$("#facebook").change(recordTickyboxChange)
6 changes: 0 additions & 6 deletions app/assets/javascripts/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
if ($("#tweet").length > 0) {
$("#tweet").attr('checked', enabled);
}
if ($("#facebook").length > 0) {
return $("#facebook").attr('checked', enabled);
}
};
textarea.keypress(updateTickyboxes).keyup(updateTickyboxes);
recordTickyboxChange = function() {
Expand All @@ -46,9 +43,6 @@
if ($("#tweet").length > 0) {
$("#tweet").change(recordTickyboxChange);
}
if ($("#facebook").length > 0) {
$("#facebook").change(recordTickyboxChange);
}
$("#update-form").submit(function() {
if (textarea.val().length <= 0 || textarea.val().length > MAX_LENGTH) {
return false;
Expand Down
2 changes: 0 additions & 2 deletions app/assets/stylesheets/lib/css3buttons.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,3 @@ a.big.button span.icon { top: 0px }
.button:hover span.icon.unlock { background-position: 0 -809px }
.button span.icon.twitter { background-position: 0 -824px }
.button:hover span.icon.twitter { background-position: 0 -839px }
.button span.icon.facebook { width: 8px; background-position: 0 -854px }
.button:hover span.icon.facebook { width: 8px; background-position: 0 -869px }
12 changes: 5 additions & 7 deletions app/controllers/auth_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This controller handles all of the external authentication needs of Rstatus.
# We're using OmniAuth to handle our Twitter and Facebook connections, so these
# We're using OmniAuth to handle our Twitter connections, so these
# routes are all derived from that codebase.
class AuthController < ApplicationController

Expand Down Expand Up @@ -34,15 +34,13 @@ def auth
session[:oauth_token] = auth['credentials']['token']
session[:oauth_secret] = auth['credentials']['secret']

# The username is checked to ensure it is unique, if it is not, or if there is a
# screwy facebook nickname the user is redirected to /users/new to change
# their registration information. If the username is unique and not facebook
# screwery the user is sent to the confirmation page where they will confirm
# The username is checked to ensure it is unique, if it is not,
# the user is redirected to /users/new to change
# their registration information. If the username is unique
# the user is sent to the confirmation page where they will confirm
# their username and enter an email address.
if User.first :username => auth['user_info']['nickname']
flash[:error] = "Sorry, someone else has that username. Please pick another."
elsif auth['user_info']['nickname'] =~ /profile[.]php[?]id=/
flash[:error] = "Please choose a username."
end

redirect_to '/users/new'
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/updates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ def show
def create
# XXX: This should really be put into a model. Fat controller here!
do_tweet = params[:tweet] == "1"
do_facebook = params[:facebook] == "1"
u = Update.new(:text => params[:text],
:referral_id => params[:referral_id],
:author => current_user.author,
:twitter => do_tweet,
:facebook => do_facebook)
:twitter => do_tweet)

# add entry to user's feed
current_user.feed.updates << u
Expand Down
4 changes: 2 additions & 2 deletions app/models/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def url
# Returns a locally useful url for the Author's avatar

# We've got a couple of options here. If they have some sort of image from
# Facebook or Twitter, we use that, and if they don't, we go with Gravatar.
# Twitter, we use that, and if they don't, we go with Gravatar.
# If none of that is around, then we show the DEFAULT_AVATAR
def avatar_url

# If the user has a facebook or twitter image, return it
# If the user has a twitter image, return it
if image_url.present?
image_url

Expand Down
3 changes: 0 additions & 3 deletions app/models/authorization.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# An Authorization represents a connection to someone's social media profile.
# For example, a User might have two Authorizations, one for their Twitter
# and one for their Facebook.

class Authorization
include MongoMapper::Document

Expand Down
17 changes: 2 additions & 15 deletions app/models/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Update
key :tags, Array, :default => []
key :language, String
key :twitter, Boolean
key :facebook, Boolean

# For speed, we generate the html for the update lazily when it is rendered
key :html, String
Expand Down Expand Up @@ -222,9 +221,8 @@ def send_to_remote_mentions
end
end

# If a user has twitter or facebook enabled on their account and they checked
# either twitter, facebook or both on update form, repost the update to
# facebook or twitter.
# If a user has twitter enabled on their account and they checked
# it on update form, repost the update to twitter
def send_to_external_accounts
return if ENV['RAILS_ENV'] == 'development'

Expand All @@ -246,17 +244,6 @@ def send_to_external_accounts
#I should be shot for doing this.
end
end

# If the facebook flag is true and the user has a facebook account linked
# send the update
if self.facebook? && author.user.facebook?
begin
user = FbGraph::User.me(author.user.facebook.oauth_token)
user.feed!(:message => text)
rescue Exception => e
#I should be shot for doing this.
end
end
end

end
Expand Down
10 changes: 0 additions & 10 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,6 @@ def twitter
get_authorization(:twitter)
end

# Returns true when this user has a facebook authorization
def facebook?
has_authorization?(:facebook)
end

# Returns the facebook authorization
def facebook
get_authorization(:facebook)
end

# Check if a a user has a certain authorization by providing the associated
# provider
def has_authorization?(auth)
Expand Down
4 changes: 0 additions & 4 deletions app/views/sessions/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
%a.button{:href=>'/auth/twitter'}
%span.icon.twitter
Twitter
.facebook.login-service
%a.button{:href=>'/auth/facebook'}
%span.icon.facebook
Facebook

- content_for :javascript do
:javascript
Expand Down
8 changes: 2 additions & 6 deletions app/views/static/homepage.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
%a.button{:href=>'/auth/twitter'}
%span.icon.twitter
Twitter
.facebook.option
%a.button{:href=>'/auth/facebook'}
%span.icon.facebook
Facebook
.username.option
%a.button{:href=>'/login'}
%span.icon.comment
Expand All @@ -33,7 +29,7 @@
.content
%h3
Sign Up
with Twitter or Facebook, or create a new account
with Twitter or create a new account
= image_tag "slide1.png"
#col-2.col
.content
Expand Down Expand Up @@ -79,6 +75,6 @@
If you're a software developer, you'll probably want to check out our [Open Source page](/open_source). If that's greek to you, here's the deal on **Openness**: the programming code that makes up rstat.us is available for anyone to download, free of charge. Programmers can use that code to run their own websites just like rstat.us, and you can subscribe to your friends on any site that supports the [OStatus protocol](http://ostatus.org/about), like [identi.ca](http://identi.ca/). This also means that you can own your data, we'll never stop you from having full access to everything you've put into rstat.us.

\- The **rstat.us** team


!= render :partial => "shared/footer"
14 changes: 4 additions & 10 deletions app/views/updates/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
#update-content
%textarea#update-textarea{:name => "text"}=@update_text
#update-info
- if current_user.twitter? || current_user.facebook?
- if current_user.twitter?
#repost-services
.info Post to:
- if current_user.twitter?
.input-checkbox
%input{:type => "checkbox", :name => "tweet", :id => "tweet", :checked => "checked", :value => "1"}
%label{:for => "tweet"} Twitter
- if current_user.facebook?
.input-checkbox
%input{:type => "checkbox", :name => "facebook", :id => "facebook", :checked => "checked", :value => "1"}
%label{:for => "facebook"} Facebook

.input-checkbox
%input{:type => "checkbox", :name => "tweet", :id => "tweet", :checked => "checked", :value => "1"}
%label{:for => "tweet"} Twitter

%input#update-referral{:type => 'hidden', :name => 'referral_id', :value => @update_id}
%input#update-button.button{:type => "submit", :value => "Share"}
Expand Down
11 changes: 0 additions & 11 deletions app/views/users/edit.haml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,3 @@
- else
%form.profile-update{:action => "/auth/twitter", :method => "GET", :name => "profile_update_form"}
%input.button{:type => "submit", :value => "Add Twitter Account"}

.linked
- if @user.facebook?
%img.linked-image{:src => asset_path("f_logo.png"), :alt => "Facebook Account"}
.linked-name="#{@user.facebook.nickname}"
%form.profile-update{:action => "/users/#{@user.username}/auth/facebook", :method => "POST", :name => "profile_update_form"}
%input{:type => "hidden", :name => "_method", :value => "delete"}
%input.button{:type => "submit", :value => "Remove"}
- else
%form.profile-update{:action => "/auth/facebook", :method => "GET", :name => "profile_update_form"}
%input.button{:type => "submit", :value => "Add Facebook Account"}
1 change: 0 additions & 1 deletion config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, ENV["CONSUMER_KEY"], ENV["CONSUMER_SECRET"]
provider :facebook, ENV["APP_ID"], ENV["APP_SECRET"], {:scope => 'publish_stream,offline_access,email', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}}
end
10 changes: 0 additions & 10 deletions test/acceptance/acceptance_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ def log_in(user, uid = 12345)
visit '/auth/twitter'
end

def log_in_fb(user, uid = 12345)
if user.is_a? User
user = user.username
end

omni_mock(user, {:uid => uid, :provider => :facebook})

visit '/auth/facebook'
end

def log_in_email(user)
User.stubs(:authenticate).returns(user)

Expand Down
Loading

0 comments on commit 1f59963

Please sign in to comment.