social_stream 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +2 -0
  2. data/app/controllers/authentications_controller.rb +17 -0
  3. data/app/controllers/omniauth_callbacks_controller.rb +17 -0
  4. data/app/models/actor.rb +11 -1
  5. data/app/models/authentication.rb +3 -0
  6. data/app/models/permission.rb +81 -18
  7. data/app/models/relation.rb +21 -3
  8. data/app/models/tie.rb +38 -20
  9. data/app/models/user.rb +29 -0
  10. data/app/views/frontpage/_sponsor.html.erb +6 -6
  11. data/app/views/groups/index.html.erb +1 -1
  12. data/app/views/layouts/_header.erb +1 -1
  13. data/app/views/layouts/application.html.erb +3 -3
  14. data/app/views/users/_profile.html.erb +5 -3
  15. data/app/views/users/edit.html.erb +105 -114
  16. data/app/views/users/index.html.erb +7 -6
  17. data/bin/social_stream +0 -0
  18. data/bin/social_stream_heroku +76 -0
  19. data/config/locales/en.yml +1 -0
  20. data/config/routes.rb +1 -2
  21. data/lib/generators/social_stream/install_generator.rb +8 -0
  22. data/lib/generators/social_stream/templates/initializer.rb +2 -2
  23. data/lib/generators/social_stream/templates/migration.rb +15 -0
  24. data/lib/generators/social_stream/templates/public/stylesheets/browse.css +47 -5
  25. data/lib/generators/social_stream/templates/public/stylesheets/edit_user.css +32 -19
  26. data/lib/generators/social_stream/templates/public/stylesheets/index.css +25 -13
  27. data/lib/generators/social_stream/templates/public/stylesheets/jqcloud.css +2 -2
  28. data/lib/generators/social_stream/templates/public/stylesheets/users.css +0 -22
  29. data/lib/generators/social_stream/templates/relations.yml +25 -20
  30. data/lib/social_stream.rb +1 -1
  31. data/lib/social_stream/models/subject.rb +9 -1
  32. data/lib/social_stream/rails.rb +2 -0
  33. data/lib/social_stream/version.rb +1 -1
  34. data/social_stream.gemspec +4 -1
  35. data/spec/dummy/config/initializers/devise.rb +71 -40
  36. data/spec/dummy/config/initializers/social_stream.rb +2 -2
  37. data/spec/dummy/config/relations.yml +25 -20
  38. data/spec/dummy/script/rails +0 -0
  39. data/spec/models/activity_spec.rb +3 -3
  40. data/spec/models/tie_spec.rb +1 -1
  41. metadata +78 -24
@@ -22,7 +22,7 @@ div#wordcloud span {
22
22
  }
23
23
  div#wordcloud span.w10 {
24
24
  font-size: 44px;
25
- color: #0cf;
25
+ color: #1F4A75;
26
26
  }
27
27
  div#wordcloud span.w9 {
28
28
  font-size: 40px;
@@ -34,7 +34,7 @@ div#wordcloud span.w8 {
34
34
  }
35
35
  div#wordcloud span.w7 {
36
36
  font-size: 30px;
37
- color: #39d;
37
+ color: #0cf;
38
38
  }
39
39
  div#wordcloud span.w6 {
40
40
  font-size: 24px;
@@ -1,22 +0,0 @@
1
- #ajax_loader_icon, .pagination{
2
- text-align:center;
3
- padding-top: 20px;
4
- }
5
-
6
- .letters{
7
- text-align:center;
8
- padding-bottom: 20px;
9
- }
10
-
11
- .search_input{
12
- border-color: #0656a4;
13
- color: #2A3890;
14
- margin-left: 5px;
15
- padding: 2px 2px 2px 2px;
16
- border:1px solid #BDC7D8;
17
- }
18
-
19
- #search_button{
20
- cursor: pointer;
21
- margin-top: 2px;
22
- }
@@ -1,43 +1,48 @@
1
- # Relations for Social Stream
1
+ # Default relations for Social Stream
2
2
  #
3
- # Define the relations and permissions supported by your application
3
+ # Define the default relations and permissions supported by your application
4
+ # Though subjects can customize their own relations, these are the defaults
5
+ # to start up
6
+ #
7
+ # Detailed information on permissions is available at:
8
+ # http://rdoc.info/gems/social_stream/Permission
4
9
  #
5
10
  user:
6
11
  friend:
7
12
  name: friend
8
13
  permissions:
