Skip to content

Commit

Permalink
a little meta and more providers
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridindie committed Apr 19, 2011
1 parent cd2c96a commit 7f1f423
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions app/controllers/omniauth_callbacks_controller.rb
Expand Up @@ -3,10 +3,10 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
include SpreeBase
helper :users, 'spree/base'

OAUTH_PROVIDERS.each do |provider|
method_name = (provider).to_sym
SpreeSocial::OAUTH_PROVIDERS.each do |provider|
method_name = (provider[1]).to_sym
send :define_method, method_name do
social_setup(provider.capitalize)
social_setup(provider[1].capitalize)
end
end

Expand All @@ -24,7 +24,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController

private

def social_setups(provider)
def social_setup(provider)
omniauth = request.env["omniauth.auth"]

if request.env["omniauth.error"].present?
Expand Down
15 changes: 9 additions & 6 deletions lib/spree_social.rb
Expand Up @@ -6,12 +6,14 @@
module SpreeSocial

OAUTH_PROVIDERS = [
"bitly", "dailymile", "doit", "dopplr", "evernote", "facebook", "foursquare", "github", "goodreads",
"google", "gowalla", "hyves", "identica", "instagram", "instapaper", "linked_in", "meetup", "miso", "mixi",
"netflix","smug_mug", "sound_cloud", "thirty_seven_signals", "trade_me", "trip_it", "twitter", "type_pad",
"vimeo", "yahoo", "you_tube"
["Bit.ly", "bitly"], ["Evernote", "evernote"], ["Facebook", "facebook"], ["Foursquare", "foursquare"],
["Github", "github"], ["Google", "google"] , ["Gowalla", "gowalla"], ["instagr.am", "instagram"],
["Instapaper", "instapaper"], ["LinkedIn", "linked_in"], ["37Signals (Basecamp, Campfire, etc)", "thirty_seven_signals"],
["Twitter", "twitter"], ["Vimeo", "vimeo"], ["Yahoo!", "yahoo"], ["YouTube", "you_tube"]
]



class Engine < Rails::Engine
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Expand All @@ -27,12 +29,13 @@ def self.activate
def self.init_provider(provider)
key, secret = nil
AuthenticationMethod.where(:environment => ::Rails.env).each do |user|
if user.preferred_provider == provider
if user.preferred_provider == provider[1]
key = user.preferred_api_key
secret = user.preferred_api_secret
puts("Loaded #{user.preferred_provider.capitalize} as authentication source")
end
end if self.table_exists?("authentication_methods") # See Below for explanation
self.setup_key_for(provider.to_sym, key, secret)
self.setup_key_for(provider[1].to_sym, key, secret)
end

def self.setup_key_for(provider, key, secret)
Expand Down
2 changes: 1 addition & 1 deletion spree_social.gemspec
Expand Up @@ -18,6 +18,6 @@ Gem::Specification.new do |s|

s.add_dependency('spree_core', '>= 0.40.0')
s.add_dependency('spree_auth', '>= 0.40.0')
s.add_dependency('oa-oauth', '>= 0.1.6')
s.add_dependency('oa-oauth', '>= 0.2.2')
s.add_dependency('evernote')
end

0 comments on commit 7f1f423

Please sign in to comment.