social_stream 0.12.14 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/base/app/controllers/groups_controller.rb +3 -2
- data/base/app/controllers/posts_controller.rb +2 -10
- data/base/app/helpers/activities_helper.rb +2 -1
- data/base/app/models/activity_object.rb +28 -0
- data/base/app/models/actor.rb +10 -0
- data/base/app/models/group.rb +7 -3
- data/base/app/models/user.rb +7 -2
- data/base/app/views/activities/_new.html.erb +0 -1
- data/base/app/views/activity_objects/_activity_object.html.erb +3 -3
- data/base/app/views/comments/_new.html.erb +2 -3
- data/base/app/views/groups/_new.html.erb +0 -3
- data/base/app/views/notifications/activities/_like.text.erb +1 -1
- data/base/app/views/objects/_new_activity.html.erb +2 -2
- data/base/app/views/objects/_show.html.erb +1 -1
- data/base/db/migrate/20111124100618_object_actors.rb +50 -0
- data/base/lib/social_stream-base.rb +2 -1
- data/base/lib/social_stream/ability/base.rb +1 -1
- data/base/lib/social_stream/base/version.rb +1 -1
- data/base/lib/social_stream/controllers/objects.rb +33 -0
- data/base/lib/social_stream/models/object.rb +33 -28
- data/base/lib/social_stream/test_helpers/controllers.rb +3 -1
- data/base/lib/tasks/db/populate.rake +9 -2
- data/base/spec/controllers/comments_controller_spec.rb +9 -6
- data/base/spec/controllers/groups_controller_spec.rb +7 -5
- data/base/spec/controllers/posts_controller_spec.rb +45 -9
- data/base/spec/controllers/users_controller_spec.rb +3 -1
- data/base/spec/factories/activity.rb +3 -2
- data/base/spec/factories/comment.rb +3 -2
- data/base/spec/factories/group.rb +2 -1
- data/base/spec/factories/post.rb +5 -4
- data/base/spec/models/activity_authorization_spec.rb +5 -4
- data/base/spec/models/group_spec.rb +5 -2
- data/base/spec/models/post_spec.rb +6 -2
- data/documents/app/assets/stylesheets/show.css.scss +4 -0
- data/documents/app/controllers/documents_controller.rb +2 -10
- data/documents/app/views/audios/_audio_processed.html.erb +1 -1
- data/documents/app/views/audios/_audio_processing.html.erb +1 -1
- data/documents/app/views/common_documents/_document_info.html.erb +5 -0
- data/documents/app/views/documents/_document.html.erb +1 -1
- data/documents/app/views/pictures/_picture.html.erb +4 -4
- data/documents/app/views/videos/_video_processed.html.erb +1 -1
- data/documents/app/views/videos/_video_processing.html.erb +1 -1
- data/documents/lib/social_stream/documents/version.rb +1 -1
- data/documents/social_stream-documents.gemspec +1 -1
- data/documents/spec/factories/document.rb +7 -6
- data/documents/spec/factories/picture.rb +7 -6
- data/documents/spec/spec_helper.rb +6 -1
- data/events/db/migrate/20111102145626_add_more_fields_to_events.rb +0 -4
- data/events/db/migrate/20111104182420_add_details_to_events.rb +0 -26
- data/events/lib/social_stream/events/version.rb +1 -1
- data/events/social_stream-events.gemspec +1 -1
- data/lib/social_stream/version.rb +1 -1
- data/linkser/.gitignore +14 -0
- data/linkser/.rspec +1 -0
- data/linkser/Gemfile +5 -0
- data/linkser/MIT-LICENSE +20 -0
- data/linkser/README.rdoc +6 -0
- data/linkser/Rakefile +26 -0
- data/{documents/app/views/audios/_mediapreviews.html.erb → linkser/app/assets/javascripts/linkser.js.erb} +0 -0
- data/linkser/app/assets/javascripts/social_stream-linkser.js +1 -0
- data/linkser/app/assets/stylesheets/linkser.css.scss +1 -0
- data/linkser/app/assets/stylesheets/social_stream-linkser.css +3 -0
- data/linkser/config/locales/en.yml +3 -0
- data/linkser/config/locales/es.yml +3 -0
- data/linkser/config/routes.rb +3 -0
- data/linkser/lib/generators/social_stream/linkser/install_generator.rb +24 -0
- data/linkser/lib/social_stream-linkser.rb +9 -0
- data/linkser/lib/social_stream/linkser/engine.rb +7 -0
- data/linkser/lib/social_stream/linkser/version.rb +5 -0
- data/linkser/lib/social_stream/migrations/linkser.rb +9 -0
- data/linkser/social_stream-linkser.gemspec +26 -0
- data/linkser/spec/dummy/Rakefile +7 -0
- data/linkser/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/linkser/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/linkser/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/linkser/spec/dummy/config.ru +4 -0
- data/linkser/spec/dummy/config/application.rb +45 -0
- data/linkser/spec/dummy/config/boot.rb +10 -0
- data/linkser/spec/dummy/config/database.yml +22 -0
- data/linkser/spec/dummy/config/environment.rb +5 -0
- data/linkser/spec/dummy/config/environments/development.rb +25 -0
- data/linkser/spec/dummy/config/environments/production.rb +49 -0
- data/linkser/spec/dummy/config/environments/test.rb +37 -0
- data/linkser/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/linkser/spec/dummy/config/initializers/devise.rb +176 -0
- data/linkser/spec/dummy/config/initializers/inflections.rb +10 -0
- data/linkser/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/linkser/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/linkser/spec/dummy/config/initializers/session_store.rb +8 -0
- data/linkser/spec/dummy/config/locales/en.yml +5 -0
- data/linkser/spec/dummy/config/navigation.rb +0 -0
- data/linkser/spec/dummy/config/relations.yml +39 -0
- data/linkser/spec/dummy/config/routes.rb +60 -0
- data/linkser/spec/dummy/db/.gitkeep +0 -0
- data/linkser/spec/dummy/documents/documents/000/000/001/original.pdf +157 -0
- data/linkser/spec/dummy/documents/documents/000/000/002/original.pdf +157 -0
- data/linkser/spec/dummy/documents/documents/000/000/003/original.pdf +157 -0
- data/linkser/spec/dummy/documents/documents/000/000/004/original.pdf +157 -0
- data/linkser/spec/dummy/documents/documents/000/000/005/original.pdf +157 -0
- data/linkser/spec/dummy/documents/documents/000/000/006/original.pdf +157 -0
- data/linkser/spec/dummy/documents/documents/000/000/007/original.pdf +157 -0
- data/linkser/spec/dummy/documents/documents/000/000/008/original.pdf +157 -0
- data/linkser/spec/dummy/documents/documents/000/000/009/original.pdf +157 -0
- data/linkser/spec/dummy/documents/documents/000/000/010/original.pdf +157 -0
- data/linkser/spec/dummy/documents/pictures/000/000/011/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/011/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/011/thumb0.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/012/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/012/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/012/thumb0.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/013/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/013/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/013/thumb0.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/014/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/014/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/014/thumb0.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/015/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/015/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/015/thumb0.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/016/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/016/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/016/thumb0.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/017/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/017/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/017/thumb0.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/018/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/018/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/018/thumb0.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/019/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/019/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/019/thumb0.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/020/original.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/020/thumb.png +0 -0
- data/linkser/spec/dummy/documents/pictures/000/000/020/thumb0.png +0 -0
- data/linkser/spec/dummy/public/404.html +26 -0
- data/linkser/spec/dummy/public/422.html +26 -0
- data/linkser/spec/dummy/public/500.html +26 -0
- data/linkser/spec/dummy/public/favicon.ico +0 -0
- data/linkser/spec/dummy/public/javascripts/application.js +2 -0
- data/linkser/spec/dummy/public/javascripts/controls.js +965 -0
- data/linkser/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/linkser/spec/dummy/public/javascripts/effects.js +1123 -0
- data/linkser/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/linkser/spec/dummy/public/javascripts/rails.js +191 -0
- data/linkser/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/linkser/spec/dummy/script/rails +6 -0
- data/linkser/spec/integration/navigation_spec.rb +9 -0
- data/linkser/spec/socialstream_linkser_spec.rb +7 -0
- data/linkser/spec/spec_helper.rb +48 -0
- data/linkser/spec/support/cancan.rb +1 -0
- data/linkser/spec/support/db.rb +8 -0
- data/linkser/spec/support/devise.rb +4 -0
- data/linkser/spec/support/mock.rb +4 -0
- data/linkser/vendor/assets/javascripts/jquery.jplayer.js +78 -0
- data/linkser/vendor/assets/stylesheets/jplayer.blue.monday.css +448 -0
- data/linkser/vendor/assets/stylesheets/jplayer.blue.monday.jpg +0 -0
- data/linkser/vendor/assets/stylesheets/jplayer.blue.monday.video.play.hover.png +0 -0
- data/linkser/vendor/assets/stylesheets/jplayer.blue.monday.video.play.png +0 -0
- data/linkser/vendor/assets/stylesheets/jquery.lightbox.css +101 -0
- data/linkser/vendor/assets/stylesheets/pbar-ani.gif +0 -0
- data/presence/app/assets/images/status/offline.png +0 -0
- data/presence/app/assets/javascripts/chat_interface_manager.js.erb +65 -16
- data/presence/app/assets/javascripts/xmpp_client_management.js.erb +13 -3
- data/presence/app/controllers/xmpp_controller.rb +2 -5
- data/presence/app/views/chat/_contacts.html.erb +10 -9
- data/presence/app/views/chat/_settings.html.erb +4 -4
- data/presence/app/views/xmpp/active_users.html.erb +10 -10
- data/presence/config/locales/en.yml +6 -1
- data/presence/config/locales/es.yml +7 -1
- data/presence/config/routes.rb +1 -4
- data/presence/lib/social_stream/presence/version.rb +1 -1
- data/social_stream.gemspec +3 -3
- metadata +127 -23
- data/documents/app/views/audios/index.js.erb +0 -1
- data/documents/app/views/documents/index.js.erb +0 -1
- data/documents/app/views/pictures/_mediapreviews.html.erb +0 -8
- data/documents/app/views/pictures/index.js.erb +0 -1
- data/presence/app/views/xmpp/index.html +0 -18
- data/presence/app/views/xmpp/test.html.erb +0 -11
@@ -51,7 +51,8 @@ class GroupsController < InheritedResources::Base
|
|
51
51
|
private
|
52
52
|
|
53
53
|
def set_founder
|
54
|
-
params[:group]
|
55
|
-
params[:group][:
|
54
|
+
params[:group] ||= {}
|
55
|
+
params[:group][:author_id] ||= current_subject.try(:actor_id)
|
56
|
+
params[:group][:user_author_id] ||= current_user.try(:actor_id)
|
56
57
|
end
|
57
58
|
end
|
@@ -1,11 +1,3 @@
|
|
1
|
-
class PostsController <
|
2
|
-
|
3
|
-
|
4
|
-
respond_to :html, :xml, :js
|
5
|
-
|
6
|
-
def destroy
|
7
|
-
@post_activity = resource.post_activity
|
8
|
-
|
9
|
-
destroy!
|
10
|
-
end
|
1
|
+
class PostsController < ApplicationController
|
2
|
+
include SocialStream::Controllers::Objects
|
11
3
|
end
|
@@ -31,6 +31,7 @@ module ActivitiesHelper
|
|
31
31
|
def new_post(receiver)
|
32
32
|
return Post.new unless user_signed_in?
|
33
33
|
|
34
|
-
Post.new :
|
34
|
+
Post.new :author_id => Actor.normalize_id(current_subject),
|
35
|
+
:owner_id => Actor.normalize_id(receiver)
|
35
36
|
end
|
36
37
|
end
|
@@ -14,9 +14,22 @@ class ActivityObject < ActiveRecord::Base
|
|
14
14
|
|
15
15
|
acts_as_taggable
|
16
16
|
|
17
|
+
# Author can be any type of Actor: User, Group, etc.
|
18
|
+
belongs_to :author,
|
19
|
+
:class_name => "Actor"
|
20
|
+
# Owner is the wall's subject this object is posted to
|
21
|
+
belongs_to :owner,
|
22
|
+
:class_name => "Actor"
|
23
|
+
|
24
|
+
# UserAuthor is the real user behind the Author
|
25
|
+
belongs_to :user_author,
|
26
|
+
:class_name => "Actor"
|
27
|
+
|
17
28
|
has_many :activity_object_activities, :dependent => :destroy
|
18
29
|
has_many :activities, :through => :activity_object_activities
|
19
30
|
|
31
|
+
validates_presence_of :object_type
|
32
|
+
|
20
33
|
# The object of this activity object
|
21
34
|
def object
|
22
35
|
subtype_instance.is_a?(Actor) ?
|
@@ -24,6 +37,21 @@ class ActivityObject < ActiveRecord::Base
|
|
24
37
|
subtype_instance
|
25
38
|
end
|
26
39
|
|
40
|
+
# The {SocialStream::Models::Subject subject} author
|
41
|
+
def author_subject
|
42
|
+
author.subject
|
43
|
+
end
|
44
|
+
|
45
|
+
# The {SocialStream::Models::Subject subject} owner
|
46
|
+
def owner_subject
|
47
|
+
owner.subject
|
48
|
+
end
|
49
|
+
|
50
|
+
# The {SocialStream::Models::Subject subject} user actor
|
51
|
+
def user_author_subject
|
52
|
+
user_author.subject
|
53
|
+
end
|
54
|
+
|
27
55
|
# The activity in which this activity_object was created
|
28
56
|
def post_activity
|
29
57
|
activities.includes(:activity_verb).where('activity_verbs.name' => 'post').first
|
data/base/app/models/actor.rb
CHANGED
@@ -58,6 +58,16 @@ class Actor < ActiveRecord::Base
|
|
58
58
|
has_many :relations,
|
59
59
|
:dependent => :destroy
|
60
60
|
|
61
|
+
has_many :authored_objects,
|
62
|
+
:class_name => "ActivityObject",
|
63
|
+
:foreign_key => :author_id,
|
64
|
+
:dependent => :destroy
|
65
|
+
|
66
|
+
has_many :owned_objects,
|
67
|
+
:class_name => "ActivityObject",
|
68
|
+
:foreign_key => :owner_id,
|
69
|
+
:dependent => :destroy
|
70
|
+
|
61
71
|
scope :alphabetic, order('actors.name')
|
62
72
|
|
63
73
|
scope :letter, lambda { |param|
|
data/base/app/models/group.rb
CHANGED
@@ -33,13 +33,17 @@ class Group < ActiveRecord::Base
|
|
33
33
|
|
34
34
|
# Creates the ties from the founder to the group
|
35
35
|
def create_ties_from_founder
|
36
|
-
|
37
|
-
|
36
|
+
author.sent_contacts.create! :receiver_id => actor_id,
|
37
|
+
:relation_ids => _relation_ids
|
38
|
+
|
39
|
+
if represented_author?
|
40
|
+
# TODO: create tie with future representation relation
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
44
|
# Creates the ties from the group to the participants
|
41
45
|
def create_ties_to_participants
|
42
|
-
([
|
46
|
+
([ author_id, user_author_id ].uniq | Array.wrap(@_participants)).uniq.each do |a|
|
43
47
|
sent_contacts.create! :receiver_id => a,
|
44
48
|
:relation_ids => Array(relation_customs.sort.first.id)
|
45
49
|
end
|
data/base/app/models/user.rb
CHANGED
@@ -3,12 +3,17 @@ require 'devise/orm/active_record'
|
|
3
3
|
class User < ActiveRecord::Base
|
4
4
|
include SocialStream::Models::Subject
|
5
5
|
|
6
|
-
has_many :authentications, :dependent => :destroy
|
7
6
|
devise *SocialStream.devise_modules
|
8
7
|
|
8
|
+
has_many :authentications, :dependent => :destroy
|
9
|
+
|
10
|
+
has_many :user_authored_objects,
|
11
|
+
:class_name => "ActivityObject",
|
12
|
+
:foreign_key => :user_author_id
|
13
|
+
|
9
14
|
# Setup accessible (or protected) attributes for your model
|
10
15
|
attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :profile_attributes
|
11
|
-
|
16
|
+
|
12
17
|
validates_presence_of :email
|
13
18
|
|
14
19
|
validates_format_of :email, :with => Devise.email_regexp, :allow_blank => true
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<%
|
2
|
-
<%= render activity_object.object %>
|
3
|
-
<% else %>
|
1
|
+
<% if activity_object.object.is_a?(Actor) || activity_object.object.class.ancestors.include?(SocialStream::Models::Subject) %>
|
4
2
|
<div class="block">
|
5
3
|
<%= model_with_details activity_object.object %>
|
6
4
|
</div>
|
5
|
+
<% else %>
|
6
|
+
<%= render activity_object.object %>
|
7
7
|
<% end %>
|
@@ -9,9 +9,8 @@
|
|
9
9
|
<%= current_subject.name %>
|
10
10
|
</div>
|
11
11
|
<%= form_for Comment.new(:text => t('comment.input'),
|
12
|
-
|
13
|
-
|
14
|
-
:_activity_parent_id => activity.id
|
12
|
+
:owner_id => Actor.normalize_id(activity.receiver),
|
13
|
+
:_activity_parent_id => activity.id
|
15
14
|
),
|
16
15
|
:html => { :class => "new_comment", :id => "new_comment"+dom_id(activity) },
|
17
16
|
:remote => true do |f| %>
|
@@ -19,9 +19,6 @@
|
|
19
19
|
<div class="space_center"></div>
|
20
20
|
|
21
21
|
<%= form_for @group do |f| %>
|
22
|
-
<% f.object._contact_id ||= current_subject.ego_contact.id %>
|
23
|
-
<%= f.hidden_field :_contact_id %>
|
24
|
-
|
25
22
|
<% if @group.errors.any? %>
|
26
23
|
<div id="notice">
|
27
24
|
<h2><%= pluralize(@group.errors.count, "error") %> prohibited this group from being saved:</h2>
|
@@ -1,8 +1,8 @@
|
|
1
|
-
<% object.
|
1
|
+
<% object.owner_id = Actor.normalize_id(receiver) %>
|
2
2
|
<% remote = true if remote.nil? %>
|
3
3
|
|
4
4
|
<%= form_for object, :remote => remote do |f| %>
|
5
|
-
<%= f.hidden_field :
|
5
|
+
<%= f.hidden_field :owner_id %>
|
6
6
|
|
7
7
|
<%= render :partial => object.class.to_s.tableize+'/new_activity_fields' , :locals => {:f => f} %>
|
8
8
|
<% end %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class ObjectActors < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
change_table :activity_objects do |t|
|
4
|
+
t.integer :author_id
|
5
|
+
t.integer :owner_id
|
6
|
+
t.integer :user_author_id
|
7
|
+
end
|
8
|
+
|
9
|
+
add_index "activity_objects", "author_id"
|
10
|
+
add_index "activity_objects", "owner_id"
|
11
|
+
add_index "activity_objects", "user_author_id"
|
12
|
+
|
13
|
+
add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_author_id", :column => :author_id
|
14
|
+
add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_owner_id", :column => :owner_id
|
15
|
+
add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_user_author_id", :column => :user_author_id
|
16
|
+
|
17
|
+
ActivityObject.record_timestamps = false
|
18
|
+
|
19
|
+
ActivityObject.all.each do |a|
|
20
|
+
if a.object_type == "Actor"
|
21
|
+
next if a.object.is_a? User
|
22
|
+
|
23
|
+
author = user_author = a.object.sent_ties.order(:created_at).first.receiver
|
24
|
+
|
25
|
+
until user_author.subject_type == "User"
|
26
|
+
user_author = user_author.sent_ties.order(:created_at).first.receiver
|
27
|
+
end
|
28
|
+
|
29
|
+
a.author = author
|
30
|
+
a.user_author = user_author
|
31
|
+
else
|
32
|
+
a.author = a.post_activity.sender
|
33
|
+
a.owner = a.post_activity.receiver
|
34
|
+
a.user_author = (a.author.is_a?(User) ? a.author : a.author.sent_ties.order(:created_at).first.receiver)
|
35
|
+
end
|
36
|
+
|
37
|
+
a.save!
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def down
|
42
|
+
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_author_id"
|
43
|
+
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_owner_id"
|
44
|
+
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_user_author_id"
|
45
|
+
|
46
|
+
remove_column :activity_objects, :author_id
|
47
|
+
remove_column :activity_objects, :owner_id
|
48
|
+
remove_column :activity_objects, :user_author_id
|
49
|
+
end
|
50
|
+
end
|
@@ -51,8 +51,9 @@ module SocialStream
|
|
51
51
|
autoload :TestHelpers, 'social_stream/test_helpers'
|
52
52
|
|
53
53
|
module Controllers
|
54
|
-
autoload :Helpers, 'social_stream/controllers/helpers'
|
55
54
|
autoload :CancanDeviseIntegration, 'social_stream/controllers/cancan_devise_integration'
|
55
|
+
autoload :Helpers, 'social_stream/controllers/helpers'
|
56
|
+
autoload :Objects, 'social_stream/controllers/objects'
|
56
57
|
end
|
57
58
|
|
58
59
|
module Models
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module SocialStream
|
2
|
+
module Controllers
|
3
|
+
module Objects
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
inherit_resources
|
8
|
+
|
9
|
+
before_filter :set_author_ids, :only => [ :new, :create, :update ]
|
10
|
+
|
11
|
+
load_and_authorize_resource :except => :index
|
12
|
+
|
13
|
+
respond_to :html, :js
|
14
|
+
end
|
15
|
+
|
16
|
+
module InstanceMethods
|
17
|
+
|
18
|
+
def destroy
|
19
|
+
@post_activity = resource.post_activity
|
20
|
+
|
21
|
+
destroy!
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def set_author_ids
|
27
|
+
resource_params.first[:author_id] = current_subject.try(:actor_id)
|
28
|
+
resource_params.first[:user_author_id] = current_user.try(:actor_id)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -7,23 +7,20 @@ module SocialStream
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
attr_accessor :_contact_id
|
11
10
|
attr_writer :_relation_ids
|
12
11
|
attr_accessor :_activity_parent_id
|
13
12
|
|
14
|
-
belongs_to :activity_object,
|
15
|
-
|
13
|
+
belongs_to :activity_object,
|
14
|
+
:validate => true,
|
15
|
+
:autosave => true,
|
16
|
+
:dependent => :destroy
|
16
17
|
|
17
|
-
|
18
|
-
:like_count,
|
19
|
-
:tag_list, :tag_list=,
|
20
|
-
:tagged_with, :tag_counts,
|
21
|
-
:to => :activity_object!
|
18
|
+
has_many :activity_object_activities, :through => :activity_object
|
22
19
|
|
23
|
-
before_create :create_activity_object_with_type
|
20
|
+
# before_create :create_activity_object_with_type
|
24
21
|
|
25
22
|
unless self == Actor
|
26
|
-
validates_presence_of :
|
23
|
+
validates_presence_of :author_id, :owner_id, :user_author_id
|
27
24
|
|
28
25
|
after_create :create_post_activity
|
29
26
|
after_update :create_update_activity
|
@@ -35,6 +32,27 @@ module SocialStream
|
|
35
32
|
activity_object || build_activity_object(:object_type => self.class.to_s)
|
36
33
|
end
|
37
34
|
|
35
|
+
# Delegate missing methods to {ActivityObject}, if they exist there
|
36
|
+
def method_missing(method, *args, &block)
|
37
|
+
super
|
38
|
+
rescue NameError => object_error
|
39
|
+
# These methods must be raised to avoid loops (the :activity_object association calls here again)
|
40
|
+
exceptions = [ :_activity_object_id ]
|
41
|
+
raise object_error if exceptions.include?(method)
|
42
|
+
|
43
|
+
activity_object!.__send__ method, *args, &block
|
44
|
+
end
|
45
|
+
|
46
|
+
# {ActivityObject} handles some methods
|
47
|
+
def respond_to? *args
|
48
|
+
super || activity_object!.respond_to?(*args)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Was the author represented with this {SocialStream::Models::Object object} was created?
|
52
|
+
def represented_author?
|
53
|
+
author_id == user_author_id
|
54
|
+
end
|
55
|
+
|
38
56
|
# All the activities with this object
|
39
57
|
def activities
|
40
58
|
Activity.
|
@@ -42,13 +60,6 @@ module SocialStream
|
|
42
60
|
where("#{ self.class.quoted_table_name }.id" => self.id)
|
43
61
|
end
|
44
62
|
|
45
|
-
# The activity in which this object was posted
|
46
|
-
#
|
47
|
-
# FIXME: Currently it only supports direct objects
|
48
|
-
def post_activity
|
49
|
-
(activities.includes(:activity_verb) & ActivityVerb.verb_name('post')).first
|
50
|
-
end
|
51
|
-
|
52
63
|
# Build the post activity when this object is not saved
|
53
64
|
def build_post_activity
|
54
65
|
Activity.new :contact_id => _contact_id,
|
@@ -65,7 +76,11 @@ module SocialStream
|
|
65
76
|
end
|
66
77
|
|
67
78
|
def _contact
|
68
|
-
@_contact ||=
|
79
|
+
@_contact ||= author && owner && author.contact_to!(owner)
|
80
|
+
end
|
81
|
+
|
82
|
+
def _contact_id
|
83
|
+
_contact.try(:id)
|
69
84
|
end
|
70
85
|
|
71
86
|
def _relation_ids
|
@@ -90,16 +105,6 @@ module SocialStream
|
|
90
105
|
@_activity_parent ||= Activity.find(_activity_parent_id)
|
91
106
|
end
|
92
107
|
|
93
|
-
# The {SocialStream::Models::Subject subject} that posted this object
|
94
|
-
def _author
|
95
|
-
post_activity.contact.sender_subject
|
96
|
-
end
|
97
|
-
|
98
|
-
# The owner of the wall where {#_author} posted this object
|
99
|
-
def _owner
|
100
|
-
post_activity.contact.receiver_subject
|
101
|
-
end
|
102
|
-
|
103
108
|
private
|
104
109
|
|
105
110
|
def create_post_activity
|
@@ -33,7 +33,9 @@ module SocialStream
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def model_assigned_to contact, relation_ids
|
36
|
-
model_attributes[:
|
36
|
+
model_attributes[:author_id] = contact.sender.id
|
37
|
+
model_attributes[:owner_id] = contact.receiver.id
|
38
|
+
model_attributes[:user_author_id] = contact.sender.id
|
37
39
|
model_attributes[:_relation_ids] = Array(relation_ids).map(&:id)
|
38
40
|
end
|
39
41
|
|
@@ -91,7 +91,8 @@ namespace :db do
|
|
91
91
|
|
92
92
|
Group.create! :name => Forgery::Name.company_name,
|
93
93
|
:email => Forgery::Internet.email_address,
|
94
|
-
:
|
94
|
+
:author_id => founder.id,
|
95
|
+
:user_author_id => founder.id
|
95
96
|
end
|
96
97
|
|
97
98
|
set_tags(Group)
|
@@ -128,11 +129,17 @@ namespace :db do
|
|
128
129
|
SocialStream::Populate.power_law(Tie.all) do |t|
|
129
130
|
updated = Time.at(rand(Time.now.to_i))
|
130
131
|
|
132
|
+
author = t.sender
|
133
|
+
owner = t.receiver
|
134
|
+
user_author = ( t.sender.subject_type == "User" ? t.sender : t.sender.user_author )
|
135
|
+
|
131
136
|
p = Post.create :text =>
|
132
137
|
"This post should be for #{ t.relation.name } of #{ t.sender.name }.\n#{ Forgery::LoremIpsum.paragraph(:random => true) }",
|
133
138
|
:created_at => Time.at(rand(updated.to_i)),
|
134
139
|
:updated_at => updated,
|
135
|
-
:
|
140
|
+
:author_id => author.id,
|
141
|
+
:owner_id => owner.id,
|
142
|
+
:user_author_id => user_author.id,
|
136
143
|
:_relation_ids => Array(t.relation_id)
|
137
144
|
|
138
145
|
p.post_activity.update_attributes(:created_at => p.created_at,
|