social_stream-base 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/contacts_controller.rb +11 -14
- data/app/models/activity.rb +5 -1
- data/app/views/message_mailer/new_message_email.html.erb +26 -12
- data/app/views/message_mailer/new_message_email.text.erb +2 -5
- data/app/views/message_mailer/reply_message_email.html.erb +26 -12
- data/app/views/message_mailer/reply_message_email.text.erb +3 -6
- data/app/views/messages/new.html.erb +2 -2
- data/app/views/notification_mailer/new_notification_email.text.erb +3 -3
- data/app/views/objects/_show.html.erb +3 -0
- data/app/views/posts/show.html.erb +2 -0
- data/config/locales/en.yml +2 -1
- data/lib/social_stream/base/version.rb +1 -1
- data/lib/social_stream/models/object.rb +10 -0
- data/social_stream-base.gemspec +1 -1
- data/spec/controllers/likes_controller_spec.rb +19 -0
- data/spec/controllers/posts_controller_spec.rb +12 -0
- data/spec/factories/post.rb +5 -0
- data/vendor/assets/javascripts/ckeditor/config.js +2 -0
- metadata +9 -7
@@ -1,24 +1,21 @@
|
|
1
1
|
class ContactsController < ApplicationController
|
2
2
|
before_filter :authenticate_user!
|
3
|
-
|
4
3
|
def index
|
5
4
|
if params[:pending].present?
|
6
5
|
pending
|
7
|
-
|
6
|
+
return
|
8
7
|
end
|
9
8
|
@contacts =
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
Contact.sent_by(current_subject).
|
10
|
+
joins(:receiver).merge(Actor.alphabetic).
|
11
|
+
merge(Actor.letter(params[:letter])).
|
12
|
+
merge(Actor.search(params[:search])).
|
13
|
+
active
|
17
14
|
|
18
15
|
respond_to do |format|
|
19
16
|
format.html { @contacts = @contacts.page(params[:page]).per(10) }
|
20
17
|
format.js { @contacts = @contacts.page(params[:page]).per(10) }
|
21
|
-
format.json { render :text => @contacts.map{ |c| { 'key' => c.
|
18
|
+
format.json { render :text => @contacts.map{ |c| { 'key' => c.receiver_id.to_s, 'value' => self.class.helpers.truncate_name(c.receiver.name) } }.to_json }
|
22
19
|
end
|
23
20
|
end
|
24
21
|
|
@@ -43,22 +40,22 @@ class ContactsController < ApplicationController
|
|
43
40
|
|
44
41
|
def destroy
|
45
42
|
@contact = current_subject.sent_contacts.find params[:id]
|
46
|
-
|
43
|
+
|
47
44
|
@contact.relation_ids = [current_subject.relation_public.id]
|
48
45
|
|
49
46
|
respond_to do |format|
|
50
47
|
format.js
|
51
48
|
end
|
52
49
|
end
|
53
|
-
|
50
|
+
|
54
51
|
def pending
|
55
52
|
|
56
|
-
|
53
|
+
@contacts = current_subject.pending_contacts
|
57
54
|
|
58
55
|
respond_to do |format|
|
59
56
|
format.html { @contacts = Kaminari.paginate_array(@contacts).page(params[:page]).per(10) }
|
60
57
|
format.js { Kaminari.paginate_array(@contacts).page(params[:page]).per(10) }
|
61
|
-
format.json { render :text => @contacts.map{ |c| { 'key' => c.
|
58
|
+
format.json { render :text => @contacts.map{ |c| { 'key' => c.receiver_id.to_s, 'value' => self.class.helpers.truncate_name(c.receiver.name) } }.to_json }
|
62
59
|
end
|
63
60
|
end
|
64
61
|
end
|
data/app/models/activity.rb
CHANGED
@@ -231,7 +231,11 @@ class Activity < ActiveRecord::Base
|
|
231
231
|
return val
|
232
232
|
|
233
233
|
when 'read'
|
234
|
-
return true if
|
234
|
+
return true if relations.select{ |r| r.is_a?(Relation::Public) }.any?
|
235
|
+
|
236
|
+
return false if subject.blank?
|
237
|
+
|
238
|
+
return true if [contact.sender_id, contact.receiver_id].include?(Actor.normalize_id(subject))
|
235
239
|
when 'update'
|
236
240
|
return true if contact.sender_id == Actor.normalize_id(subject)
|
237
241
|
when 'destroy'
|
@@ -4,17 +4,31 @@
|
|
4
4
|
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
5
5
|
</head>
|
6
6
|
<body>
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
<
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
<div>
|
8
|
+
<div style="padding: 10px 5px 5px 5px;">
|
9
|
+
<span style="font-weight: bold;"><%= @message.sender.name%></span>
|
10
|
+
has sent you a new message: <%= @message.subject.html_safe? ? @message.subject : strip_tags(@message.subject) %></h1>
|
11
|
+
</div>
|
12
|
+
<div style="position: static;padding: 5px; border: #2A3890 solid 2px; background-color: #E1EEF5; margin:10px; min-height: 125px; width: 500px;">
|
13
|
+
<div style="float:left; margin-right:7px; border: thin solid #D4E4EA; background-color: white; max-height: 119px;">
|
14
|
+
<img src="http://<%= ActionMailer::Base.default_url_options[:host] +@message.sender.logo.url(:profile)%>" alt="<%=@message.sender.name%>">
|
15
|
+
</div>
|
16
|
+
<div style=" margin: 5px 5px 5px 5px;">
|
17
|
+
<p style="font-weight: bold; "><%= @message.sender.name %>
|
18
|
+
<% if @message.sender.profile.organization? %>
|
19
|
+
<br/><span style="color: #6C6D6F; font-weight: normal;"><%= @message.sender.profile.organization%></span>
|
20
|
+
<% end %>
|
21
|
+
</p>
|
22
|
+
<p>
|
23
|
+
<%= raw @message.body %>
|
24
|
+
</p>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<div style="padding: 10px 5px 5px 5px;">
|
28
|
+
<p>
|
29
|
+
<%= link_to((t('message.look')+" at "+t('socialstream')), conversation_url(@message.conversation))%>
|
30
|
+
</p>
|
31
|
+
</div>
|
32
|
+
</div>
|
19
33
|
</body>
|
20
34
|
</html>
|
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
===============================================
|
3
|
-
|
4
|
-
You have received a new message:
|
1
|
+
<%= @message.sender.name%> has sent you a new message: <%= @message.subject.html_safe? ? @message.subject : strip_tags(@message.subject) %>
|
5
2
|
|
6
3
|
-----------------------------------------------
|
7
4
|
<%= @message.body.html_safe? ? @message.body : strip_tags(@message.body) %>
|
8
5
|
-----------------------------------------------
|
9
6
|
|
10
|
-
|
7
|
+
<%=t('message.look')%> at <%= t('socialstream')%>: <%=conversation_url(@message.conversation)%>.
|
@@ -4,17 +4,31 @@
|
|
4
4
|
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
5
5
|
</head>
|
6
6
|
<body>
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
<
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
<div>
|
8
|
+
<div style="padding: 10px 5px 5px 5px;">
|
9
|
+
<span style="font-weight: bold;"><%= @message.sender.name%></span>
|
10
|
+
has sent a reply: <%= @message.subject.html_safe? ? @message.subject : strip_tags(@message.subject) %>
|
11
|
+
</div>
|
12
|
+
<div style="position: static;padding: 5px; border: #2A3890 solid 2px; background-color: #E1EEF5; margin:10px; min-height: 125px; width: 500px;">
|
13
|
+
<div style="float:left; margin-right:7px; border: thin solid #D4E4EA; background-color: white; max-height: 119px;">
|
14
|
+
<img src="http://<%= ActionMailer::Base.default_url_options[:host] +@message.sender.logo.url(:profile)%>" alt="<%=@message.sender.name%>">
|
15
|
+
</div>
|
16
|
+
<div style=" margin: 5px 5px 5px 5px;">
|
17
|
+
<p style="font-weight: bold; "><%= @message.sender.name %>
|
18
|
+
<% if @message.sender.profile.organization? %>
|
19
|
+
<br/><span style="color: #6C6D6F; font-weight: normal;"><%= @message.sender.profile.organization%></span>
|
20
|
+
<% end %>
|
21
|
+
</p>
|
22
|
+
<p>
|
23
|
+
<%= raw @message.body %>
|
24
|
+
</p>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<div style="padding: 10px 5px 5px 5px;">
|
28
|
+
<p>
|
29
|
+
<%= link_to t('message.look'), conversation_url(@message.conversation)%> at <%= t('socialstream')%>
|
30
|
+
</p>
|
31
|
+
</div>
|
32
|
+
</div>
|
19
33
|
</body>
|
20
34
|
</html>
|
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
===============================================
|
3
|
-
|
4
|
-
You have received a new reply:
|
1
|
+
<%= @message.sender.name%> has sent a reply: <%= @message.subject.html_safe? ? @message.subject : strip_tags(@message.subject) %>
|
5
2
|
|
6
3
|
-----------------------------------------------
|
7
|
-
<%= @message.body.html_safe? ? @message.body : strip_tags(@message.body) %>
|
4
|
+
"<%= @message.body.html_safe? ? @message.body : strip_tags(@message.body) %>"
|
8
5
|
-----------------------------------------------
|
9
6
|
|
10
|
-
|
7
|
+
<%=t('message.look')%> at <%= t('socialstream')%>: <%=conversation_url(@message.conversation)%>.
|
@@ -17,7 +17,7 @@
|
|
17
17
|
height: 6
|
18
18
|
});
|
19
19
|
|
20
|
-
|
20
|
+
/*
|
21
21
|
$('#body').ckeditor(
|
22
22
|
function(){
|
23
23
|
$('#cke_top_body').click( updateTextArea);
|
@@ -38,7 +38,7 @@
|
|
38
38
|
$("#body").trigger('keyup');
|
39
39
|
}
|
40
40
|
|
41
|
-
|
41
|
+
*/
|
42
42
|
<% unless @recipient.nil? %>
|
43
43
|
$("#_recipients").trigger("addItem",[{"title": "<%= truncate_name @recipient.name %>", "value": "<%= @recipient.id %>"}]);
|
44
44
|
<% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% self.class.send :include, NotificationsHelper %>
|
2
2
|
<%= strip_tags decode_notification @notification.subject,@notification.notified_object %>
|
3
|
-
|
3
|
+
-----------------------------------------------
|
4
4
|
<%= strip_tags decode_notification @notification.body,@notification.notified_object %>
|
5
|
-
|
6
|
-
Visit <%=
|
5
|
+
-----------------------------------------------
|
6
|
+
Visit <%= notifications_url %> and check all your notifications.
|
data/config/locales/en.yml
CHANGED
@@ -190,13 +190,14 @@ en:
|
|
190
190
|
message:
|
191
191
|
answer: "Write your answer"
|
192
192
|
inbox: "Inbox"
|
193
|
+
look: "Take a look at this conversation"
|
193
194
|
new: "New Message"
|
194
195
|
one: "Message"
|
195
196
|
other: "Messages"
|
196
197
|
participants: "Participants"
|
198
|
+
send: "Send a message"
|
197
199
|
sentbox: "Sentbox"
|
198
200
|
trash: "Trash"
|
199
|
-
send: "Send a message"
|
200
201
|
notification:
|
201
202
|
confirm: "Confirm %{sender.name} as contact?"
|
202
203
|
destroy_sure: "Do you want to delete this notification?"
|
@@ -65,6 +65,16 @@ module SocialStream
|
|
65
65
|
@_activity_parent ||= Activity.find(_activity_parent_id)
|
66
66
|
end
|
67
67
|
|
68
|
+
# The {SocialStream::Models::Subject subject} that posted this object
|
69
|
+
def _author
|
70
|
+
post_activity.contact.sender_subject
|
71
|
+
end
|
72
|
+
|
73
|
+
# The owner of the wall where {#_author} posted this object
|
74
|
+
def _owner
|
75
|
+
post_activity.contact.receiver_subject
|
76
|
+
end
|
77
|
+
|
68
78
|
private
|
69
79
|
|
70
80
|
def create_post_activity
|
data/social_stream-base.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
# OAuth provider
|
36
36
|
s.add_runtime_dependency('oauth-plugin','~> 0.4.0.pre1')
|
37
37
|
# Messages
|
38
|
-
s.add_runtime_dependency('mailboxer','~> 0.4.
|
38
|
+
s.add_runtime_dependency('mailboxer','~> 0.4.1')
|
39
39
|
# Avatar manipulation
|
40
40
|
s.add_runtime_dependency('rmagick','~> 2.13.1')
|
41
41
|
# Tagging
|
@@ -25,5 +25,24 @@ describe LikesController do
|
|
25
25
|
|
26
26
|
assert ! @activity.liked_by?(@subject)
|
27
27
|
end
|
28
|
+
|
29
|
+
it "should create, destroy and create it again" do
|
30
|
+
@activity = Factory(:activity)
|
31
|
+
@subject = @activity.receiver_subject
|
32
|
+
|
33
|
+
sign_in @subject
|
34
|
+
|
35
|
+
post :create, :activity_id => @activity.id
|
36
|
+
|
37
|
+
assert @activity.liked_by?(@subject)
|
38
|
+
|
39
|
+
delete :destroy, :activity_id => @activity.id
|
40
|
+
|
41
|
+
assert ! @activity.liked_by?(@subject)
|
42
|
+
|
43
|
+
post :create, :activity_id => @activity.id
|
44
|
+
|
45
|
+
assert @activity.liked_by?(@subject)
|
46
|
+
end
|
28
47
|
end
|
29
48
|
|
@@ -151,5 +151,17 @@ describe PostsController do
|
|
151
151
|
post.post_activity.relations.should include(@tie.relation)
|
152
152
|
end
|
153
153
|
end
|
154
|
+
|
155
|
+
context "creating public post" do
|
156
|
+
before do
|
157
|
+
@post = Factory(:public_post)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should render" do
|
161
|
+
get :show, :id => @post.to_param
|
162
|
+
|
163
|
+
response.should be_success
|
164
|
+
end
|
165
|
+
end
|
154
166
|
end
|
155
167
|
|
data/spec/factories/post.rb
CHANGED
@@ -3,3 +3,8 @@ Factory.define :post do |p|
|
|
3
3
|
p._contact_id { Factory(:friend).contact_id }
|
4
4
|
p._relation_ids { |q| Array(Contact.find(q._contact_id).sender.relation_customs.sort.first.id) }
|
5
5
|
end
|
6
|
+
|
7
|
+
Factory.define :public_post, :parent => :post do |p|
|
8
|
+
p._contact_id { Factory(:self_contact).id }
|
9
|
+
p._relation_ids { |q| Array(Contact.find(q._contact_id).sender.relation_public.id) }
|
10
|
+
end
|
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: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 2
|
10
|
+
version: 0.7.2
|
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-07-
|
19
|
+
date: 2011-07-21 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -205,12 +205,12 @@ dependencies:
|
|
205
205
|
requirements:
|
206
206
|
- - ~>
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
hash:
|
208
|
+
hash: 13
|
209
209
|
segments:
|
210
210
|
- 0
|
211
211
|
- 4
|
212
|
-
-
|
213
|
-
version: 0.4.
|
212
|
+
- 1
|
213
|
+
version: 0.4.1
|
214
214
|
type: :runtime
|
215
215
|
version_requirements: *id012
|
216
216
|
- !ruby/object:Gem::Dependency
|
@@ -811,6 +811,7 @@ files:
|
|
811
811
|
- app/views/notifications/index.js.erb
|
812
812
|
- app/views/objects/_destroy.js.erb
|
813
813
|
- app/views/objects/_new.html.erb
|
814
|
+
- app/views/objects/_show.html.erb
|
814
815
|
- app/views/permissions/_index.html.erb
|
815
816
|
- app/views/permissions/index.js.erb
|
816
817
|
- app/views/posts/_fields.erb
|
@@ -818,6 +819,7 @@ files:
|
|
818
819
|
- app/views/posts/_post.html.erb
|
819
820
|
- app/views/posts/create.js.erb
|
820
821
|
- app/views/posts/destroy.js.erb
|
822
|
+
- app/views/posts/show.html.erb
|
821
823
|
- app/views/profiles/_contact.html.erb
|
822
824
|
- app/views/profiles/_experience.html.erb
|
823
825
|
- app/views/profiles/_personal.html.erb
|