social_stream 0.3.1 → 0.3.2
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/.gitignore +1 -0
- data/app/models/activity.rb +8 -3
- data/app/models/permission.rb +3 -1
- data/app/models/tie.rb +11 -5
- data/app/views/activities/_activities.html.erb +3 -2
- data/app/views/activities/_new.html.erb +1 -1
- data/app/views/groups/_index.html.erb +4 -1
- data/app/views/groups/index.html.erb +0 -13
- data/app/views/groups/show.html.erb +1 -1
- data/app/views/home/index.html.erb +1 -1
- data/app/views/layouts/_header.erb +33 -28
- data/app/views/ties/create.js.erb +3 -3
- data/app/views/users/_index.html.erb +4 -1
- data/app/views/users/index.html.erb +0 -13
- data/app/views/users/show.html.erb +1 -1
- data/lib/generators/social_stream/templates/public/images/favicon.ico +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/header.css +6 -1
- data/lib/generators/social_stream/templates/relations.yml +1 -0
- data/lib/social_stream/ability.rb +1 -3
- data/lib/social_stream/controllers/helpers.rb +5 -2
- data/lib/social_stream/version.rb +1 -1
- data/social_stream.gemspec +3 -2
- data/spec/dummy/config/relations.yml +1 -0
- data/spec/dummy/db/.gitignore +1 -0
- data/spec/models/tie_activity_spec.rb +52 -0
- data/spec/models/tie_spec.rb +10 -6
- metadata +12 -9
data/.gitignore
CHANGED
data/app/models/activity.rb
CHANGED
@@ -114,9 +114,14 @@ class Activity < ActiveRecord::Base
|
|
114
114
|
# Assign to ties of followers
|
115
115
|
def assign_to_ties
|
116
116
|
original = tie_activities.create!(:tie => _tie)
|
117
|
-
|
118
|
-
|
119
|
-
|
117
|
+
|
118
|
+
# All the ties following the activities attached to this tie, allowed to read
|
119
|
+
# this activity
|
120
|
+
Tie.following([_tie.sender_id, _tie.receiver_id]).each do |t|
|
121
|
+
if _tie.allows?(t.sender_id, 'read', 'activity')
|
122
|
+
tie_activities.create!(:tie => t,
|
123
|
+
:original => false)
|
124
|
+
end
|
120
125
|
end
|
121
126
|
end
|
122
127
|
end
|
data/app/models/permission.rb
CHANGED
@@ -19,7 +19,9 @@ class Permission < ActiveRecord::Base
|
|
19
19
|
has_many :relation_permissions, :dependent => :destroy
|
20
20
|
has_many :relations, :through => :relation_permissions
|
21
21
|
|
22
|
-
|
22
|
+
%w(represent follow).each do |p|
|
23
|
+
scope p, where(:action => p) # scope :represent, where(:action => 'represent')
|
24
|
+
end
|
23
25
|
|
24
26
|
# The SQL and ARel conditions for permission queries
|
25
27
|
ParameterConditions = {
|
data/app/models/tie.rb
CHANGED
@@ -68,6 +68,11 @@ class Tie < ActiveRecord::Base
|
|
68
68
|
where("ties.sender_id = ties_2.receiver_id AND ties.receiver_id = ties_2.sender_id")
|
69
69
|
}
|
70
70
|
|
71
|
+
scope :following, lambda { |a|
|
72
|
+
where(:receiver_id => Actor.normalize_id(a)).
|
73
|
+
joins(:relation => :permissions) & Permission.follow
|
74
|
+
}
|
75
|
+
|
71
76
|
validates_presence_of :sender_id, :receiver_id, :relation_id
|
72
77
|
|
73
78
|
before_validation :find_relation
|
@@ -118,11 +123,6 @@ class Tie < ActiveRecord::Base
|
|
118
123
|
relation_set(:relations => r).first
|
119
124
|
end
|
120
125
|
|
121
|
-
def activity_receivers
|
122
|
-
# TODO
|
123
|
-
Array.new
|
124
|
-
end
|
125
|
-
|
126
126
|
# = Access Control
|
127
127
|
#
|
128
128
|
# Access control enforcement in ties come from the permissions assigned to other ties through relations.
|
@@ -184,15 +184,21 @@ class Tie < ActiveRecord::Base
|
|
184
184
|
where("ties_as.receiver_id" => Actor.normalize_id(actor))
|
185
185
|
}
|
186
186
|
|
187
|
+
# The set of ties that permit this tie allow to allow action on object
|
187
188
|
def access_set(action, object)
|
188
189
|
self.class.access_set(self, action, object)
|
189
190
|
end
|
190
191
|
|
192
|
+
# The set of ties allowing user to perform action on object
|
191
193
|
def allowing(user, action, object)
|
192
194
|
access_set(action, object).received_by(user)
|
193
195
|
end
|
194
196
|
|
197
|
+
# Does this tie allows user to perform action on object?
|
195
198
|
def allows?(user, action, object)
|
199
|
+
# FIXME: Patch to support public activities
|
200
|
+
return true if relation.name == 'public' && action == 'read' && object == 'activity'
|
201
|
+
|
196
202
|
allowing(user, action, object).any?
|
197
203
|
end
|
198
204
|
|
@@ -12,8 +12,9 @@
|
|
12
12
|
</div>
|
13
13
|
|
14
14
|
<div id="wall">
|
15
|
-
|
15
|
+
<% activities = activities.paginate(:page => params[:page]) %>
|
16
|
+
<%- # should be activities.paginate(:page => params[:page], :count => { :select => 'activity.id', :distinct => true }) but it is not working in Rails 3.0.3 -%>
|
16
17
|
<%= render activities %>
|
17
|
-
|
18
|
+
<%= will_paginate activities %>
|
18
19
|
</div>
|
19
20
|
</div>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<%= f.text_field :text, :id => "input_activities", :size => 85 %>
|
17
17
|
<div id="activities_share_btn">
|
18
18
|
<div id="securities">
|
19
|
-
<%= f.select :_activity_tie_id, receiver.sent_ties_allowing(current_subject, 'create', 'activity').map{ |t| [ t.relation_name, t.id ] }, {}, :id => 'security' %>
|
19
|
+
<%= f.select :_activity_tie_id, receiver.sent_ties_allowing(current_subject, 'create', 'activity').sort{ |t, u| t.relation <=> u.relation }.map{ |t| [ t.relation_name, t.id ] }, {}, :id => 'security' %>
|
20
20
|
</div>
|
21
21
|
<%= image_submit_tag "btn/btn_share.png" %>
|
22
22
|
</div>
|
@@ -1,6 +1,8 @@
|
|
1
|
+
<% groups = Group.alphabetic.paginate(:page => params[:page]) %>
|
2
|
+
|
1
3
|
<% cont=0; %>
|
2
4
|
|
3
|
-
<%
|
5
|
+
<% groups.each do |group| %>
|
4
6
|
|
5
7
|
<% if (cont%2) == 0
|
6
8
|
cont+=1; %>
|
@@ -31,3 +33,4 @@
|
|
31
33
|
</div>
|
32
34
|
<% end %>
|
33
35
|
|
36
|
+
<%= will_paginate(groups) %>
|
@@ -69,19 +69,6 @@
|
|
69
69
|
<%= render :partial => "groups/index"%>
|
70
70
|
<div class="space_center">
|
71
71
|
</div>
|
72
|
-
<div class="letters" class="content_size">
|
73
|
-
<a href="#">First</a>
|
74
|
-
<a href="#"><<</a>
|
75
|
-
<a href="#">1</a>
|
76
|
-
<a href="#">2</a>
|
77
|
-
<a href="#">3</a>
|
78
|
-
4 <a href="#">5</a>
|
79
|
-
<a href="#">6</a>
|
80
|
-
... <a href="#">>></a>
|
81
|
-
<a href="#">Last</a>
|
82
|
-
</div>
|
83
|
-
<div class="space_center">
|
84
|
-
</div>
|
85
72
|
</div>
|
86
73
|
|
87
74
|
<div id="most_popular" class="tabconference_browse">
|
@@ -1,37 +1,42 @@
|
|
1
1
|
<div id="headerFront">
|
2
2
|
<div class="banner_top">
|
3
3
|
<div id="header_left">
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
</div>
|
8
|
-
<% if user_signed_in? %>
|
9
|
-
<%=image_tag("btn/btn_home.png",:class=>"btn_config") %>
|
10
|
-
<div class="txt_config">
|
11
|
-
<%= link_to t('home'), home_path %>
|
12
|
-
</div>
|
13
|
-
<%=image_tag("btn/btn_profile.png",:class=>"btn_config") %>
|
14
|
-
<div class="txt_config">
|
15
|
-
<%= link_to(t('profile.one'), current_subject)%>
|
16
|
-
</div>
|
17
|
-
<%=image_tag("btn/btn_browse.png",:class=>"btn_config") %>
|
18
|
-
<div class="txt_config2">
|
19
|
-
<%=link_to(t('browse'),users_path) %>
|
20
|
-
</div>
|
4
|
+
<a href="index.htm"></a>
|
5
|
+
<div id="logo_txt">
|
6
|
+
<%= link_to(t('socialstream') , root_path)%>
|
21
7
|
</div>
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
<% if user_signed_in? %>
|
9
|
+
<%=image_tag("btn/btn_home.png",:class=>"btn_config") %>
|
10
|
+
<div class="txt_config">
|
11
|
+
<%= link_to t('home'), home_path %>
|
12
|
+
</div>
|
13
|
+
<%=image_tag("btn/btn_profile.png",:class=>"btn_config") %>
|
14
|
+
<div class="txt_config">
|
15
|
+
<%= link_to(t('profile.one'), current_subject)%>
|
16
|
+
</div>
|
17
|
+
<%=image_tag("btn/btn_browse.png",:class=>"btn_config") %>
|
18
|
+
<div class="txt_config2">
|
19
|
+
<%=link_to(t('browse'),users_path) %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
27
23
|
|
28
|
-
|
24
|
+
<div id="header_right">
|
25
|
+
<% if user_signed_in? %>
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
<%=image_tag("btn/btn_config.png",:class=>"btn_config") %>
|
28
|
+
<div class="txt_config">
|
29
|
+
<%= link_to t('account.one'), '#' %>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div id="representation">
|
33
|
+
<%= render :partial => 'layouts/representation' %>
|
34
|
+
</div>
|
35
|
+
<%=image_tag("btn/btn_exit.png",:class=>"btn_config") %>
|
36
|
+
<div class="txt_config2">
|
37
|
+
<%= link_to t('sign_out'), destroy_user_session_path %>
|
38
|
+
</div>
|
39
|
+
<% end %>
|
35
40
|
</div>
|
36
41
|
</div>
|
37
42
|
<br class="clearfloat" />
|
@@ -8,7 +8,7 @@
|
|
8
8
|
if ($('#carousel_ul').length) { // element found
|
9
9
|
$("#carousel_ul").prepend("<%= escape_javascript(render @tie.receiver_subject) %>");
|
10
10
|
}else{ // no element found
|
11
|
-
$("#my_groups").html("<%= escape_javascript(render 'users/groups' )%>");
|
11
|
+
$("#my_groups").html("<%= escape_javascript(render(:partial => 'users/groups', :locals => { :user => current_subject } ))%>");
|
12
12
|
}
|
13
13
|
$("#group_count").html("<%=current_subject.recent_groups.count%>");
|
14
14
|
link_tie.replaceWith("<%= escape_javascript(link_follow_state) %>");
|
@@ -20,7 +20,7 @@
|
|
20
20
|
} else {
|
21
21
|
old_tie.hide();
|
22
22
|
}
|
23
|
-
|
24
|
-
$(".boxy-inner .close").click();
|
25
23
|
<% end %>
|
24
|
+
|
25
|
+
$(".boxy-inner .close").click();
|
26
26
|
<% end %>
|
@@ -1,6 +1,8 @@
|
|
1
|
+
<% users = User.alphabetic.paginate(:page => params[:page]) %>
|
2
|
+
|
1
3
|
<% cont=0; %>
|
2
4
|
|
3
|
-
<%
|
5
|
+
<% users.each do |user| %>
|
4
6
|
|
5
7
|
<% if (cont%2) == 0
|
6
8
|
cont+=1; %>
|
@@ -28,3 +30,4 @@
|
|
28
30
|
</div>
|
29
31
|
<% end %>
|
30
32
|
|
33
|
+
<%= will_paginate(users) %>
|
@@ -63,19 +63,6 @@
|
|
63
63
|
|
64
64
|
<div class="space_center">
|
65
65
|
</div>
|
66
|
-
<div class="letters" class="content_size">
|
67
|
-
<a href="#">First</a>
|
68
|
-
<a href="#"><<</a>
|
69
|
-
<a href="#">1</a>
|
70
|
-
<a href="#">2</a>
|
71
|
-
<a href="#">3</a>
|
72
|
-
4 <a href="#">5</a>
|
73
|
-
<a href="#">6</a>
|
74
|
-
... <a href="#">>></a>
|
75
|
-
<a href="#">Last</a>
|
76
|
-
</div>
|
77
|
-
<div class="space_center">
|
78
|
-
</div>
|
79
66
|
</div>
|
80
67
|
|
81
68
|
|
Binary file
|
@@ -53,7 +53,12 @@
|
|
53
53
|
float: right;
|
54
54
|
right: 0px;
|
55
55
|
padding-right: 10px;
|
56
|
+
display: inline-block;
|
56
57
|
}
|
58
|
+
#representation {
|
59
|
+
display: inline;
|
60
|
+
}
|
61
|
+
|
57
62
|
|
58
63
|
.btn_config {
|
59
64
|
vertical-align: top;
|
@@ -107,5 +112,5 @@
|
|
107
112
|
}
|
108
113
|
|
109
114
|
#new_representation {
|
110
|
-
display: inline;
|
115
|
+
display: inline-block;
|
111
116
|
}
|
@@ -10,9 +10,7 @@ module SocialStream
|
|
10
10
|
end
|
11
11
|
|
12
12
|
can :read, Activity do |a|
|
13
|
-
|
14
|
-
a.tie.relation.name == 'public' ||
|
15
|
-
a.tie.allows?(user, 'read', 'activity')
|
13
|
+
a.tie.allows?(user, 'read', 'activity')
|
16
14
|
end
|
17
15
|
|
18
16
|
can :update, Activity do |a|
|
@@ -11,14 +11,17 @@ module SocialStream
|
|
11
11
|
module InstanceMethods
|
12
12
|
# Current subject represented by the user. Defaults to the own user
|
13
13
|
def current_subject
|
14
|
-
|
15
|
-
|
14
|
+
@current_subject ||=
|
15
|
+
current_subject_from_session ||
|
16
|
+
current_user
|
16
17
|
end
|
17
18
|
|
18
19
|
# Set represented subject
|
19
20
|
def current_subject= instance
|
20
21
|
session[:subject_type] = instance.class.to_s
|
21
22
|
session[:subject_id] = instance.id
|
23
|
+
|
24
|
+
@current_subject = instance
|
22
25
|
end
|
23
26
|
|
24
27
|
private
|
data/social_stream.gemspec
CHANGED
@@ -5,7 +5,8 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.version = SocialStream::VERSION.dup
|
6
6
|
s.summary = "Social networking features and activity streams for Ruby on Rails."
|
7
7
|
s.description = "Ruby on Rails engine supporting social networking features and activity streams."
|
8
|
-
s.authors = ["
|
8
|
+
s.authors = [ "GING - DIT - UPM",
|
9
|
+
"CISE - ESPOL" ]
|
9
10
|
s.homepage = "http://social-stream.dit.upm.es/"
|
10
11
|
s.files = `git ls-files`.split("\n")
|
11
12
|
s.add_runtime_dependency('atd-ancestry', '1.3.0')
|
@@ -17,7 +18,7 @@ Gem::Specification.new do |s|
|
|
17
18
|
s.add_runtime_dependency('paperclip', '~> 2.3.4')
|
18
19
|
s.add_runtime_dependency('jquery-rails', '~> 0.2.5')
|
19
20
|
s.add_runtime_dependency('cancan', '~> 1.4.0')
|
20
|
-
s.add_runtime_dependency('will_paginate', '~>
|
21
|
+
s.add_runtime_dependency('will_paginate', '~> 3.0.pre2')
|
21
22
|
s.add_development_dependency('rails', '~> 3.0.3')
|
22
23
|
s.add_development_dependency('capybara', '~> 0.3.9')
|
23
24
|
s.add_development_dependency('sqlite3-ruby')
|
data/spec/dummy/db/.gitignore
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe TieActivity do
|
4
|
+
describe "for followers" do
|
5
|
+
before do
|
6
|
+
@tie = Factory(:friend)
|
7
|
+
|
8
|
+
@tie_to_sender_friend = Factory(:friend, :receiver => @tie.sender)
|
9
|
+
@tie_to_receiver_friend = Factory(:friend, :receiver => @tie.receiver)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "of a public activity" do
|
13
|
+
before do
|
14
|
+
@a = Factory(:activity, :_tie => @tie.related(@tie.sender.relations.sort.last))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be created" do
|
18
|
+
assert @tie_to_sender_friend.activities.include?(@a)
|
19
|
+
assert @tie_to_receiver_friend.activities.include?(@a)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "of a friend activity" do
|
24
|
+
before do
|
25
|
+
@a = Factory(:activity, :_tie => @tie)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not be created" do
|
29
|
+
assert !@tie_to_sender_friend.activities.include?(@a)
|
30
|
+
assert !@tie_to_receiver_friend.activities.include?(@a)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "one of them being friend" do
|
35
|
+
before do
|
36
|
+
Factory(:friend, :sender => @tie.sender, :receiver => @tie_to_receiver_friend.sender)
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "with a friend activity" do
|
40
|
+
before do
|
41
|
+
@a = Factory(:activity, :_tie => @tie)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should be created for the friend" do
|
45
|
+
assert !@tie_to_sender_friend.activities.include?(@a)
|
46
|
+
assert @tie_to_receiver_friend.activities.include?(@a)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
data/spec/models/tie_spec.rb
CHANGED
@@ -17,18 +17,22 @@ describe Tie do
|
|
17
17
|
tie.should be_valid
|
18
18
|
end
|
19
19
|
|
20
|
-
it "should create pending" do
|
21
|
-
tie = Factory(:friend)
|
22
|
-
|
23
|
-
assert tie.receiver.pending_ties.present?
|
24
|
-
assert tie.receiver.pending_ties.first.relation_set.blank?
|
25
|
-
end
|
26
20
|
|
27
21
|
describe "friend" do
|
28
22
|
before do
|
29
23
|
@tie = Factory(:friend)
|
30
24
|
end
|
31
25
|
|
26
|
+
it "should create pending" do
|
27
|
+
|
28
|
+
assert @tie.receiver.pending_ties.present?
|
29
|
+
assert @tie.receiver.pending_ties.first.relation_set.blank?
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should be following" do
|
33
|
+
assert Tie.following(@tie.receiver_id).include?(@tie)
|
34
|
+
end
|
35
|
+
|
32
36
|
describe ", receiver" do
|
33
37
|
before do
|
34
38
|
@s = @tie.receiver
|
metadata
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
-
|
13
|
+
- GING - DIT - UPM
|
14
|
+
- CISE - ESPOL
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-01-
|
19
|
+
date: 2011-01-25 00:00:00 +01:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
@@ -170,12 +171,12 @@ dependencies:
|
|
170
171
|
requirements:
|
171
172
|
- - ~>
|
172
173
|
- !ruby/object:Gem::Version
|
173
|
-
hash:
|
174
|
+
hash: 270495401
|
174
175
|
segments:
|
175
|
-
- 2
|
176
176
|
- 3
|
177
|
-
-
|
178
|
-
|
177
|
+
- 0
|
178
|
+
- pre2
|
179
|
+
version: 3.0.pre2
|
179
180
|
type: :runtime
|
180
181
|
version_requirements: *id010
|
181
182
|
- !ruby/object:Gem::Dependency
|
@@ -501,6 +502,7 @@ files:
|
|
501
502
|
- lib/generators/social_stream/templates/public/images/btn/time.png
|
502
503
|
- lib/generators/social_stream/templates/public/images/btn/uno.png
|
503
504
|
- lib/generators/social_stream/templates/public/images/btn/viewer.png
|
505
|
+
- lib/generators/social_stream/templates/public/images/favicon.ico
|
504
506
|
- lib/generators/social_stream/templates/public/images/frontpage/collaborate.gif
|
505
507
|
- lib/generators/social_stream/templates/public/images/frontpage/collaborate.png
|
506
508
|
- lib/generators/social_stream/templates/public/images/frontpage/comments.png
|
@@ -656,6 +658,7 @@ files:
|
|
656
658
|
- spec/models/actor_spec.rb
|
657
659
|
- spec/models/post_spec.rb
|
658
660
|
- spec/models/representation_spec.rb
|
661
|
+
- spec/models/tie_activity_spec.rb
|
659
662
|
- spec/models/tie_spec.rb
|
660
663
|
- spec/models/user_spec.rb
|
661
664
|
- spec/social_stream_spec.rb
|