cornflakeomnisocial 0.1.2.3 → 0.1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/app/controllers/omnisocial/auth_controller.rb +2 -2
- data/app/models/omnisocial/facebook_account.rb +1 -2
- data/app/models/omnisocial/login_account.rb +6 -17
- data/app/models/omnisocial/user.rb +2 -11
- data/lib/extensions/action_controller/base.rb +2 -2
- data/lib/generators/omnisocial/omnisocial_generator.rb +16 -1
- data/lib/generators/omnisocial/templates/migration.rb +35 -0
- data/lib/omnisocial/version.rb +1 -1
- metadata +5 -4
data/README.md
CHANGED
|
@@ -10,7 +10,7 @@ To use OmniSocial in a Rails 3 application:
|
|
|
10
10
|
|
|
11
11
|
2. Install it by running `bundle`.
|
|
12
12
|
|
|
13
|
-
3. Run `rails g omnisocial` to copy an initializer and some CSS and image assets into your base application directory.
|
|
13
|
+
3. Run `rails g omnisocial` to copy an initializer, database migration and some CSS and image assets into your base application directory.
|
|
14
14
|
|
|
15
15
|
4. Edit `config/initializers/omnisocial.rb` and include your application's Twitter and Facebook OAuth configuration.
|
|
16
16
|
|
|
@@ -25,13 +25,13 @@ module Omnisocial
|
|
|
25
25
|
flash[:message] = 'You have logged in successfully.'
|
|
26
26
|
redirect_back_or_default(root_path)
|
|
27
27
|
else
|
|
28
|
-
@user =
|
|
28
|
+
@user = User.new(:display_name => @account.name)
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def confirm
|
|
33
33
|
@account = Omnisocial::LoginAccount.find(params[:account_id])
|
|
34
|
-
@user =
|
|
34
|
+
@user = User.new(params[:omnisocial_user].merge(:picture_url => @account.picture_url))
|
|
35
35
|
if @user.save
|
|
36
36
|
@account.update_attributes(:user => @user)
|
|
37
37
|
self.current_user = @user
|
|
@@ -5,14 +5,13 @@ module Omnisocial
|
|
|
5
5
|
self.remote_account_id = auth_hash['uid']
|
|
6
6
|
self.login = auth_hash['user_info']['nickname']
|
|
7
7
|
self.name = auth_hash['user_info']['name']
|
|
8
|
-
self.picture_url = generate_picture_url
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
def account_url
|
|
12
11
|
"http://facebook.com/#{self.login}"
|
|
13
12
|
end
|
|
14
13
|
|
|
15
|
-
def
|
|
14
|
+
def picture_url
|
|
16
15
|
if self.login.include?('profile.php')
|
|
17
16
|
"https://graph.facebook.com/#{self.login.gsub(/[^\d]/, '')}/picture?type=square"
|
|
18
17
|
else
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
module Omnisocial
|
|
2
|
-
class LoginAccount
|
|
3
|
-
|
|
4
|
-
include Mongoid::Timestamps
|
|
5
|
-
|
|
6
|
-
referenced_in :user
|
|
7
|
-
|
|
8
|
-
field :token
|
|
9
|
-
field :secret
|
|
10
|
-
field :remote_account_id
|
|
11
|
-
field :name
|
|
12
|
-
field :login
|
|
13
|
-
field :picture_url
|
|
2
|
+
class LoginAccount < ActiveRecord::Base
|
|
3
|
+
belongs_to :user
|
|
14
4
|
|
|
15
5
|
def self.find_or_create_from_auth_hash(auth_hash)
|
|
16
|
-
if (account =
|
|
6
|
+
if (account = find_by_remote_account_id(auth_hash['uid']))
|
|
17
7
|
account.assign_account_info(auth_hash)
|
|
18
8
|
account.save
|
|
19
9
|
account
|
|
@@ -23,10 +13,9 @@ module Omnisocial
|
|
|
23
13
|
end
|
|
24
14
|
|
|
25
15
|
def self.create_from_auth_hash(auth_hash)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
account
|
|
16
|
+
create do |account|
|
|
17
|
+
account.assign_account_info(auth_hash)
|
|
18
|
+
end
|
|
30
19
|
end
|
|
31
20
|
|
|
32
21
|
end
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
module Omnisocial
|
|
2
|
-
class User
|
|
3
|
-
|
|
4
|
-
include Mongoid::Timestamps
|
|
5
|
-
|
|
6
|
-
field :remember_token
|
|
7
|
-
field :display_name
|
|
8
|
-
field :email_address
|
|
9
|
-
field :picture_url
|
|
10
|
-
|
|
11
|
-
references_many :login_accounts, :class_name => 'Omnisocial::LoginAccount', :dependent => :destroy
|
|
12
|
-
|
|
2
|
+
class User < ActiveRecord::Base
|
|
3
|
+
has_many :login_accounts, :class_name => 'Omnisocial::LoginAccount', :dependent => :destroy
|
|
13
4
|
validates_presence_of :display_name, :email_address
|
|
14
5
|
|
|
15
6
|
def facebook_account
|
|
@@ -32,9 +32,9 @@ class ActionController::Base
|
|
|
32
32
|
|
|
33
33
|
def current_user
|
|
34
34
|
@current_user ||= if session[:user_id]
|
|
35
|
-
User.
|
|
35
|
+
User.find_by_id(session[:user_id])
|
|
36
36
|
elsif cookies[:remember_token]
|
|
37
|
-
User.
|
|
37
|
+
User.find_by_remember_token(cookies[:remember_token])
|
|
38
38
|
else
|
|
39
39
|
false
|
|
40
40
|
end
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
require 'rails/generators'
|
|
2
|
+
require 'rails/generators/migration'
|
|
2
3
|
|
|
3
4
|
module Omnisocial
|
|
4
5
|
module Generators
|
|
5
6
|
class OmnisocialGenerator < Rails::Generators::Base
|
|
6
7
|
include Rails::Generators::Migration
|
|
7
8
|
|
|
8
|
-
desc 'Creates an omnisocial initializer and copies image and CSS assets.'
|
|
9
|
+
desc 'Creates an omnisocial initializer and migration, and copies image and CSS assets.'
|
|
9
10
|
|
|
10
11
|
def self.source_root
|
|
11
12
|
File.join(File.dirname(__FILE__), 'templates')
|
|
12
13
|
end
|
|
13
14
|
|
|
15
|
+
# Implement the required interface for Rails::Generators::Migration:
|
|
16
|
+
# http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
|
17
|
+
def self.next_migration_number(dirname)
|
|
18
|
+
if ActiveRecord::Base.timestamped_migrations
|
|
19
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
|
20
|
+
else
|
|
21
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def create_migration_file
|
|
26
|
+
migration_template 'migration.rb', 'db/migrate/create_omnisocial_tables.rb'
|
|
27
|
+
end
|
|
28
|
+
|
|
14
29
|
def copy_initializer
|
|
15
30
|
template 'omnisocial.rb', 'config/initializers/omnisocial.rb'
|
|
16
31
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class CreateOmnisocialTables < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :users do |t|
|
|
4
|
+
t.string :remember_token
|
|
5
|
+
# Any additional fields here
|
|
6
|
+
t.string :display_name
|
|
7
|
+
t.string :email_address
|
|
8
|
+
t.string :picture_url
|
|
9
|
+
|
|
10
|
+
t.timestamps
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
create_table :login_accounts do |t|
|
|
14
|
+
t.string :type
|
|
15
|
+
t.string :user_id
|
|
16
|
+
t.string :remote_account_id
|
|
17
|
+
t.string :name
|
|
18
|
+
t.string :login
|
|
19
|
+
t.string :picture_url
|
|
20
|
+
# Any additional fields here
|
|
21
|
+
|
|
22
|
+
t.timestamps
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
add_index :login_accounts, :user_id
|
|
26
|
+
add_index :login_accounts, :type
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.down
|
|
30
|
+
remove_index :login_accounts, :type
|
|
31
|
+
remove_index :login_accounts, :user_id
|
|
32
|
+
drop_table :login_accounts
|
|
33
|
+
drop_table :users
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/omnisocial/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cornflakeomnisocial
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 71
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 1
|
|
9
9
|
- 2
|
|
10
|
-
-
|
|
11
|
-
version: 0.1.2.
|
|
10
|
+
- 4
|
|
11
|
+
version: 0.1.2.4
|
|
12
12
|
platform: ruby
|
|
13
13
|
authors:
|
|
14
14
|
- Jason Kotchoff
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date: 2011-01-
|
|
19
|
+
date: 2011-01-17 00:00:00 +11:00
|
|
20
20
|
default_executable:
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|
|
@@ -77,6 +77,7 @@ extra_rdoc_files: []
|
|
|
77
77
|
files:
|
|
78
78
|
- README.md
|
|
79
79
|
- lib/generators/omnisocial/templates/omnisocial.rb
|
|
80
|
+
- lib/generators/omnisocial/templates/migration.rb
|
|
80
81
|
- lib/generators/omnisocial/templates/assets/images/signin_twitter.png
|
|
81
82
|
- lib/generators/omnisocial/templates/assets/images/twitter.gif
|
|
82
83
|
- lib/generators/omnisocial/templates/assets/images/signin_facebook.png
|