9
- - [ follow ]
10
- - [ create, activity, weak_set ]
11
- - [ read, activity, star_set ]
12
- - [ update, activity, weak_set ]
13
- - [ destroy, activity, weak_set ]
14
+ - [ follow ] # follow the activities of the friend
15
+ - [ create, activity, tie ] # let the friend create activities to the same tie
16
+ - [ read, activity, star_ties ] # friend can read activities from the other friends
17
+ - [ update, activity, tie ] # update activities to the same tie
18
+ - [ destroy, activity, tie ] # destroy activities to the same tie
14
19
  acquaintance:
15
20
  name: acquaintance
16
- parent: friend
21
+ parent: friend # friend relation is stronger than acquaintance
17
22
  permissions:
18
- - [ read, activity, star_set ]
23
+ - [ read, activity, star_ties ]
19
24
  public:
20
25
  name: public
21
- parent: acquaintance
26
+ parent: acquaintance # acquaintance is stronger than public
22
27
  permissions:
23
- - [ read, activity, star_set ]
28
+ - [ read, activity, star_ties ]
24
29
 
25
30
  group:
26
31
  member:
27
32
  name: member
28
33
  permissions:
29
- - [ represent ]
30
- - [ create, activity, weak_set ]
31
- - [ read, activity, star_set ]
32
- - [ update, activity, weak_star_set ]
33
- - [ destroy, activity, weak_star_set ]
34
+ - [ represent ] # let the member act as the group
35
+ - [ create, activity, weak_ties ] # let them member create activities at the level of member, partner and public
36
+ - [ read, activity, star_ties ] # read activities from other members
37
+ - [ update, activity, weak_star_ties ] # update and destroy activities to members,
38
+ - [ destroy, activity, weak_star_ties ] # acquaintance and public
34
39
  partner:
35
40
  name: partner
36
- parent: member
41
+ parent: member # member is stronger than partner
37
42
  permissions:
38
- - [ read, activity, star_set ]
43
+ - [ read, activity, star_ties ]
39
44
  public:
40
45
  name: public
41
- parent: partner
46
+ parent: partner # partner is stronger than public
42
47
  permissions:
43
- - [ read, activity, star_set ]
48
+ - [ read, activity, star_ties ]
data/lib/social_stream.rb CHANGED
@@ -19,7 +19,7 @@ module SocialStream
19
19
 
20
20
  mattr_accessor :devise_modules
21
21
  @@devise_modules = [ :database_authenticatable, :registerable, :recoverable,
22
- :rememberable, :trackable ]
22
+ :rememberable, :trackable, :omniauthable ]
23
23
 
24
24
  mattr_accessor :objects
25
25
  @@objects = [ :post, :comment ]
@@ -2,7 +2,15 @@ require 'active_support/concern'
2
2
 
3
3
  module SocialStream
4
4
  module Models
5
- # Additional features for models that are subtypes of actors, like User or Group
5
+ # {Subject Subjects} are subtypes of {Actor}. {SocialStream} provides two
6
+ # {Subject Subjects}, {User} and {Group}
7
+ #
8
+ # Each {Subject} is defined in +config/initializers/social_stream.rb+
9
+ #
10
+ # This module provides additional features for models that are subjects,
11
+ # extending them. Including the module in each {Subject} model is not required!
12
+ # After declared in +config/initializers/social_stream.rb+, {SocialStream} is
13
+ # responsible for adding subject features to each model.
6
14
  module Subject
7
15
  extend ActiveSupport::Concern
8
16
 
@@ -19,6 +19,8 @@ require 'paperclip'
19
19
  require 'paperclip/social_stream'
20
20
  # Pagination
21
21
  require 'will_paginate'
22
+ # Oauth
23
+ require 'omniauth/oauth'
22
24
 
23
25
  module SocialStream
24
26
  class Engine < ::Rails::Engine #:nodoc:
@@ -1,3 +1,3 @@
1
1
  module SocialStream
2
- VERSION = "0.3.5".freeze
2
+ VERSION = "0.3.6".freeze
3
3
  end
@@ -12,13 +12,15 @@ Gem::Specification.new do |s|
12
12
  s.add_runtime_dependency('atd-ancestry', '1.3.0')
13
13
  s.add_runtime_dependency('nested_set', '~> 1.5.3')
14
14
  s.add_runtime_dependency('foreigner', '~> 0.9.1')
15
- s.add_runtime_dependency('devise', '~> 1.1.7')
15
+ s.add_runtime_dependency('devise', '~> 1.2.rc')
16
16
  s.add_runtime_dependency('inherited_resources', '~> 1.1.2')
17
17
  s.add_runtime_dependency('stringex', '~> 1.2.0')
18
18
  s.add_runtime_dependency('paperclip', '~> 2.3.4')
