social_stream 0.4.2 → 0.4.3
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/activities_controller.rb +1 -0
- data/app/controllers/avatars_controller.rb +17 -10
- data/app/controllers/comments_controller.rb +2 -0
- data/app/controllers/conversations_controller.rb +98 -103
- data/app/controllers/groups_controller.rb +3 -1
- data/app/controllers/likes_controller.rb +2 -0
- data/app/controllers/messages_controller.rb +4 -0
- data/app/controllers/posts_controller.rb +2 -2
- data/app/controllers/ties_controller.rb +6 -0
- data/app/helpers/subjects_helper.rb +32 -7
- data/app/helpers/ties_helper.rb +7 -2
- data/app/models/activity.rb +1 -1
- data/app/models/actor.rb +5 -8
- data/app/models/relation.rb +65 -0
- data/app/models/tie.rb +27 -7
- data/app/views/activities/_child.html.erb +1 -5
- data/app/views/activities/_root.html.erb +2 -4
- data/app/views/avatars/_form.html.erb +5 -16
- data/app/views/avatars/_precrop.html.erb +24 -17
- data/app/views/avatars/index.html.erb +47 -36
- data/app/views/avatars/new.html.erb +19 -3
- data/app/views/contacts/index.html.erb +1 -1
- data/app/views/contacts/index.js.erb +2 -0
- data/app/views/conversations/_conversation_full.html.erb +2 -1
- data/app/views/conversations/_index.html.erb +0 -7
- data/app/views/conversations/_show.html.erb +0 -7
- data/app/views/conversations/index.html.erb +9 -1
- data/app/views/conversations/index.js.erb +1 -0
- data/app/views/conversations/show.html.erb +1 -1
- data/app/views/conversations/show.js.erb +2 -0
- data/app/views/groups/_new.html.erb +9 -2
- data/app/views/groups/new.html.erb +5 -1
- data/app/views/layouts/_header.erb +23 -1
- data/app/views/layouts/_representation.html.erb +1 -1
- data/app/views/messages/new.html.erb +1 -1
- data/app/views/messages/new.js.erb +3 -0
- data/app/views/profiles/_profile.html.erb +18 -13
- data/app/views/profiles/edit.html.erb +29 -4
- data/app/views/profiles/update.js.erb +3 -3
- data/app/views/subjects/_toolbar_home_menu_options.html.erb +1 -1
- data/app/views/subjects/_toolbar_home_menu_options_subjects.html.erb +2 -2
- data/app/views/subjects/_toolbar_logo.html.erb +14 -2
- data/app/views/subjects/_toolbar_message_menu.html.erb +1 -1
- data/app/views/subjects/_toolbar_profile_menu_tie_options.html.erb +18 -7
- data/app/views/ties/_edit.html.erb +102 -0
- data/app/views/ties/_new.html.erb +48 -19
- data/app/views/ties/edit.html.erb +1 -0
- data/config/locales/en.yml +42 -27
- data/config/routes.rb +0 -6
- data/lib/generators/social_stream/templates/public/images/btn/arrowBlue.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/shadow.png +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/addContact.js +100 -0
- data/lib/generators/social_stream/templates/public/javascripts/avatars.js +8 -0
- data/lib/generators/social_stream/templates/public/javascripts/hoverIntent.js +84 -0
- data/lib/generators/social_stream/templates/public/javascripts/main.js +10 -1
- data/lib/generators/social_stream/templates/public/javascripts/menu.js +22 -6
- data/lib/generators/social_stream/templates/public/stylesheets/default/activities.css +2 -2
- data/lib/generators/social_stream/templates/public/stylesheets/default/addContact.css +29 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/avatars.css +79 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +44 -5
- data/lib/generators/social_stream/templates/public/stylesheets/default/header.css +151 -1
- data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +1 -1
- data/lib/generators/social_stream/templates/public/stylesheets/default/jquery-ui.css +1 -1
- data/lib/generators/social_stream/templates/public/stylesheets/default/messages.css +6 -4
- data/lib/social_stream.rb +1 -1
- data/lib/social_stream/ability.rb +20 -0
- data/lib/social_stream/models/subject.rb +5 -1
- data/lib/social_stream/test_helpers/controllers.rb +55 -0
- data/lib/social_stream/version.rb +1 -1
- data/social_stream.gemspec +1 -1
- data/spec/controllers/comments_controller_spec.rb +38 -0
- data/spec/controllers/groups_controller_spec.rb +75 -5
- data/spec/factories/comment.rb +4 -0
- data/spec/models/tie_spec.rb +25 -15
- metadata +18 -10
- data/app/controllers/pshb_controller.rb +0 -55
- data/app/views/ties/new.js.erb +0 -12
- data/lib/social_stream/relations.rb +0 -46
@@ -8,22 +8,22 @@ class AvatarsController < InheritedResources::Base
|
|
8
8
|
new_logo = Avatar.find(params[:id])
|
9
9
|
|
10
10
|
if (new_logo.actor == current_subject.actor)
|
11
|
-
|
11
|
+
|
12
12
|
actual_logo = current_subject.avatars.active.first
|
13
13
|
if !actual_logo.blank?
|
14
|
-
|
15
|
-
|
14
|
+
actual_logo.active = false
|
15
|
+
actual_logo.save
|
16
16
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
|
18
|
+
new_logo.active = true
|
19
|
+
new_logo.save
|
20
20
|
end
|
21
21
|
end
|
22
22
|
redirect_to avatars_path
|
23
23
|
end
|
24
24
|
|
25
25
|
def create
|
26
|
-
@avatar = Avatar.create(params[:
|
26
|
+
@avatar = Avatar.create(params[:avatar])
|
27
27
|
|
28
28
|
if @avatar.new_record?
|
29
29
|
render :new
|
@@ -32,13 +32,20 @@ class AvatarsController < InheritedResources::Base
|
|
32
32
|
@avatar.actor_id = current_subject.actor.id
|
33
33
|
if !current_subject.avatars.blank?
|
34
34
|
actual_logo = current_subject.avatars.active.first
|
35
|
-
|
36
|
-
|
35
|
+
actual_logo.active = false
|
36
|
+
actual_logo.save
|
37
37
|
end
|
38
38
|
@avatar.active = true
|
39
39
|
@avatar.save
|
40
|
-
redirect_to
|
40
|
+
redirect_to avatars_path
|
41
|
+
#redirect_to [current_subject, :profile]
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
45
|
+
protected
|
46
|
+
|
47
|
+
def begin_of_association_chain
|
48
|
+
current_subject
|
49
|
+
end
|
50
|
+
|
44
51
|
end
|
@@ -1,107 +1,102 @@
|
|
1
1
|
class ConversationsController < ApplicationController
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
@box = "inbox"
|
102
|
-
return
|
103
|
-
end
|
104
|
-
@box = params[:box]
|
105
|
-
end
|
3
|
+
before_filter :authenticate_user!
|
4
|
+
before_filter :get_mailbox, :get_box, :get_actor
|
5
|
+
before_filter :check_current_subject_in_conversation, :only => [:show, :update, :destroy]
|
6
|
+
def index
|
7
|
+
if @box.eql?"inbox"
|
8
|
+
@conversations = @mailbox.inbox.paginate(:per_page => 9, :page => params[:page])
|
9
|
+
elsif @box.eql?"sentbox"
|
10
|
+
@conversations = @mailbox.sentbox.paginate(:per_page => 9, :page => params[:page])
|
11
|
+
else
|
12
|
+
@conversations = @mailbox.trash.paginate(:per_page => 9, :page => params[:page])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def show
|
17
|
+
if @box.eql? 'trash'
|
18
|
+
@receipts = @conversation.receipts(@actor).trash
|
19
|
+
else
|
20
|
+
@receipts = @conversation.receipts(@actor).not_trash
|
21
|
+
end
|
22
|
+
render :action => :show
|
23
|
+
@receipts.mark_as_read
|
24
|
+
end
|
25
|
+
|
26
|
+
def new
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def edit
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def create
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
if params[:untrash].present?
|
40
|
+
@conversation.untrash(@actor)
|
41
|
+
end
|
42
|
+
|
43
|
+
if params[:reply_all].present?
|
44
|
+
last_receipt = @conversation.receipts(@actor).last
|
45
|
+
@receipt = @actor.reply_to_all(last_receipt, params[:body])
|
46
|
+
end
|
47
|
+
|
48
|
+
if @box.eql? 'trash'
|
49
|
+
@receipts = @conversation.receipts(@actor).trash
|
50
|
+
else
|
51
|
+
@receipts = @conversation.receipts(@actor).not_trash
|
52
|
+
end
|
53
|
+
render :action => :show
|
54
|
+
@receipts.mark_as_read
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def destroy
|
59
|
+
|
60
|
+
@conversation.move_to_trash(@actor)
|
61
|
+
|
62
|
+
if params[:location].present?
|
63
|
+
case params[:location]
|
64
|
+
when 'conversation'
|
65
|
+
redirect_to conversations_path(:box => :trash)
|
66
|
+
return
|
67
|
+
else
|
68
|
+
redirect_to conversations_path(:box => @box,:page => params[:page])
|
69
|
+
return
|
70
|
+
end
|
71
|
+
end
|
72
|
+
redirect_to conversations_path(:box => @box,:page => params[:page])
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def get_mailbox
|
78
|
+
@mailbox = current_subject.mailbox
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_actor
|
82
|
+
@actor = Actor.normalize(current_subject)
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_box
|
86
|
+
if params[:box].blank? or !["inbox","sentbox","trash"].include?params[:box]
|
87
|
+
@box = "inbox"
|
88
|
+
return
|
89
|
+
end
|
90
|
+
@box = params[:box]
|
91
|
+
end
|
92
|
+
|
93
|
+
def check_current_subject_in_conversation
|
94
|
+
@conversation = Conversation.find_by_id(params[:id])
|
95
|
+
|
96
|
+
if @conversation.nil? or !@conversation.is_participant?(@actor)
|
97
|
+
redirect_to conversations_path(:box => @box)
|
98
|
+
return
|
99
|
+
end
|
100
|
+
end
|
106
101
|
|
107
102
|
end
|
@@ -9,6 +9,12 @@ class TiesController < InheritedResources::Base
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
def update
|
13
|
+
update do |format|
|
14
|
+
format.html { redirect_to resource.receiver_subject }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
def suggestion
|
13
19
|
@tie = current_subject.suggestion
|
14
20
|
render :layout => false
|
@@ -11,6 +11,20 @@ module SubjectsHelper
|
|
11
11
|
#
|
12
12
|
# The menu option allows overwriting a menu slot with the content of the given block
|
13
13
|
#
|
14
|
+
#
|
15
|
+
# Autoexpanding a menu section on your view:
|
16
|
+
#
|
17
|
+
# Toolbar allows you to autoexpand certain menu section that may be of interest for your view.
|
18
|
+
# For example, the messages menu when you are looking your inbox. This is done through :option element.
|
19
|
+
#
|
20
|
+
# To get it working, you should use the proper :option to be expanded, ":option => :messages" in the
|
21
|
+
# mentioned example. This will try, automatically, to expand the section of the menu where its root
|
22
|
+
# list link, the one expanding the section, has an id equal to "#messages_menu". If you use
|
23
|
+
# ":options => :contacts" it will try to expand "#contacts_menu".
|
24
|
+
#
|
25
|
+
# For now its working with :option => :messages, :contacts or :groups
|
26
|
+
#
|
27
|
+
#
|
14
28
|
# Examples:
|
15
29
|
#
|
16
30
|
# Render the home toolbar:
|
@@ -29,6 +43,7 @@ module SubjectsHelper
|
|
29
43
|
#
|
30
44
|
# <% toolbar :profile => @group, :option => :contacts %>
|
31
45
|
#
|
46
|
+
|
32
47
|
def toolbar(options = {}, &block)
|
33
48
|
if options[:option] && block_given?
|
34
49
|
menu_options[options[:option]] = capture(&block)
|
@@ -44,15 +59,25 @@ module SubjectsHelper
|
|
44
59
|
|
45
60
|
case request.format
|
46
61
|
when Mime::JS
|
47
|
-
<<-EOJ
|
48
|
-
|
49
|
-
|
62
|
+
response = <<-EOJ
|
63
|
+
|
64
|
+
$('#toolbar').html("#{ escape_javascript(content) }");
|
65
|
+
initMenu();
|
66
|
+
expandSubMenu('#{ options[:option] }');
|
67
|
+
EOJ
|
68
|
+
|
69
|
+
response.html_safe
|
50
70
|
else
|
51
|
-
|
52
|
-
|
53
|
-
end
|
71
|
+
content_for(:toolbar) do
|
72
|
+
content
|
54
73
|
end
|
55
|
-
|
74
|
+
content_for(:javascript) do
|
75
|
+
<<-EOJ
|
76
|
+
expandSubMenu('#{ options[:option] }');
|
77
|
+
EOJ
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
56
81
|
end
|
57
82
|
|
58
83
|
# Cache menu options for toolbar
|
data/app/helpers/ties_helper.rb
CHANGED
@@ -22,11 +22,16 @@ module TiesHelper
|
|
22
22
|
new_tie_path("tie[sender_id]" => tie.sender.id,
|
23
23
|
"tie[receiver_id]" => tie.receiver.id),
|
24
24
|
:title => t("contact.new.title",
|
25
|
-
:name => tie.receiver_subject.name)
|
26
|
-
:remote => true
|
25
|
+
:name => tie.receiver_subject.name)
|
27
26
|
end
|
28
27
|
|
29
28
|
def link_follow_state
|
30
29
|
link_to("Unfollow", home_path)
|
31
30
|
end
|
31
|
+
|
32
|
+
|
33
|
+
def get_permission_id(action,object,function)
|
34
|
+
return Permission.find_by_action_and_function_and_object(action,object,function).id
|
35
|
+
end
|
36
|
+
|
32
37
|
end
|
data/app/models/activity.rb
CHANGED
@@ -137,7 +137,7 @@ class Activity < ActiveRecord::Base
|
|
137
137
|
def title view
|
138
138
|
case verb
|
139
139
|
when "follow", "make-friend"
|
140
|
-
I18n.t "activity.verb.#{ verb }.title",
|
140
|
+
I18n.t "activity.verb.#{ verb }.#{ tie.receiver.subject_type }.title",
|
141
141
|
:subject => view.link_name(sender_subject),
|
142
142
|
:contact => view.link_name(receiver_subject)
|
143
143
|
when "post"
|
data/app/models/actor.rb
CHANGED
@@ -67,7 +67,7 @@ class Actor < ActiveRecord::Base
|
|
67
67
|
joins(:received_ties).merge(Tie.sent_by(a))
|
68
68
|
}
|
69
69
|
|
70
|
-
after_create :
|
70
|
+
after_create :create_initial_relations
|
71
71
|
|
72
72
|
after_create :create_profile
|
73
73
|
|
@@ -229,7 +229,7 @@ class Actor < ActiveRecord::Base
|
|
229
229
|
|
230
230
|
# Set of ties sent by this actor received by a
|
231
231
|
def ties_to(a)
|
232
|
-
sent_ties.received_by(a)
|
232
|
+
sent_ties.received_by(a).original
|
233
233
|
end
|
234
234
|
|
235
235
|
def ties_to?(a)
|
@@ -301,11 +301,8 @@ class Actor < ActiveRecord::Base
|
|
301
301
|
|
302
302
|
private
|
303
303
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
:relation => r
|
308
|
-
end
|
304
|
+
# After create callback
|
305
|
+
def create_initial_relations
|
306
|
+
Relation.defaults_for(self)
|
309
307
|
end
|
310
|
-
|
311
308
|
end
|