social_stream-base 0.9.35 → 0.9.36
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/app/helpers/settings_helper.rb +9 -0
- data/app/views/settings/_index.html.erb +2 -15
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/lib/social_stream/ability/base.rb +101 -0
- data/lib/social_stream/ability.rb +3 -95
- data/lib/social_stream/{base.rb → base/engine.rb} +6 -0
- data/lib/social_stream/base/version.rb +1 -1
- data/lib/social_stream/views/settings/base.rb +43 -0
- data/lib/social_stream/views/settings/item_list.rb +13 -0
- data/lib/social_stream-base.rb +8 -5
- metadata +9 -5
@@ -4,18 +4,5 @@
|
|
4
4
|
<h2><%= t('settings.for')%> <%= current_subject.name %></h2>
|
5
5
|
<div class="space_center">
|
6
6
|
</div>
|
7
|
-
|
8
|
-
<%=
|
9
|
-
<% end %>
|
10
|
-
<%= render :partial => "notifications" %>
|
11
|
-
<% if current_subject.respond_to? :authentication_token%>
|
12
|
-
<%= render :partial => "api_key" %>
|
13
|
-
<% end %>
|
14
|
-
<% if current_subject==current_user %>
|
15
|
-
<%= render :partial => "devise/registrations/delete_account", :locals => { :resource => current_user, :resource_name => :user }%>
|
16
|
-
<% else %>
|
17
|
-
<%= render :partial => 'destroy' %>
|
18
|
-
<% end %>
|
19
|
-
<% if defined?(SocialStream::Presence) and SocialStream::Presence.enable %>
|
20
|
-
<%= render :partial => 'chat/settings' %>
|
21
|
-
<% end %>
|
7
|
+
|
8
|
+
<%= render_settings %>
|
data/config/locales/en.yml
CHANGED
@@ -190,7 +190,7 @@ en:
|
|
190
190
|
destroy:
|
191
191
|
one: "Destroy group"
|
192
192
|
explanation: "All the activities, information and contacts of this group will be destroyed!"
|
193
|
-
go_ahead: "Yes, I am sure.
|
193
|
+
go_ahead: "Yes, I am sure. Destroy all!"
|
194
194
|
last_confirm: "This is your last chance. Are you really sure?"
|
195
195
|
form:
|
196
196
|
title: "Group"
|
data/config/locales/es.yml
CHANGED
@@ -190,7 +190,7 @@ es:
|
|
190
190
|
destroy:
|
191
191
|
one: "Destruir grupo"
|
192
192
|
explanation: "¡Todas las actividades, información y contactos de este grupo serán destruídos!"
|
193
|
-
go_ahead: "Sí, estoy seguro/a. ¡
|
193
|
+
go_ahead: "Sí, estoy seguro/a. ¡Destruirlo todo!"
|
194
194
|
last_confirm: "Es tu última oportunidad. ¿Realmente estás seguro/a?"
|
195
195
|
form:
|
196
196
|
title: "Grupo"
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module SocialStream
|
2
|
+
class Ability
|
3
|
+
module Base
|
4
|
+
include CanCan::Ability
|
5
|
+
|
6
|
+
# Create a new ability for this user, who is currently representing subject
|
7
|
+
def initialize(subject)
|
8
|
+
|
9
|
+
#Download alias action
|
10
|
+
alias_action :download, :to => :show
|
11
|
+
|
12
|
+
# Activity Objects
|
13
|
+
(SocialStream.objects - [ :actor, :comment ]).map{ |obj|
|
14
|
+
obj.to_s.classify.constantize
|
15
|
+
}.each do |klass|
|
16
|
+
can :create, klass do |k| # can :create, Post do |post|
|
17
|
+
k.build_post_activity.allow?(subject, 'create')
|
18
|
+
end
|
19
|
+
|
20
|
+
can :read, klass do |k| # can :read, Post do |post|
|
21
|
+
k.post_activity.allow?(subject, 'read')
|
22
|
+
end
|
23
|
+
|
24
|
+
can :update, klass do |k| # can :update, Post do |post|
|
25
|
+
k.post_activity.allow?(subject, 'update')
|
26
|
+
end
|
27
|
+
|
28
|
+
can :destroy, klass do |k| # can :destroy, Post do |post|
|
29
|
+
k.post_activity.allow?(subject, 'destroy')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
can :create, Comment do |c|
|
34
|
+
c._activity_parent.allow?(subject, 'read')
|
35
|
+
end
|
36
|
+
|
37
|
+
can :read, Comment do |c|
|
38
|
+
c.post_activity.allow?(subject, 'read')
|
39
|
+
end
|
40
|
+
|
41
|
+
can :update, Comment do |c|
|
42
|
+
c.post_activity.allow?(subject, 'update')
|
43
|
+
end
|
44
|
+
|
45
|
+
can :destroy, Comment do |c|
|
46
|
+
c.post_activity.allow?(subject, 'destroy')
|
47
|
+
end
|
48
|
+
|
49
|
+
# Activities
|
50
|
+
can :create, Activity do |a|
|
51
|
+
a.allow?(subject, 'create')
|
52
|
+
end
|
53
|
+
|
54
|
+
can :read, Activity do |a|
|
55
|
+
a.allow?(subject, 'read')
|
56
|
+
end
|
57
|
+
|
58
|
+
can :update, Activity do |a|
|
59
|
+
a.allow?(subject, 'update')
|
60
|
+
end
|
61
|
+
|
62
|
+
can :destroy, Activity do |a|
|
63
|
+
a.allow?(subject, 'destroy')
|
64
|
+
end
|
65
|
+
|
66
|
+
# Users
|
67
|
+
can :read, User
|
68
|
+
|
69
|
+
can :update, User do |u|
|
70
|
+
u.represented_by?(subject)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Groups
|
74
|
+
can :read, Group
|
75
|
+
|
76
|
+
can :create, Group do |g|
|
77
|
+
subject.present? &&
|
78
|
+
g._contact.sender_id == Actor.normalize_id(subject)
|
79
|
+
end
|
80
|
+
|
81
|
+
can :update, Group do |g|
|
82
|
+
g.represented_by?(subject)
|
83
|
+
end
|
84
|
+
|
85
|
+
can :destroy, Group do |g|
|
86
|
+
g.represented_by?(subject)
|
87
|
+
end
|
88
|
+
|
89
|
+
can :read, Profile
|
90
|
+
|
91
|
+
# Profile
|
92
|
+
can :update, Profile do |p|
|
93
|
+
p.subject.represented_by?(subject)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Privacy
|
97
|
+
can [:create, :read, :update, :destroy], Relation::Custom, :actor_id => subject.try(:actor_id)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -1,99 +1,7 @@
|
|
1
|
+
require 'social_stream/ability/base'
|
2
|
+
|
1
3
|
module SocialStream
|
2
4
|
class Ability
|
3
|
-
include
|
4
|
-
|
5
|
-
# Create a new ability for this user, who is currently representing subject
|
6
|
-
def initialize(subject)
|
7
|
-
|
8
|
-
#Download alias action
|
9
|
-
alias_action :download, :to => :show
|
10
|
-
|
11
|
-
# Activity Objects
|
12
|
-
(SocialStream.objects - [ :actor, :comment ]).map{ |obj|
|
13
|
-
obj.to_s.classify.constantize
|
14
|
-
}.each do |klass|
|
15
|
-
can :create, klass do |k| # can :create, Post do |post|
|
16
|
-
k.build_post_activity.allow?(subject, 'create')
|
17
|
-
end
|
18
|
-
|
19
|
-
can :read, klass do |k| # can :read, Post do |post|
|
20
|
-
k.post_activity.allow?(subject, 'read')
|
21
|
-
end
|
22
|
-
|
23
|
-
can :update, klass do |k| # can :update, Post do |post|
|
24
|
-
k.post_activity.allow?(subject, 'update')
|
25
|
-
end
|
26
|
-
|
27
|
-
can :destroy, klass do |k| # can :destroy, Post do |post|
|
28
|
-
k.post_activity.allow?(subject, 'destroy')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
can :create, Comment do |c|
|
33
|
-
c._activity_parent.allow?(subject, 'read')
|
34
|
-
end
|
35
|
-
|
36
|
-
can :read, Comment do |c|
|
37
|
-
c.post_activity.allow?(subject, 'read')
|
38
|
-
end
|
39
|
-
|
40
|
-
can :update, Comment do |c|
|
41
|
-
c.post_activity.allow?(subject, 'update')
|
42
|
-
end
|
43
|
-
|
44
|
-
can :destroy, Comment do |c|
|
45
|
-
c.post_activity.allow?(subject, 'destroy')
|
46
|
-
end
|
47
|
-
|
48
|
-
# Activities
|
49
|
-
can :create, Activity do |a|
|
50
|
-
a.allow?(subject, 'create')
|
51
|
-
end
|
52
|
-
|
53
|
-
can :read, Activity do |a|
|
54
|
-
a.allow?(subject, 'read')
|
55
|
-
end
|
56
|
-
|
57
|
-
can :update, Activity do |a|
|
58
|
-
a.allow?(subject, 'update')
|
59
|
-
end
|
60
|
-
|
61
|
-
can :destroy, Activity do |a|
|
62
|
-
a.allow?(subject, 'destroy')
|
63
|
-
end
|
64
|
-
|
65
|
-
# Users
|
66
|
-
can :read, User
|
67
|
-
|
68
|
-
can :update, User do |u|
|
69
|
-
u.represented_by?(subject)
|
70
|
-
end
|
71
|
-
|
72
|
-
# Groups
|
73
|
-
can :read, Group
|
74
|
-
|
75
|
-
can :create, Group do |g|
|
76
|
-
subject.present? &&
|
77
|
-
g._contact.sender_id == Actor.normalize_id(subject)
|
78
|
-
end
|
79
|
-
|
80
|
-
can :update, Group do |g|
|
81
|
-
g.represented_by?(subject)
|
82
|
-
end
|
83
|
-
|
84
|
-
can :destroy, Group do |g|
|
85
|
-
g.represented_by?(subject)
|
86
|
-
end
|
87
|
-
|
88
|
-
can :read, Profile
|
89
|
-
|
90
|
-
# Profile
|
91
|
-
can :update, Profile do |p|
|
92
|
-
p.subject.represented_by?(subject)
|
93
|
-
end
|
94
|
-
|
95
|
-
# Privacy
|
96
|
-
can [:create, :read, :update, :destroy], Relation::Custom, :actor_id => subject.try(:actor_id)
|
97
|
-
end
|
5
|
+
include SocialStream::Ability::Base
|
98
6
|
end
|
99
7
|
end
|
@@ -31,6 +31,12 @@ module SocialStream
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
initializer "social_stream-base.views.settings" do
|
35
|
+
SocialStream::Views::Settings.module_eval do
|
36
|
+
include SocialStream::Views::Settings::Base
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
34
40
|
initializer "social_stream-base.avatars_for_rails" do
|
35
41
|
AvatarsForRails.setup do |config|
|
36
42
|
config.avatarable_model = :actor
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module SocialStream
|
2
|
+
module Views
|
3
|
+
module Settings
|
4
|
+
module Base
|
5
|
+
def settings_items
|
6
|
+
SocialStream::Views::Settings::ItemList.new.tap do |items|
|
7
|
+
if current_subject == current_user
|
8
|
+
items << {
|
9
|
+
:key => 'user.edit',
|
10
|
+
:html => render(:partial => "devise/registrations/edit_user",
|
11
|
+
:locals => {
|
12
|
+
:resource => current_user,
|
13
|
+
:resource_name => :user
|
14
|
+
})
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
items << {
|
19
|
+
:key => 'notifications',
|
20
|
+
:html => render(:partial => "notifications")
|
21
|
+
}
|
22
|
+
|
23
|
+
if current_subject.respond_to? :authentication_token
|
24
|
+
items << {
|
25
|
+
:key => 'api_key',
|
26
|
+
:html => render(:partial => "api_key")
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
items << {
|
31
|
+
:key => 'destroy',
|
32
|
+
:html =>
|
33
|
+
current_subject == current_user ?
|
34
|
+
render(:partial => "devise/registrations/delete_account",
|
35
|
+
:locals => { :resource => current_user, :resource_name => :user }) :
|
36
|
+
render(:partial => 'destroy')
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/social_stream-base.rb
CHANGED
@@ -61,6 +61,13 @@ module SocialStream
|
|
61
61
|
autoload :Object, 'social_stream/models/object'
|
62
62
|
end
|
63
63
|
|
64
|
+
module Views
|
65
|
+
module Settings
|
66
|
+
autoload :Base, 'social_stream/views/settings/base'
|
67
|
+
autoload :ItemList, 'social_stream/views/settings/item_list'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
64
71
|
module TestHelpers
|
65
72
|
autoload :Controllers, 'social_stream/test_helpers/controllers'
|
66
73
|
end
|
@@ -129,8 +136,4 @@ module SocialStream
|
|
129
136
|
end
|
130
137
|
end
|
131
138
|
|
132
|
-
|
133
|
-
autoload :NotificationDecoder, 'mailboxer/notification_decoder'
|
134
|
-
end
|
135
|
-
|
136
|
-
require 'social_stream/base'
|
139
|
+
require 'social_stream/base/engine'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_stream-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 115
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 36
|
10
|
+
version: 0.9.36
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- GING - DIT - UPM
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-11-
|
19
|
+
date: 2011-11-21 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -737,6 +737,7 @@ files:
|
|
737
737
|
- app/helpers/permissions_helper.rb
|
738
738
|
- app/helpers/profiles_helper.rb
|
739
739
|
- app/helpers/search_helper.rb
|
740
|
+
- app/helpers/settings_helper.rb
|
740
741
|
- app/helpers/subjects_helper.rb
|
741
742
|
- app/helpers/toolbar_helper.rb
|
742
743
|
- app/helpers/users_helper.rb
|
@@ -967,7 +968,8 @@ files:
|
|
967
968
|
- lib/paperclip/social_stream.rb
|
968
969
|
- lib/social_stream-base.rb
|
969
970
|
- lib/social_stream/ability.rb
|
970
|
-
- lib/social_stream/base.rb
|
971
|
+
- lib/social_stream/ability/base.rb
|
972
|
+
- lib/social_stream/base/engine.rb
|
971
973
|
- lib/social_stream/base/version.rb
|
972
974
|
- lib/social_stream/controllers/cancan_devise_integration.rb
|
973
975
|
- lib/social_stream/controllers/helpers.rb
|
@@ -981,6 +983,8 @@ files:
|
|
981
983
|
- lib/social_stream/test_helpers.rb
|
982
984
|
- lib/social_stream/test_helpers/controllers.rb
|
983
985
|
- lib/social_stream/toolbar_config/base.rb
|
986
|
+
- lib/social_stream/views/settings/base.rb
|
987
|
+
- lib/social_stream/views/settings/item_list.rb
|
984
988
|
- lib/tasks/db/populate.rake
|
985
989
|
- lib/tasks/workers.rake
|
986
990
|
- social_stream-base.gemspec
|