19
19
  s.add_runtime_dependency('jquery-rails', '~> 0.2.5')
20
20
  s.add_runtime_dependency('cancan', '~> 1.5.1')
21
21
  s.add_runtime_dependency('will_paginate', '~> 3.0.pre2')
22
+ s.add_runtime_dependency('omniauth','~> 0.2.0.beta5')
23
+ s.add_runtime_dependency('oauth-plugin','~> 0.4.0.pre1')
22
24
  s.add_development_dependency('rails', '~> 3.0.5')
23
25
  s.add_development_dependency('capybara', '~> 0.3.9')
24
26
  s.add_development_dependency('sqlite3-ruby')
@@ -29,4 +31,5 @@ Gem::Specification.new do |s|
29
31
  s.add_development_dependency('factory_girl', '~> 1.3.2')
30
32
  s.add_development_dependency('forgery', '~> 0.3.6')
31
33
  s.add_development_dependency('ci_reporter', '~> 1.6.4')
34
+ s.add_development_dependency('nifty-generators','~> 0.4.5')
32
35
  end
@@ -15,23 +15,37 @@ Devise.setup do |config|
15
15
  require 'devise/orm/active_record'
16
16
 
17
17
  # ==> Configuration for any authentication mechanism
18
- # Configure which keys are used when authenticating an user. By default is
18
+ # Configure which keys are used when authenticating a user. The default is
19
19
  # just :email. You can configure it to use [:username, :subdomain], so for
20
- # authenticating an user, both parameters are required. Remember that those
20
+ # authenticating a user, both parameters are required. Remember that those
21
21
  # parameters are used only when authenticating and not when retrieving from
22
22
  # session. If you need permissions, you should implement that in a before filter.
23
+ # You can also supply a hash where the value is a boolean determining whether
24
+ # or not authentication should be aborted when the value is not present.
23
25
  # config.authentication_keys = [ :email ]
24
26
 
27
+ # Configure parameters from the request object used for authentication. Each entry
28
+ # given should be a request method and it will automatically be passed to the
29
+ # find_for_authentication method and considered in your model lookup. For instance,
30
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
31
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
32
+ # config.request_keys = []
33
+
34
+ # Configure which authentication keys should be case-insensitive.
35
+ # These keys will be downcased upon creating or modifying a user and when used
36
+ # to authenticate or find a user. Default is :email.
37
+ # config.case_insensitive_keys = [ :email ]
38
+
25
39
  # Tell if authentication through request.params is enabled. True by default.
26
40
  # config.params_authenticatable = true
27
41
 
28
- # Tell if authentication through HTTP Basic Auth is enabled. True by default.
29
- # config.http_authenticatable = true
42
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
43
+ # config.http_authenticatable = false
30
44
 
31
- # Set this to true to use Basic Auth for AJAX requests. True by default.
45
+ # If http headers should be returned for AJAX requests. True by default.
32
46
  # config.http_authenticatable_on_xhr = true
33
47
 
34
- # The realm used in Http Basic Authentication
48
+ # The realm used in Http Basic Authentication. "Application" by default.
35
49
  # config.http_authentication_realm = "Application"
36
50
 
37
51
  # ==> Configuration for :database_authenticatable
@@ -39,22 +53,13 @@ Devise.setup do |config|
39
53
  # using other encryptors, it sets how many times you want the password re-encrypted.
40
54
  config.stretches = 10
41
55
 
42
- # Define which will be the encryption algorithm. Devise also supports encryptors
43
- # from others authentication tools as :clearance_sha1, :authlogic_sha512 (then
44
- # you should set stretches above to 20 for default behavior) and :restful_authentication_sha1
45
- # (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
46
- config.encryptor = :bcrypt
47
-
48
- # Setup a pepper to generate the encrypted password.
49
- config.pepper = "0f41b9a7507f1d62d825b9599df4ba96b82b0455b6ab2bc4569aaad4b7a948631bce63227ab7f6211e4c00275077020158402e54a72ddc309d261023424d5e6c"
50
-
51
56
  # ==> Configuration for :confirmable
52
57
  # The time you want to give your user to confirm his account. During this time
53
- # he will be able to access your application without confirming. Default is nil.
54
- # When confirm_within is zero, the user won't be able to sign in without confirming.
55
- # You can use this to let your user access some features of your application
56
- # without confirming the account, but blocking it after a certain period
57
- # (ie 2 days).
58
+ # he will be able to access your application without confirming. Default is 0.days
59
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
60
+ # You can use this to let your user access some features of your application
61
+ # without confirming the account, but blocking it after a certain period
62
+ # (ie 2 days).
58
63
  # config.confirm_within = 2.days
