social_stream 0.4.3 → 0.4.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/app/controllers/api_controller.rb +1 -1
- data/app/controllers/contacts_controller.rb +1 -1
- data/app/controllers/conversations_controller.rb +5 -5
- data/app/controllers/groups_controller.rb +1 -0
- data/app/controllers/likes_controller.rb +17 -5
- data/app/controllers/messages_controller.rb +3 -1
- data/app/controllers/profiles_controller.rb +4 -0
- data/app/controllers/representations_controller.rb +12 -1
- data/app/controllers/tags_controller.rb +15 -0
- data/app/controllers/users_controller.rb +3 -0
- data/app/helpers/activities_helper.rb +13 -6
- data/app/models/activity.rb +53 -52
- data/app/models/activity_object.rb +2 -0
- data/app/models/actor.rb +85 -19
- data/app/models/avatar.rb +2 -1
- data/app/models/like.rb +28 -13
- data/app/models/permission.rb +7 -7
- data/app/models/profile.rb +1 -1
- data/app/models/relation/custom.rb +111 -0
- data/app/models/relation/public.rb +42 -0
- data/app/models/relation.rb +1 -89
- data/app/models/sphere.rb +7 -0
- data/app/models/tie.rb +65 -52
- data/app/models/tie_activity.rb +38 -0
- data/app/views/activities/_new.html.erb +4 -4
- data/app/views/activities/_options.html.erb +2 -2
- data/app/views/actors/_actor.html.erb +0 -0
- data/app/views/avatars/index.html.erb +5 -2
- data/app/views/comments/_new.html.erb +2 -2
- data/app/views/contacts/index.html.erb +5 -1
- data/app/views/conversations/edit.html.erb +4 -0
- data/app/views/conversations/index.html.erb +5 -1
- data/app/views/conversations/show.html.erb +4 -0
- data/app/views/frontpage/index.html.erb +4 -0
- data/app/views/groups/_sidebar_index.html.erb +7 -42
- data/app/views/groups/index.html.erb +3 -0
- data/app/views/groups/new.html.erb +3 -0
- data/app/views/groups/show.html.erb +7 -0
- data/app/views/layouts/_account.html.erb +16 -0
- data/app/views/layouts/_footer.html.erb +1 -1
- data/app/views/layouts/_header.erb +7 -22
- data/app/views/layouts/_representation.html.erb +25 -12
- data/app/views/layouts/application.html.erb +6 -3
- data/app/views/layouts/frontpage.html.erb +1 -1
- data/app/views/likes/create.js.erb +1 -1
- data/app/views/likes/destroy.js.erb +1 -1
- data/app/views/messages/new.html.erb +7 -5
- data/app/views/profiles/_profile.html.erb +20 -0
- data/app/views/profiles/edit.html.erb +42 -0
- data/app/views/profiles/show.html.erb +4 -0
- data/app/views/profiles/update.js.erb +5 -0
- data/app/views/subjects/_toolbar_profile_menu_tie_options.html.erb +3 -1
- data/app/views/ties/_new.html.erb +1 -1
- data/app/views/users/index.html.erb +4 -0
- data/app/views/users/show.html.erb +5 -0
- data/config/locales/en.yml +54 -1
- data/config/routes.rb +3 -1
- data/lib/generators/social_stream/install_generator.rb +2 -1
- data/lib/generators/social_stream/templates/migration.rb +23 -27
- data/lib/generators/social_stream/templates/public/images/btn/error.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/info.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/like.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/nolike.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/success.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/warning.png +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/ajax.paginate.js +12 -19
- data/lib/generators/social_stream/templates/public/javascripts/jquery.validate.js +1 -1
- data/lib/generators/social_stream/templates/public/javascripts/main.js +20 -10
- data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +21 -4
- data/lib/generators/social_stream/templates/public/stylesheets/default/header.css +8 -3
- data/lib/generators/social_stream/templates/relations.yml +7 -13
- data/lib/social_stream/ability.rb +39 -20
- data/lib/social_stream/controllers/helpers.rb +6 -0
- data/lib/social_stream/models/object.rb +8 -4
- data/lib/social_stream/models/subject.rb +6 -0
- data/lib/social_stream/rails.rb +6 -3
- data/lib/social_stream/version.rb +1 -1
- data/lib/tasks/db/populate.rake +11 -1
- data/social_stream.gemspec +7 -8
- data/spec/controllers/comments_controller_spec.rb +6 -2
- data/spec/controllers/posts_controller_spec.rb +93 -5
- data/spec/controllers/profiles_controller_spec.rb +58 -1
- data/spec/controllers/representations_controller_spec.rb +51 -0
- data/spec/controllers/users_controller_spec.rb +28 -0
- data/spec/dummy/config/relations.yml +7 -13
- data/spec/dummy/db/schema.rb +2 -13
- data/spec/factories/tie.rb +1 -1
- data/spec/models/activity_spec.rb +28 -67
- data/spec/models/profile_spec.rb +38 -0
- data/spec/models/tie_activity_spec.rb +88 -31
- data/spec/models/tie_spec.rb +20 -14
- data/spec/support/db.rb +8 -10
- data/spec/support/migrations.rb +24 -0
- metadata +74 -59
@@ -85,8 +85,8 @@ class CreateSocialStream < ActiveRecord::Migration
|
|
85
85
|
|
86
86
|
create_table "permissions", :force => true do |t|
|
87
87
|
t.string "action"
|
88
|
-
t.string "object"
|
89
|
-
t.string "function"
|
88
|
+
t.string "object", :default => nil
|
89
|
+
t.string "function", :default => nil
|
90
90
|
t.datetime "created_at"
|
91
91
|
t.datetime "updated_at"
|
92
92
|
end
|
@@ -137,31 +137,27 @@ class CreateSocialStream < ActiveRecord::Migration
|
|
137
137
|
add_index "relation_permissions", "permission_id"
|
138
138
|
|
139
139
|
create_table "relations", :force => true do |t|
|
140
|
-
t.string "
|
140
|
+
t.string "type"
|
141
|
+
t.string "name"
|
141
142
|
t.datetime "created_at"
|
142
143
|
t.datetime "updated_at"
|
143
144
|
t.string "sender_type"
|
144
145
|
t.string "receiver_type"
|
145
|
-
t.
|
146
|
-
t.integer "
|
147
|
-
t.integer "rgt"
|
146
|
+
t.string "ancestry"
|
147
|
+
t.integer "sphere_id"
|
148
148
|
end
|
149
149
|
|
150
|
-
add_index "relations", "
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
add_index "relations", "ancestry"
|
151
|
+
add_index "relations", "sphere_id"
|
152
|
+
|
153
|
+
create_table "spheres", :force => true do |t|
|
154
|
+
t.string "name"
|
155
|
+
t.integer "actor_id"
|
154
156
|
t.datetime "created_at"
|
155
157
|
t.datetime "updated_at"
|
156
158
|
end
|
157
|
-
|
158
|
-
|
159
|
-
t.integer "tag_id"
|
160
|
-
t.integer "activity_object_id"
|
161
|
-
end
|
162
|
-
|
163
|
-
add_index "tags_activity_objects", "activity_object_id"
|
164
|
-
add_index "tags_activity_objects", "tag_id"
|
159
|
+
|
160
|
+
add_index "spheres", "actor_id"
|
165
161
|
|
166
162
|
create_table "tie_activities", :force => true do |t|
|
167
163
|
t.integer "tie_id"
|
@@ -229,9 +225,10 @@ class CreateSocialStream < ActiveRecord::Migration
|
|
229
225
|
add_foreign_key "relation_permissions", "relations", :name => "relation_permissions_on_relation_id"
|
230
226
|
add_foreign_key "relation_permissions", "permissions", :name => "relation_permissions_on_permission_id"
|
231
227
|
|
232
|
-
add_foreign_key "
|
233
|
-
|
234
|
-
|
228
|
+
add_foreign_key "relations", "spheres", :name => "relations_on_sphere_id"
|
229
|
+
|
230
|
+
add_foreign_key "spheres", "actors", :name => "spheres_on_actor_id"
|
231
|
+
|
235
232
|
add_foreign_key "tie_activities", "ties", :name => "tie_activities_on_tie_id"
|
236
233
|
add_foreign_key "tie_activities", "activities", :name => "tie_activities_on_activity_id"
|
237
234
|
|
@@ -265,9 +262,10 @@ class CreateSocialStream < ActiveRecord::Migration
|
|
265
262
|
|
266
263
|
remove_foreign_key "relation_permissions", :name => "relation_permissions_on_relation_id"
|
267
264
|
remove_foreign_key "relation_permissions", :name => "relation_permissions_on_permission_id"
|
268
|
-
|
269
|
-
remove_foreign_key "
|
270
|
-
|
265
|
+
|
266
|
+
remove_foreign_key "relations", :name => "relations_on_sphere_id"
|
267
|
+
|
268
|
+
remove_foreign_key "spheres", :name => "spheres_on_actor_id"
|
271
269
|
|
272
270
|
remove_foreign_key "tie_activities", :name => "tie_activities_on_tie_id"
|
273
271
|
remove_foreign_key "tie_activities", :name => "tie_activities_on_activity_id"
|
@@ -292,10 +290,8 @@ class CreateSocialStream < ActiveRecord::Migration
|
|
292
290
|
drop_table :profiles
|
293
291
|
drop_table :relation_permissions
|
294
292
|
drop_table :relations
|
295
|
-
drop_table :
|
296
|
-
drop_table :tags_activity_objects
|
293
|
+
drop_table :spheres
|
297
294
|
drop_table :ties
|
298
295
|
drop_table :users
|
299
|
-
|
300
296
|
end
|
301
297
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -20,34 +20,27 @@ $(function(){
|
|
20
20
|
|
21
21
|
$('.pagination a').live('click',function(){
|
22
22
|
$('#list_users_ajax').html("<div id='ajax_loader_icon'><img src='../images/loader.gif'></div>");
|
23
|
-
$.setFragment({ "page" : $.queryString(this.href).page
|
23
|
+
$.setFragment({ "page" : $.queryString(this.href).page});
|
24
|
+
$.setFragment({ "letter" : $.queryString(this.href).letter});
|
25
|
+
$.setFragment({ "search" : $.queryString(this.href).search});
|
26
|
+
$.setFragment({ "tag" : $.queryString(this.href).tag});
|
27
|
+
|
24
28
|
$.getScript(this.href);
|
25
29
|
return false;
|
26
30
|
});
|
27
31
|
|
28
32
|
$('.user_letter_link').live('click',function(){
|
29
33
|
$('#list_users_ajax').html("<div id='ajax_loader_icon'><img src='../images/loader.gif'></div>");
|
30
|
-
$.setFragment({ "
|
31
|
-
$.setFragment({ "letter" : $.queryString(this.href).letter });
|
34
|
+
$.setFragment({ "letter" : $.queryString(this.href).letter});
|
32
35
|
$.getScript(this.href);
|
33
36
|
return false;
|
34
37
|
});
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
$.
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
$.getScript($.queryString(document.location.href, { "page" : $.fragment().page,
|
43
|
-
"letter": $.fragment().letter}));
|
44
|
-
});
|
45
|
-
|
46
|
-
if ($.fragment().page) {
|
47
|
-
$(document).trigger("fragmentChange.page");
|
48
|
-
}
|
49
|
-
if ($.fragment().letter) {
|
50
|
-
$(document).trigger("fragmentChange.letter");
|
51
|
-
}
|
39
|
+
$('#wordcloud a').live('click', function(){
|
40
|
+
$('#list_users_ajax').html("<div id='ajax_loader_icon'><img src='../images/loader.gif'></div>");
|
41
|
+
$.setFragment({ "tag" : $.queryString(this.href).tag});
|
42
|
+
$.getScript(this.href);
|
43
|
+
return false;
|
44
|
+
});
|
52
45
|
|
53
46
|
});
|
@@ -1,18 +1,28 @@
|
|
1
1
|
// initialise plugins
|
2
2
|
jQuery(function(){
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
|
3
|
+
|
4
|
+
|
5
|
+
jQuery('ul.sf-menu').superfish({
|
6
|
+
delay: 2000, // one second delay on mouseout
|
7
|
+
animation: {
|
8
|
+
height: 'show'
|
9
|
+
}, // fade-in and slide-down animation
|
10
|
+
speed: 'fast', // faster animation speed
|
11
|
+
autoArrows: false,
|
12
|
+
dropShadows: false // disable drop shadows
|
13
|
+
});
|
14
|
+
|
15
|
+
|
11
16
|
});
|
12
17
|
|
13
18
|
|
14
19
|
|
15
|
-
$(document).ready(function()
|
16
|
-
$('#tabright> ul').tabs({
|
20
|
+
$(document).ready(function(){
|
21
|
+
$('#tabright> ul').tabs({
|
22
|
+
fx: {
|
23
|
+
height: 'toggle',
|
24
|
+
opacity: 'toggle'
|
25
|
+
}
|
26
|
+
});
|
17
27
|
});
|
18
28
|
|
@@ -22,10 +22,27 @@ margin-top: auto; margin-bottom:auto;}
|
|
22
22
|
|
23
23
|
|
24
24
|
/*********** Notices SECTION *********************/
|
25
|
-
.
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
.notice, .success, .alert, .error, .validation {
|
26
|
+
border: 1px solid;
|
27
|
+
margin: 10px 0px;
|
28
|
+
padding:15px 10px 15px 50px;
|
29
|
+
background-repeat: no-repeat;
|
30
|
+
background-position: 10px center;
|
31
|
+
width: 440px;
|
32
|
+
margin-left: auto;
|
33
|
+
margin-right: auto;
|
34
|
+
font-weight: bold;
|
35
|
+
}
|
36
|
+
.notice ul, .success ul, .alert ul, .error ul, .validation ul{
|
37
|
+
margin-left:50px;
|
38
|
+
|
39
|
+
}
|
40
|
+
label.validation_error{color: #D8000C;background-color: #FFBABA;border: 1px solid;
|
41
|
+
display: block;padding-left:5px;padding-right:5px;width:90%;}
|
42
|
+
.notice {color: #00529B;background-color: #BDE5F8;background-image: url('/images/btn/info.png');}
|
43
|
+
.success {color: #4F8A10;background-color: #DFF2BF;background-image:url('/images/btn/success.png');}
|
44
|
+
.alert {color: #9F6000;background-color: #FEEFB3;background-image: url('/images/btn/warning.png');}
|
45
|
+
.error {color: #D8000C;background-color: #FFBABA;background-image: url('/images/btn/error.png');}
|
29
46
|
|
30
47
|
/************Forms SECTION **************/
|
31
48
|
input.other_blue{ background:#497FC1; border:0px; cursor:pointer; font-size:1.0em; line-height:135%;
|
@@ -42,9 +42,15 @@ li.btn_menu_browse{background: transparent url("/images/btn/btn_browse.png") no-
|
|
42
42
|
#menu_account ul{ list-style: none; margin: 0px; float:left;}
|
43
43
|
#menu_account ul li{ line-height:20px; padding:5px 0px 5px 20px; vertical-align:top;}
|
44
44
|
|
45
|
-
#
|
45
|
+
#menu_pipe{ vertical-align: top; height:23px; }
|
46
|
+
#menu_pipe span { float:right; padding-right: 5px; vertical-align: top; padding-top: 5px;}
|
47
|
+
#menu_pipe ul{ list-style: none; margin: 0px; float:left;}
|
48
|
+
#menu_pipe ul li{ line-height:20px; padding:5px 0px 5px 0px; vertical-align:top;}
|
46
49
|
|
47
50
|
|
51
|
+
#account, #representation_li,#current_user_info, #representations_menu {display:inline-block;vertical-align: top; height:22px; color:#FFF;}
|
52
|
+
#representation_li{margin-left:10px;display:none;}
|
53
|
+
|
48
54
|
li.btn_menu_exit{background: transparent url("/images/btn/btn_exit.png") no-repeat left center;}
|
49
55
|
li.btn_menu_representation{}
|
50
56
|
#menu_home ul li.pipe,#menu_account ul li.pipe{padding:0px 3px 0px 3px; margin:0px;}
|
@@ -119,9 +125,8 @@ ul.sf-menu li li li.sfHover ul {
|
|
119
125
|
/*margin-bottom: 1em; */
|
120
126
|
}
|
121
127
|
.sf-menu a {
|
122
|
-
padding: .
|
128
|
+
padding: .40em 1em .70em 2em;
|
123
129
|
text-decoration:none;
|
124
|
-
padding-left:2em;
|
125
130
|
}
|
126
131
|
.sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/
|
127
132
|
color: #fff;
|
@@ -12,20 +12,17 @@ user:
|
|
12
12
|
name: friend
|
13
13
|
permissions:
|
14
14
|
- [ follow ] # follow the activities of the friend
|
15
|
-
- [ create, activity
|
15
|
+
- [ create, activity ] # let the friend create activities
|
16
16
|
- [ read, activity, star_ties ] # friend can read activities from the other friends
|
17
|
-
- [ update, activity
|
18
|
-
- [ destroy, activity
|
17
|
+
- [ update, activity ] # update her activities
|
18
|
+
- [ destroy, activity ] # destroy her activities
|
19
|
+
sphere: personal
|
19
20
|
acquaintance:
|
20
21
|
name: acquaintance
|
21
22
|
parent: friend # friend relation is stronger than acquaintance
|
22
23
|
permissions:
|
23
24
|
- [ read, activity, star_ties ]
|
24
|
-
|
25
|
-
name: public
|
26
|
-
parent: acquaintance # acquaintance is stronger than public
|
27
|
-
permissions:
|
28
|
-
- [ read, activity, star_ties ]
|
25
|
+
sphere: personal
|
29
26
|
|
30
27
|
group:
|
31
28
|
member:
|
@@ -37,13 +34,10 @@ group:
|
|
37
34
|
- [ update, activity, weak_star_ties ] # update and destroy activities to members,
|
38
35
|
- [ destroy, activity, weak_star_ties ] # acquaintance and public
|
39
36
|
- [ read, tie, weak_star_ties ]
|
37
|
+
sphere: organization
|
40
38
|
partner:
|
41
39
|
name: partner
|
42
40
|
parent: member # member is stronger than partner
|
43
41
|
permissions:
|
44
42
|
- [ read, activity, star_ties ]
|
45
|
-
|
46
|
-
name: public
|
47
|
-
parent: partner # partner is stronger than public
|
48
|
-
permissions:
|
49
|
-
- [ read, activity, star_ties ]
|
43
|
+
sphere: organization
|
@@ -2,62 +2,81 @@ module SocialStream
|
|
2
2
|
class Ability
|
3
3
|
include CanCan::Ability
|
4
4
|
|
5
|
-
def initialize(
|
5
|
+
def initialize(subject)
|
6
|
+
|
6
7
|
# Activity Objects
|
7
8
|
(SocialStream.objects - [ :actor ]).map{ |obj|
|
8
9
|
obj.to_s.classify.constantize
|
9
10
|
}.each do |klass|
|
10
|
-
can :create, klass do |k|
|
11
|
-
k._activity_tie.
|
11
|
+
can :create, klass do |k| # can :create, Post do |post|
|
12
|
+
k._activity_tie.sender_id == subject.actor_id &&
|
13
|
+
k._activity_tie.receiver.allow?(subject, 'create', 'activity')
|
12
14
|
end
|
13
15
|
|
14
|
-
can :read, klass do |k|
|
15
|
-
k.
|
16
|
+
can :read, klass do |k| # can :read, Post do |post|
|
17
|
+
k.post_activity.tie.allow?(subject, 'read', 'activity')
|
16
18
|
end
|
17
19
|
|
18
|
-
can :update, klass do |k|
|
19
|
-
k.
|
20
|
+
can :update, klass do |k| # can :update, Post do |post|
|
21
|
+
k.post_activity.tie.allow?(subject, 'update', 'activity')
|
20
22
|
end
|
21
23
|
|
22
|
-
can :destroy, klass do |k|
|
23
|
-
k.
|
24
|
+
can :destroy, klass do |k| # can :destroy, Post do |post|
|
25
|
+
k.post_activity.tie.sender_id == Actor.normalize_id(subject) ||
|
26
|
+
k.post_activity.tie.allow?(subject, 'destroy', 'activity')
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
30
|
# Activities
|
28
31
|
can :create, Activity do |a|
|
29
|
-
a.tie.
|
32
|
+
a.tie.allow?(subject, 'create', 'activity')
|
30
33
|
end
|
31
34
|
|
32
35
|
can :read, Activity do |a|
|
33
|
-
a.tie.
|
36
|
+
a.tie.allow?(subject, 'read', 'activity')
|
34
37
|
end
|
35
38
|
|
36
39
|
can :update, Activity do |a|
|
37
|
-
a.tie.
|
40
|
+
a.tie.allow?(subject, 'update', 'activity')
|
38
41
|
end
|
39
42
|
|
40
43
|
can :destroy, Activity do |a|
|
41
|
-
a.tie.
|
44
|
+
a.tie.allow?(subject, 'destroy', 'activity')
|
45
|
+
end
|
46
|
+
|
47
|
+
# Users
|
48
|
+
can :read, User
|
49
|
+
|
50
|
+
can :update, User do |u|
|
51
|
+
u.represented_by?(subject)
|
42
52
|
end
|
43
53
|
|
44
54
|
# Groups
|
45
55
|
can :read, Group
|
46
56
|
|
47
57
|
can :create, Group do |g|
|
48
|
-
|
49
|
-
|
50
|
-
Actor.find_by_slug!(g._founder).sent_ties.received_by(user).with_permissions('represent', nil).any? )
|
58
|
+
subject.present? &&
|
59
|
+
g._founder == subject.slug
|
51
60
|
end
|
52
61
|
|
53
62
|
can :update, Group do |g|
|
54
|
-
|
55
|
-
g.sent_ties.received_by(user).with_permissions('represent', nil).any?
|
63
|
+
g.represented_by?(subject)
|
56
64
|
end
|
57
65
|
|
58
66
|
can :destroy, Group do |g|
|
59
|
-
|
60
|
-
|
67
|
+
g.represented_by?(subject)
|
68
|
+
end
|
69
|
+
|
70
|
+
can :read, Profile
|
71
|
+
|
72
|
+
# Profile
|
73
|
+
can :update, Profile do |p|
|
74
|
+
p.subject.represented_by?(subject)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Representation
|
78
|
+
can :create, Representation do |r|
|
79
|
+
r.subject.represented_by?(subject)
|
61
80
|
end
|
62
81
|
end
|
63
82
|
end
|
@@ -44,6 +44,12 @@ module SocialStream
|
|
44
44
|
@current_subject = instance
|
45
45
|
end
|
46
46
|
|
47
|
+
# Override Cancan#current_ability method to use {#current_subject}
|
48
|
+
def current_ability
|
49
|
+
@current_ability ||=
|
50
|
+
Ability.new(current_subject)
|
51
|
+
end
|
52
|
+
|
47
53
|
private
|
48
54
|
|
49
55
|
# Get represented subject from session
|
@@ -10,7 +10,7 @@ module SocialStream
|
|
10
10
|
attr_accessor :_activity_tie_id
|
11
11
|
attr_accessor :_activity_parent_id
|
12
12
|
|
13
|
-
belongs_to :activity_object, :dependent => :destroy
|
13
|
+
belongs_to :activity_object, :dependent => :destroy, :autosave => true
|
14
14
|
has_many :activity_object_activities, :through => :activity_object
|
15
15
|
|
16
16
|
delegate :post_activity, :to => :activity_object
|
@@ -61,9 +61,13 @@ module SocialStream
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def create_activity(verb)
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
a = Activity.new :verb => verb,
|
65
|
+
:_tie => _activity_tie,
|
66
|
+
:parent_id => _activity_parent_id
|
67
|
+
|
68
|
+
a.activity_objects << activity_object
|
69
|
+
|
70
|
+
a.save!
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -43,6 +43,12 @@ module SocialStream
|
|
43
43
|
scope :search, lambda{ |param|
|
44
44
|
joins(:actor).merge(Actor.search(param))
|
45
45
|
}
|
46
|
+
|
47
|
+
scope :tagged_with, lambda { |param|
|
48
|
+
if param.present?
|
49
|
+
joins(:actor => :activity_object).merge(ActivityObject.tagged_with(param))
|
50
|
+
end
|
51
|
+
}
|
46
52
|
|
47
53
|
scope :distinct_initials, joins(:actor).merge(Actor.distinct_initials)
|
48
54
|
|
data/lib/social_stream/rails.rb
CHANGED
@@ -4,9 +4,7 @@ require 'foreigner'
|
|
4
4
|
require 'jquery-rails'
|
5
5
|
# Permalinks:
|
6
6
|
require 'stringex'
|
7
|
-
# Hierarchical relationships in Relation:
|
8
|
-
require 'nested_set'
|
9
|
-
# Hierarchical relationships in Activity:
|
7
|
+
# Hierarchical relationships in Activity and Relation:
|
10
8
|
require 'ancestry'
|
11
9
|
# Messages
|
12
10
|
require 'mailboxer'
|
@@ -27,11 +25,14 @@ require 'will_paginate'
|
|
27
25
|
require 'omniauth/oauth'
|
28
26
|
# CSS themes
|
29
27
|
require 'rails_css_themes'
|
28
|
+
#Tags
|
29
|
+
require 'acts-as-taggable-on'
|
30
30
|
|
31
31
|
module SocialStream
|
32
32
|
class Engine < ::Rails::Engine #:nodoc:
|
33
33
|
config.app_generators.authentication :devise
|
34
34
|
config.app_generators.messages :mailboxer
|
35
|
+
config.app_generators.taggings :acts_as_taggable_on
|
35
36
|
|
36
37
|
config.to_prepare do
|
37
38
|
%w( actor activity_object ).each do |supertype|
|
@@ -43,6 +44,8 @@ module SocialStream
|
|
43
44
|
ApplicationController.helper SubjectsHelper
|
44
45
|
ApplicationController.helper TiesHelper
|
45
46
|
ApplicationController.helper LocationHelper
|
47
|
+
|
48
|
+
ActsAsTaggableOn::TagsHelper
|
46
49
|
end
|
47
50
|
|
48
51
|
initializer "social_stream.inflections" do
|
data/lib/tasks/db/populate.rake
CHANGED
@@ -34,6 +34,15 @@ namespace :db do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def set_tags(klass)
|
38
|
+
klass.all.each do |el|
|
39
|
+
el.tag_list = Forgery::LoremIpsum.words(1,:random => true)+", "+
|
40
|
+
Forgery::LoremIpsum.words(1,:random => true)+", "+
|
41
|
+
Forgery::LoremIpsum.words(1,:random => true)
|
42
|
+
el.save!
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
37
46
|
puts 'User population'
|
38
47
|
users_start = Time.now
|
39
48
|
|
@@ -66,7 +75,7 @@ namespace :db do
|
|
66
75
|
|
67
76
|
# = Groups
|
68
77
|
available_actors = Actor.all
|
69
|
-
|
78
|
+
|
70
79
|
10.times do
|
71
80
|
founder = available_actors[rand(available_actors.size)]
|
72
81
|
|
@@ -76,6 +85,7 @@ namespace :db do
|
|
76
85
|
end
|
77
86
|
|
78
87
|
set_logos(Group)
|
88
|
+
set_tags(Group)
|
79
89
|
|
80
90
|
groups_end = Time.now
|
81
91
|
puts ' -> ' + (groups_end - groups_start).round(4).to_s + 's'
|
data/social_stream.gemspec
CHANGED
@@ -12,10 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
# Gem dependencies
|
14
14
|
#
|
15
|
-
# Activity hierarchies
|
16
|
-
s.add_runtime_dependency('
|
17
|
-
# Relation hierarchies
|
18
|
-
s.add_runtime_dependency('nested_set', '~> 1.5.3')
|
15
|
+
# Activity and Relation hierarchies
|
16
|
+
s.add_runtime_dependency('ancestry', '~> 1.2.3')
|
19
17
|
# SQL foreign keys
|
20
18
|
s.add_runtime_dependency('foreigner', '~> 0.9.1')
|
21
19
|
# Authentication
|
@@ -29,7 +27,7 @@ Gem::Specification.new do |s|
|
|
29
27
|
# jQuery
|
30
28
|
s.add_runtime_dependency('jquery-rails', '~> 0.2.5')
|
31
29
|
# Authorization
|
32
|
-
s.add_runtime_dependency('cancan', '~> 1.6.
|
30
|
+
s.add_runtime_dependency('cancan', '~> 1.6.4')
|
33
31
|
# Pagination
|
34
32
|
s.add_runtime_dependency('will_paginate', '~> 3.0.pre2')
|
35
33
|
# OAuth client
|
@@ -39,13 +37,14 @@ Gem::Specification.new do |s|
|
|
39
37
|
# Theme support
|
40
38
|
s.add_runtime_dependency('rails_css_themes','~> 1.0.0')
|
41
39
|
# Messages
|
42
|
-
s.add_runtime_dependency('mailboxer','~> 0.0.
|
40
|
+
s.add_runtime_dependency('mailboxer','~> 0.0.16')
|
43
41
|
# Avatar manipulation
|
44
42
|
s.add_runtime_dependency('rmagick','~> 2.13.1')
|
45
|
-
|
43
|
+
# Tagging
|
44
|
+
s.add_runtime_dependency('acts-as-taggable-on','~> 2.0.6')
|
46
45
|
|
47
46
|
# Development Gem dependencies
|
48
|
-
s.add_development_dependency('rails', '~> 3.0.
|
47
|
+
s.add_development_dependency('rails', '~> 3.0.7')
|
49
48
|
# Integration testing
|
50
49
|
s.add_development_dependency('capybara', '~> 0.3.9')
|
51
50
|
# Testing database
|
@@ -21,7 +21,9 @@ describe CommentsController do
|
|
21
21
|
|
22
22
|
describe "comment from friend" do
|
23
23
|
before do
|
24
|
-
|
24
|
+
f = Factory(:friend, :receiver => @user.actor).sender
|
25
|
+
|
26
|
+
model_assigned_to Factory(:friend, :sender => @user.actor, :receiver => f)
|
25
27
|
end
|
26
28
|
|
27
29
|
it_should_behave_like "Allow Creating"
|
@@ -29,7 +31,9 @@ describe CommentsController do
|
|
29
31
|
|
30
32
|
describe "post from acquaintance" do
|
31
33
|
before do
|
32
|
-
|
34
|
+
a = Factory(:acquaintance, :receiver => @user.actor).sender
|
35
|
+
|
36
|
+
model_assigned_to Factory(:friend, :sender => @user.actor, :receiver => a)
|
33
37
|
end
|
34
38
|
|
35
39
|
it_should_behave_like "Deny Creating"
|