diff --git a/Gemfile b/Gemfile index 08a142c..31e9781 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,9 @@ gem 'omniauth-identity' gem 'omniauth-instagram' gem 'omniauth-twitter', '0.0.8' gem 'omniauth-banters', :git => "git://github.com/becarella/omniauth-banters.git" +gem 'omniauth-foursquare' +gem 'omniauth-tumblr' +gem 'omniauth-lastfm' gem 'hbs' gem 'handlebars_assets', :git => 'git://github.com/becarella/handlebars_assets.git' diff --git a/Gemfile.lock b/Gemfile.lock index 21534ef..070e72f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -121,17 +121,25 @@ GEM omniauth (1.1.0) hashie (~> 1.2) rack + omniauth-foursquare (0.0.7) + omniauth (~> 1.0) + omniauth-oauth2 (~> 1.0) omniauth-identity (1.0.0) omniauth (~> 1.0) omniauth-instagram (1.0.0) omniauth (~> 1.0) omniauth-oauth2 (~> 1.0) + omniauth-lastfm (0.0.2) + omniauth-oauth (~> 1.0) + rest-client (~> 1.6.6) omniauth-oauth (1.0.1) oauth omniauth (~> 1.0) omniauth-oauth2 (1.0.2) oauth2 (~> 0.6.0) omniauth (~> 1.0) + omniauth-tumblr (1.0) + omniauth-oauth (~> 1.0) omniauth-twitter (0.0.8) omniauth-oauth (~> 1.0) pg (0.13.2) @@ -163,6 +171,8 @@ GEM rake (0.9.2.2) rdoc (3.12) json (~> 1.4) + rest-client (1.6.7) + mime-types (>= 1.16) rspec (2.10.0) rspec-core (~> 2.10.0) rspec-expectations (~> 2.10.0) @@ -196,7 +206,7 @@ GEM sprockets (2.0.4) hike (~> 1.2) rack (~> 1.0) - tilt (!= 1.3.0, ~> 1.1) + tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.6) therubyracer (0.9.10) libv8 (~> 3.3.10) @@ -224,8 +234,11 @@ DEPENDENCIES jquery-rails let_me_in! omniauth-banters! + omniauth-foursquare omniauth-identity omniauth-instagram + omniauth-lastfm + omniauth-tumblr omniauth-twitter (= 0.0.8) pg render_or_redirect! diff --git a/app/controllers/let_me_in/auth_controller.rb b/app/controllers/let_me_in/auth_controller.rb index 6e626b5..331a608 100644 --- a/app/controllers/let_me_in/auth_controller.rb +++ b/app/controllers/let_me_in/auth_controller.rb @@ -41,4 +41,4 @@ def callback end end -end \ No newline at end of file +end diff --git a/lib/let_me_in/linked_accounts/lastfm_account.rb b/lib/let_me_in/linked_accounts/lastfm_account.rb new file mode 100644 index 0000000..85b4c24 --- /dev/null +++ b/lib/let_me_in/linked_accounts/lastfm_account.rb @@ -0,0 +1,36 @@ +module LetMeIn + module LinkedAccounts + module LastfmAccount + extend ActiveSupport::Concern + + + module InstanceMethods + + def link(auth_hash, user) + update_attributes({ + :user_id => user.id, + :token => auth_hash[:credentials][:token], + :secret => nil, #auth_hash[:credentials][:secret], + :app_user_id => auth_hash[:uid], + :app_username => auth_hash[:info][:name], + :url => "http://www.last.fm/user/#{auth_hash[:uid]}", + :image_url => nil #auth_hash[:info][:image] + }) + self + end + + end + + module ClassMethods + + def link(auth_hash, user) + account = self.find_or_create_by_user_id(:user_id => user.id) + account.link(auth_hash, user) + end + + end + + + end + end +end diff --git a/spec/dummy/app/controllers/application_controller.rb b/spec/dummy/app/controllers/application_controller.rb index e8065d9..e31b110 100644 --- a/spec/dummy/app/controllers/application_controller.rb +++ b/spec/dummy/app/controllers/application_controller.rb @@ -1,3 +1,9 @@ class ApplicationController < ActionController::Base protect_from_forgery + + before_filter :register_partials if Rails.env.development? + + def register_partials + HandlebarsConfig.register_partials + end end diff --git a/spec/dummy/app/models/lastfm.rb b/spec/dummy/app/models/lastfm.rb new file mode 100644 index 0000000..3b8f0a7 --- /dev/null +++ b/spec/dummy/app/models/lastfm.rb @@ -0,0 +1,3 @@ +class Lastfm < LinkedAccount + include LetMeIn::LinkedAccounts::LastfmAccount +end diff --git a/spec/dummy/config/initializers/omniauth.rb b/spec/dummy/config/initializers/omniauth.rb index 47c7e1c..ae1faa7 100644 --- a/spec/dummy/config/initializers/omniauth.rb +++ b/spec/dummy/config/initializers/omniauth.rb @@ -17,11 +17,26 @@ provider :banters, Banters.key, Banters.secret, :name => "banters" LetMeIn::Engine.config.account_types << Banters end - + + if Foursquare.available? + provider :foursquare, Foursquare.key, Foursquare.secret, :name => "foursquare" + LetMeIn::Engine.config.account_types << Foursquare + end + if Instagram.available? provider :instagram, Instagram.key, Instagram.secret, :display => 'touch', :name => "instagram" LetMeIn::Engine.config.account_types << Instagram end + + if Lastfm.available? + provider :lastfm, Lastfm.key, Lastfm.secret, :name => "lastfm" + LetMeIn::Engine.config.account_types << Lastfm + end + + if Tumblr.available? + provider :tumblr, Tumblr.key, Tumblr.secret, :name => "tumblr" + LetMeIn::Engine.config.account_types << Tumblr + end if Twitter.available? provider :twitter, Twitter.key, Twitter.secret, :name => "twitter" @@ -34,4 +49,4 @@ } end -OmniAuth.config.logger = Rails.logger \ No newline at end of file +OmniAuth.config.logger = Rails.logger diff --git a/spec/dummy/db/development.sqlite3 b/spec/dummy/db/development.sqlite3 deleted file mode 100644 index 5e3ccca..0000000 Binary files a/spec/dummy/db/development.sqlite3 and /dev/null differ