59
64
 
60
65
  # ==> Configuration for :rememberable
@@ -67,8 +72,12 @@ Devise.setup do |config|
67
72
  # If true, extends the user's remember period when remembered via cookie.
68
73
  # config.extend_remember_period = false
69
74
 
75
+ # If true, uses the password salt as remember token. This should be turned
76
+ # to false if you are not using database authenticatable.
77
+ config.use_salt_as_remember_token = true
78
+
70
79
  # ==> Configuration for :validatable
71
- # Range for password length
80
+ # Range for password length. Default is 6..20.
72
81
  # config.password_length = 6..20
73
82
 
74
83
  # Regex to use to validate the email address
@@ -76,8 +85,8 @@ Devise.setup do |config|
76
85
 
77
86
  # ==> Configuration for :timeoutable
78
87
  # The time you want to timeout the user session without activity. After this
79
- # time the user will be asked for credentials again.
80
- # config.timeout_in = 10.minutes
88
+ # time the user will be asked for credentials again. Default is 30 minutes.
89
+ # config.timeout_in = 30.minutes
81
90
 
82
91
  # ==> Configuration for :lockable
83
92
  # Defines which strategy will be used to lock an account.
@@ -99,44 +108,66 @@ Devise.setup do |config|
99
108
  # Time interval to unlock the account if :time is enabled as unlock_strategy.
100
109
  # config.unlock_in = 1.hour
101
110
 
111
+ # ==> Configuration for :encryptable
112
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
113
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
114
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
115
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
116
+ # REST_AUTH_SITE_KEY to pepper)
117
+ # config.encryptor = :sha512
118
+
119
+ # Setup a pepper to generate the encrypted password.
120
+ # config.pepper = "6efecaefd488a07abded679d45be30dc97935d74c44825b647149a6fa30ee8cd5e05bb3a426ce8a87fcd75b04079b1bac68a079acdcc175800c4131dde7961f0"
121
+
102
122
  # ==> Configuration for :token_authenticatable
103
123
  # Defines name of the authentication token params key
104
124
  # config.token_authentication_key = :auth_token
105
125
 
126
+ # If true, authentication through token does not store user in session and needs
127
+ # to be supplied on each request. Useful if you are using the token as API token.
128
+ # config.stateless_token = false
129
+
106
130
  # ==> Scopes configuration
107
131
  # Turn scoped views on. Before rendering "sessions/new", it will first check for
108
132
  # "users/sessions/new". It's turned off by default because it's slower if you
109
133
  # are using only default views.
110
- # config.scoped_views = true
134
+ # config.scoped_views = false
111
135
 
112
136
  # Configure the default scope given to Warden. By default it's the first
113
- # devise role declared in your routes.
137
+ # devise role declared in your routes (usually :user).
114
138
  # config.default_scope = :user
115
139
 
116
- # Configure sign_out behavior.
117
- # By default sign_out is scoped (i.e. /users/sign_out affects only :user scope).
118
- # In case of sign_out_all_scopes set to true any logout action will sign out all active scopes.
119
- # config.sign_out_all_scopes = false
140
+ # Configure sign_out behavior.
141
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
142
+ # The default is true, which means any logout action will sign out all active scopes.
143
+ # config.sign_out_all_scopes = true
120
144
 
121
145
  # ==> Navigation configuration
122
146
  # Lists the formats that should be treated as navigational. Formats like
123
147
  # :html, should redirect to the sign in page when the user does not have
124
148
  # access, but formats like :xml or :json, should return 401.
149
+ #
125
150
  # If you have any extra navigational formats, like :iphone or :mobile, you
126
- # should add them to the navigational formats lists. Default is [:html]
127
- # config.navigational_formats = [:html, :iphone]
151
+ # should add them to the navigational formats lists.
152
+ #
153
+ # The :"*/*" format below is required to match Internet Explorer requests.
154
+ # config.navigational_formats = [:"*/*", :html]
155
+
156
+ # The default HTTP method used to sign out a resource. Default is :get.
157
+ # config.sign_out_via = :get
158
+
159
+ # ==> OmniAuth
160
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
161
+ # up on your models and hooks.
162
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
128
163
 
129
164
  # ==> Warden configuration
130
- # If you want to use other strategies, that are not (yet) supported by Devise,
131
- # you can configure them inside the config.warden block. The example below
132
- # allows you to setup OAuth, using http://github.com/roman/warden_oauth
165
+ # If you want to use other strategies, that are not supported by Devise, or
166
+ # change the failure app, you can configure them inside the config.warden block.
133
167
  #
