This repository has been archived by the owner on Nov 11, 2017. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting to add TwitterUsersController#new
- Loading branch information
Jason Morrison
committed
Mar 14, 2010
1 parent
e94fb1b
commit 4b10c1a
Showing
5 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* You need to add the <%= twitter_connect_button %> to your sessions/new.html.erb | ||
* You need to add the <%= twitter_connect_button %> to your users/new.html.erb |
13 changes: 13 additions & 0 deletions
13
app/controllers/clearance_twitter/twitter_users_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class ClearanceTwitter::TwitterUsersController < ApplicationController | ||
def new | ||
oauth_callback = request.protocol + request.host_with_port + '/oauth_callback' | ||
@request_token = ClearanceTwitter.consumer.get_request_token({:oauth_callback=>oauth_callback}) | ||
session[:request_token] = @request_token.token | ||
session[:request_token_secret] = @request_token.secret | ||
|
||
url = @request_token.authorize_url | ||
# TODO: Test for this | ||
# url << "&oauth_callback=#{CGI.escape(ClearanceTwitter.oauth_callback)}" if ClearanceTwitter.oauth_callback? | ||
redirect_to url | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module ClearanceTwitterHelper | ||
def twitter_connect_button | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
require 'oauth' | ||
|
||
module ClearanceTwitter | ||
|
||
def self.config(environment=RAILS_ENV) | ||
{ | ||
'oauth_consumer_key' => 'key', | ||
'oauth_consumer_secret' => 'secret' | ||
} | ||
|
||
# TODO | ||
# @config ||= {} | ||
# @config[environment] ||= YAML.load(File.open(RAILS_ROOT + '/config/twitter_auth.yml').read)[environment] | ||
end | ||
|
||
def self.base_url | ||
config['base_url'] || 'https://twitter.com' | ||
end | ||
|
||
def self.consumer | ||
options = {:site => ClearanceTwitter.base_url} | ||
[ :authorize_path, | ||
:request_token_path, | ||
:access_token_path, | ||
:scheme, | ||
:signature_method ].each do |oauth_option| | ||
options[oauth_option] = ClearanceTwitter.config[oauth_option.to_s] if ClearanceTwitter.config[oauth_option.to_s] | ||
end | ||
|
||
OAuth::Consumer.new( | ||
config['oauth_consumer_key'], | ||
config['oauth_consumer_secret'], | ||
options | ||
) | ||
end | ||
|
||
# class Error < StandardError; end | ||
|
||
# def self.config(environment=RAILS_ENV) | ||
# @config ||= {} | ||
# @config[environment] ||= YAML.load(File.open(RAILS_ROOT + '/config/twitter_auth.yml').read)[environment] | ||
# end | ||
|
||
# def self.base_url | ||
# config['base_url'] || 'https://twitter.com' | ||
# end | ||
|
||
# def self.path_prefix | ||
# URI.parse(base_url).path | ||
# end | ||
|
||
# def self.api_timeout | ||
# config['api_timeout'] || 10 | ||
# end | ||
|
||
# def self.encryption_key | ||
# raise TwitterAuth::Cryptify::Error, 'You must specify an encryption_key in config/twitter_auth.yml' if config['encryption_key'].blank? | ||
# config['encryption_key'] | ||
# end | ||
|
||
# def self.oauth_callback? | ||
# config.key?('oauth_callback') | ||
# end | ||
|
||
# def self.oauth_callback | ||
# config['oauth_callback'] | ||
# end | ||
|
||
end |