134
168
  # config.warden do |manager|
135
- # manager.oauth(:twitter) do |twitter|
136
- # twitter.consumer_secret = <YOUR CONSUMER SECRET>
137
- # twitter.consumer_key = <YOUR CONSUMER KEY>
138
- # twitter.options :site => 'http://twitter.com'
139
- # end
140
- # manager.default_strategies(:scope => :user).unshift :twitter_oauth
169
+ # manager.failure_app = AnotherApp
170
+ # manager.intercept_401 = false
171
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
141
172
  # end
142
173
  end
@@ -8,8 +8,8 @@ SocialStream.setup do |config|
8
8
  # Others available are:
9
9
  # :token_authenticatable, :confirmable, :lockable, :timeoutable, :validatable
10
10
  # config.devise_modules :database_authenticatable, :registerable,
11
- # :recoverable, :rememberable, :trackable
12
-
11
+ # :recoverable, :rememberable, :trackable, :omniauthable
12
+
13
13
  # Type of activities managed by actors
14
14
  # Remember you must add an "activity_object_id" foreign key column to your migration!
15
15
  #
@@ -1,43 +1,48 @@
1
- # Relations for Social Stream
1
+ # Default relations for Social Stream
2
2
  #
3
- # Define the relations and permissions supported by your application
3
+ # Define the default relations and permissions supported by your application
4
+ # Though subjects can customize their own relations, these are the defaults
5
+ # to start up
6
+ #
7
+ # Detailed information on permissions is available at:
8
+ # http://rdoc.info/gems/social_stream/Permission
4
9
  #
5
10
  user:
6
11
  friend:
7
12
  name: friend
8
13
  permissions:
9
- - [ follow ]
10
- - [ create, activity, weak_set ]
11
- - [ read, activity, star_set ]
12
- - [ update, activity, weak_set ]
13
- - [ destroy, activity, weak_set ]
14
+ - [ follow ] # follow the activities of the friend
15
+ - [ create, activity, tie ] # let the friend create activities to the same tie
16
+ - [ read, activity, star_ties ] # friend can read activities from the other friends
17
+ - [ update, activity, tie ] # update activities to the same tie
18
+ - [ destroy, activity, tie ] # destroy activities to the same tie
14
19
  acquaintance:
15
20
  name: acquaintance
16
- parent: friend
21
+ parent: friend # friend relation is stronger than acquaintance
17
22
  permissions:
18
- - [ read, activity, star_set ]
23
+ - [ read, activity, star_ties ]
19
24
  public:
20
25
  name: public
21
- parent: acquaintance
26
+ parent: acquaintance # acquaintance is stronger than public
22
27
  permissions:
23
- - [ read, activity, star_set ]
28
+ - [ read, activity, star_ties ]
24
29
 
25
30
  group:
26
31
  member:
27
32
  name: member
28
33
  permissions:
29
- - [ represent ]
30
- - [ create, activity, weak_set ]
31
- - [ read, activity, star_set ]
32
- - [ update, activity, weak_star_set ]
33
- - [ destroy, activity, weak_star_set ]
34
+ - [ represent ] # let the member act as the group
35
+ - [ create, activity, weak_ties ] # let them member create activities at the level of member, partner and public
36
+ - [ read, activity, star_ties ] # read activities from other members
37
+ - [ update, activity, weak_star_ties ] # update and destroy activities to members,
38
+ - [ destroy, activity, weak_star_ties ] # acquaintance and public
34
39
  partner:
35
40
  name: partner
36
- parent: member
41
+ parent: member # member is stronger than partner
37
42
  permissions:
38
- - [ read, activity, star_set ]
43
+ - [ read, activity, star_ties ]
39
44
  public:
40
45
  name: public
41
- parent: partner
46
+ parent: partner # partner is stronger than public
42
47
  permissions:
43
- - [ read, activity, star_set ]
48
+ - [ read, activity, star_ties ]
File without changes
@@ -205,10 +205,10 @@ describe Activity do
205
205
  create_ability_accessed_by_receiver
206
206
  end
207
207
 
208
- it_should_behave_like "Allows Creating"
208
+ it_should_behave_like "Denies Creating"
209
209
  it_should_behave_like "Allows Reading"
210
- it_should_behave_like "Allows Updating"
211
- it_should_behave_like "Allows Destroying"
210
+ it_should_behave_like "Denies Updating"
211
+ it_should_behave_like "Denies Destroying"
212
212
  end
213
213
 
214
214
  describe "accessed by a friend" do