social_stream 0.15.4 → 0.15.5
Sign up to get free protection for your applications and to get access to all the features.
- data/base/app/models/actor.rb +9 -5
- data/base/app/models/contact.rb +9 -2
- data/base/app/models/relation.rb +29 -12
- data/base/app/models/tie.rb +8 -15
- data/base/app/views/groups/_new.html.erb +18 -0
- data/base/app/views/layouts/application.html.erb +1 -0
- data/base/app/views/profiles/edit.html.erb +10 -0
- data/base/lib/social_stream/base/version.rb +1 -1
- data/base/lib/social_stream/models/subject.rb +3 -7
- data/lib/social_stream/version.rb +1 -1
- data/linkser/app/assets/stylesheets/linkser.css.scss +8 -0
- data/linkser/app/controllers/linkser_controller.rb +12 -7
- data/linkser/app/models/link.rb +6 -3
- data/linkser/app/views/links/_error.html.erb +4 -0
- data/linkser/lib/social_stream/linkser/version.rb +1 -1
- data/linkser/social_stream-linkser.gemspec +1 -1
- data/presence/.gitignore +1 -0
- data/presence/app/controllers/xmpp_controller.rb +41 -52
- data/presence/ejabberd/conf/ssconfig_example.cfg +2 -1
- data/presence/ejabberd/ejabberd_files.zip +0 -0
- data/presence/ejabberd/ejabberd_scripts/reset_connection_script +255 -13
- data/presence/ejabberd/ejabberd_scripts/rest_api_client_script +301 -0
- data/presence/ejabberd/ejabberd_scripts/synchronize_presence_script +256 -18
- data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
- data/presence/ejabberd/mod_sspresence/mod_sspresence.erl +10 -10
- data/presence/lib/generators/social_stream/presence/templates/initializer.rb +6 -4
- data/presence/lib/social_stream-presence.rb +2 -0
- data/presence/lib/social_stream/presence/version.rb +1 -1
- data/presence/lib/social_stream/presence/xmpp_server_order.rb +190 -12
- data/presence/lib/tasks/presence/installer.rake +38 -4
- data/social_stream.gemspec +2 -2
- data/spec/support/optimizations.rb +4 -0
- metadata +13 -14
- data/presence/ejabberd/ejabberd_scripts/set_connection_script +0 -48
- data/presence/ejabberd/ejabberd_scripts/set_presence_script +0 -48
- data/presence/ejabberd/ejabberd_scripts/unset_connection_script +0 -48
- data/presence/ejabberd/ejabberd_scripts/unset_presence_script +0 -48
data/base/app/models/actor.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
# An {Actor}
|
1
|
+
# An {Actor} represents a social entity. This includes individuals, but also groups, departments,
|
2
2
|
# organizations even nations or states.
|
3
3
|
#
|
4
|
-
# Actors are the nodes of a social network. Two actors are linked by
|
5
|
-
# type of a {
|
4
|
+
# Actors are the nodes of a social network. Two actors are linked by {Tie Ties}. The
|
5
|
+
# type of a {Tie} is a {Relation}. Each actor can define and customize their relations own
|
6
|
+
# {Relation Relations}.
|
7
|
+
#
|
8
|
+
# Every {Actor} has an Avatar, a {Profile} with personal o group information, contact data, etc.
|
6
9
|
#
|
7
10
|
# = Actor subtypes
|
8
11
|
# An actor subtype is called a {SocialStream::Models::Subject Subject}.
|
9
|
-
# {SocialStream} provides
|
12
|
+
# {SocialStream} provides two actor subtypes, {User} and {Group}, but the
|
10
13
|
# application developer can define as many actor subtypes as required.
|
11
|
-
#
|
14
|
+
# Actor subtypes are added to +config/initializers/social_stream.rb+
|
15
|
+
#
|
12
16
|
#
|
13
17
|
class Actor < ActiveRecord::Base
|
14
18
|
@subtypes_name = :subject
|
data/base/app/models/contact.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# A {Contact} is an ordered pair of {Actor Actors},
|
2
|
+
# and therefore two {SocialStream::Models::Subject Subjects}.
|
2
3
|
#
|
3
|
-
#
|
4
|
+
# {Contact Contacts} are created at convenience (in the case of {Actor#suggestions suggestions},
|
5
|
+
# for instance), and they do not mean that there is a real link between those two
|
6
|
+
# {SocialStream::Models::Subject Subjects}. Link existance is stored as {Tie Ties}.
|
4
7
|
#
|
5
8
|
# = {Contact Contacts} and {Activity activities}
|
9
|
+
#
|
10
|
+
# WARNING: This will be change soon to direct references to author, owner and user_author,
|
11
|
+
# in the same way as {ActivityObject}
|
12
|
+
#
|
6
13
|
# Each {Activity} is attached to a {Contact}. When _Alice_ post in _Bob_'s wall,
|
7
14
|
# the {Activity} is attached to the {Contact} from _Alice_ to _Bob_
|
8
15
|
#
|
data/base/app/models/relation.rb
CHANGED
@@ -1,26 +1,43 @@
|
|
1
|
-
# A relation defines a type of {Tie
|
2
|
-
#
|
3
|
-
# resources (transactions, lending and borrowing),
|
4
|
-
# physical connection and affiliation to same organizations.
|
1
|
+
# A relation defines a type of {Tie} between two {Actor Actors}. From social literature,
|
2
|
+
# {Relation Relations} can be affective (friendship, liking, respect), formal or biological
|
3
|
+
# (authority, kinship), transfer of material resources (transactions, lending and borrowing),
|
4
|
+
# messages or conversations, physical connection and affiliation to same organizations.
|
5
5
|
#
|
6
|
-
# =
|
6
|
+
# = Relation types defined in {SocialStream Social Stream}
|
7
7
|
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
8
|
+
# All the above cases could be supported in {SocialStream Social Stream}.
|
9
|
+
# Nevertheless, the following {Relation Relations} are defined. All of them inherit from the
|
10
|
+
# {Relation} class:
|
11
11
|
#
|
12
|
-
#
|
12
|
+
# {Relation::Custom}:: user-defined {Relation}. Every {SocialStream::Models::Subject Subject}
|
13
|
+
# is able to define their own {Relation::Custom Custom relation},
|
14
|
+
# giving them a custom name
|
15
|
+
# (for instance: friend, colleague, partner, buddy) and {Permission Permissions}.
|
16
|
+
# {Relation::Public}:: default {Relation} for ocassional {Tie Ties}.
|
17
|
+
# {Relation::Reject}:: the {SocialStream::Models::Subject Subject} does not want to add the other
|
18
|
+
# as a contact. A new {Tie} is created using this {Relation}
|
19
|
+
#
|
20
|
+
# You can define new {Relation Relations} in your application. Just create a new class and
|
21
|
+
# inherit from {Relation}. This class already supports
|
22
|
+
# {http://api.rubyonrails.org/classes/ActiveRecord/Base.html#label-Single+table+inheritance Single Table Inheritance (STI)}.
|
23
|
+
#
|
24
|
+
# = Relations and link building
|
25
|
+
#
|
26
|
+
# When a {SocialStream::Models::Subject Subject} creates a new link to other
|
27
|
+
# {SocialStream::Models::Subject Subject}, she must specify one or serveral {Relation Relations}
|
28
|
+
# for that link. (friend, colleague, {Relation::Public} or {Relation::Reject}.
|
29
|
+
# A new {Tie} will be created for each {Relation}
|
13
30
|
#
|
14
31
|
# = Permissions
|
15
32
|
#
|
16
|
-
# {SocialStream::Models::Subject Subjects} assign {Permission permissions} to
|
33
|
+
# {SocialStream::Models::Subject Subjects} assign {Permission permissions} to {Relation Relations}.
|
17
34
|
# This way, when establishing {Tie ties}, they are granting permissions to their contacts.
|
18
35
|
#
|
19
36
|
# See the documentation of {Permission} for more details on permission definition.
|
20
37
|
#
|
21
|
-
# = {Activity Activities} and {Relation
|
38
|
+
# = {Activity Activities} and {Relation Relations}
|
39
|
+
#
|
22
40
|
# Each {Activity} can be attached to one or more {Relation relations}.
|
23
|
-
# The {Relation} sets up the mode in which the {Activity} is shared.
|
24
41
|
# It sets the {Audience} that has access to it, and the {Permission Permissions} that rule that access.
|
25
42
|
#
|
26
43
|
class Relation < ActiveRecord::Base
|
data/base/app/models/tie.rb
CHANGED
@@ -1,25 +1,17 @@
|
|
1
|
-
# A {Tie} is a link between two {Actor Actors}
|
2
|
-
#
|
3
|
-
# The first {Actor} is the sender of the {Tie}. The second {Actor}
|
4
|
-
# is the receiver of the {Tie}.
|
5
|
-
#
|
6
|
-
# = Tie strengh
|
7
|
-
#
|
8
|
-
# Because each {Tie} belongs to a {Relation} and {Relation Relations} have strength
|
9
|
-
# hierarchies, {Tie Ties} also have them. A {Tie} is stronger than other if its
|
10
|
-
# {Relation} is stronger than the other's. For example, if _Alice_ has a _friend_ {Tie}
|
11
|
-
# with _Bob_, and an _acquaintance_ {Tie} with _Charlie_, given that _friend_ {Relation}
|
12
|
-
# is stronger than _acquaintance_, the {Tie} with _Bob_ is stronger than the {Tie} with
|
13
|
-
# _Charlie_.
|
1
|
+
# A {Tie} is a link between two {Actor Actors},
|
2
|
+
# and therefore, two {SocialStream::Models::Subject Subjects}.
|
14
3
|
#
|
4
|
+
# It is made up with a {Contact} and a {Relation}. The {Contact} defines the sender
|
5
|
+
# or {Actor} that declares the link, and the receiver or {Actor} that is pointed by
|
6
|
+
# the declaration. The {Relation} defines the type of link (friend, colleague,
|
7
|
+
# {Relation::Reject}, etc)
|
8
|
+
|
15
9
|
# = Authorization
|
16
10
|
# When an {Actor} establishes a {Tie} with other, she is granting a set of
|
17
11
|
# {Permission Permissions} to them (posting to her wall, reading her posts, etc..)
|
18
12
|
# The set of {Permission Permissions} granted are associated with the {Relation} of
|
19
13
|
# the {Tie}.
|
20
14
|
#
|
21
|
-
# Usually, stronger ties (and relations) have more permissions than weaker ones.
|
22
|
-
#
|
23
15
|
# = Scopes
|
24
16
|
# There are several scopes defined:
|
25
17
|
#
|
@@ -28,6 +20,7 @@
|
|
28
20
|
# sent_or_received_by(actor):: the union of the former
|
29
21
|
# related_by(relation):: ties with this relation. Accepts relation, relation_name,
|
30
22
|
# integer, array
|
23
|
+
#
|
31
24
|
class Tie < ActiveRecord::Base
|
32
25
|
|
33
26
|
belongs_to :contact, :counter_cache => true
|
@@ -9,6 +9,14 @@
|
|
9
9
|
newel: false,
|
10
10
|
height: 6
|
11
11
|
});
|
12
|
+
$("#group_actor_tag_list").fcbkcomplete({
|
13
|
+
json_url: "<%= tags_path(:format => :json) %>",
|
14
|
+
cache: false,
|
15
|
+
filter_case: true,
|
16
|
+
filter_hide: true,
|
17
|
+
newel: false,
|
18
|
+
height: 6
|
19
|
+
});
|
12
20
|
<% end %>
|
13
21
|
|
14
22
|
<%= location(
|
@@ -52,6 +60,16 @@
|
|
52
60
|
<%= f.select :_participants, [], :class => "form_tag" %>
|
53
61
|
</div>
|
54
62
|
</div>
|
63
|
+
<div class="form_row">
|
64
|
+
<div class="form_label" id="form_tags">
|
65
|
+
<%= f.label t('group.tags')%>
|
66
|
+
</div>
|
67
|
+
<div class="form_field">
|
68
|
+
<%= f.fields_for :actor do |actor_form| %>
|
69
|
+
<%= actor_form.select :tag_list, [], :class => "form_tag" %>
|
70
|
+
<%end%>
|
71
|
+
</div>
|
72
|
+
</div>
|
55
73
|
<div class="form_row form_label">
|
56
74
|
<%= f.label :description %>
|
57
75
|
</div>
|
@@ -6,6 +6,7 @@
|
|
6
6
|
<title><%= yield(:title).empty? ? t('site.name') : yield(:title)%></title>
|
7
7
|
<meta name="keywords" content="<%= t('profile.tags.default') %><%= yield(:keywords) %>" >
|
8
8
|
<meta name="description" content= "<%= yield(:description).empty? ? t('frontpage.main_title') : yield(:description) %>" >
|
9
|
+
<meta name="generator" content="SocialStream" />
|
9
10
|
|
10
11
|
<%= stylesheet_link_tag "application" %>
|
11
12
|
<%= javascript_include_tag "application" %>
|
@@ -166,6 +166,16 @@ end %>
|
|
166
166
|
<%= f.text_field :address, :class => "form_tag" %>
|
167
167
|
</div>
|
168
168
|
</div>
|
169
|
+
<%= f.fields_for :actor do |actor_form| %>
|
170
|
+
<div class="form_row">
|
171
|
+
<div class="form_label">
|
172
|
+
<%= actor_form.label t('profile.email')%>
|
173
|
+
</div>
|
174
|
+
<div class="form_field">
|
175
|
+
<%= actor_form.text_field :email, :class => "email form_tag" %>
|
176
|
+
</div>
|
177
|
+
</div>
|
178
|
+
<%end%>
|
169
179
|
<div class="form_row">
|
170
180
|
<div class="form_label">
|
171
181
|
<%= f.label t('profile.website')%>
|
@@ -2,15 +2,11 @@ require 'active_support/concern'
|
|
2
2
|
|
3
3
|
module SocialStream
|
4
4
|
module Models
|
5
|
-
# {Subject Subjects} are subtypes of {Actor}. {SocialStream} provides two
|
5
|
+
# {Subject Subjects} are subtypes of {Actor Actors}. {SocialStream Social Stream} provides two
|
6
6
|
# {Subject Subjects}, {User} and {Group}
|
7
7
|
#
|
8
|
-
# Each {Subject}
|
9
|
-
#
|
10
|
-
# This module provides additional features for models that are subjects,
|
11
|
-
# extending them. Including the module in each {Subject} model is not required!
|
12
|
-
# After declared in +config/initializers/social_stream.rb+, {SocialStream} is
|
13
|
-
# responsible for adding subject features to each model.
|
8
|
+
# Each {Subject} must defined in +config/initializers/social_stream.rb+ in order to be
|
9
|
+
# included in the application.
|
14
10
|
#
|
15
11
|
# = Scopes
|
16
12
|
# There are several scopes available for subjects
|
@@ -2,14 +2,19 @@ class LinkserController < ApplicationController
|
|
2
2
|
def index
|
3
3
|
if params[:url].present?
|
4
4
|
url = params[:url]
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
begin
|
6
|
+
o = Linkser.parse url, {:max_images => 1}
|
7
|
+
if o.is_a? Linkser::Objects::HTML
|
8
|
+
link = Link.new
|
9
|
+
link.fill o
|
10
|
+
render :partial => "links/link_preview", :locals => {:link => link}
|
11
|
+
return
|
12
|
+
end
|
13
|
+
rescue
|
14
|
+
render :partial => "links/error", :locals => {:message => I18n.t("link.errors.loading") + " " + url.to_s}
|
15
|
+
return
|
11
16
|
end
|
12
17
|
end
|
13
|
-
|
18
|
+
render :partial => "links/error", :locals => {:message => I18n.t("link.errors.only_webs")}
|
14
19
|
end
|
15
20
|
end
|
data/linkser/app/models/link.rb
CHANGED
@@ -32,9 +32,12 @@ class Link < ActiveRecord::Base
|
|
32
32
|
|
33
33
|
def check_loaded
|
34
34
|
if !self.loaded.eql? "true" and self.title.nil? and self.description.nil? and self.image.nil?
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
begin
|
36
|
+
o = Linkser.parse self.url, {:max_images => 1}
|
37
|
+
if o.is_a? Linkser::Objects::HTML
|
38
|
+
self.fill o
|
39
|
+
end
|
40
|
+
rescue
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.files = `git ls-files`.split("\n")
|
13
13
|
|
14
14
|
# Gem dependencies
|
15
|
-
s.add_runtime_dependency('social_stream-base', '~> 0.10.
|
15
|
+
s.add_runtime_dependency('social_stream-base', '~> 0.10.8')
|
16
16
|
s.add_runtime_dependency('linkser', '~> 0.0.7')
|
17
17
|
# Development Gem dependencies
|
18
18
|
s.add_development_dependency('sqlite3-ruby')
|
data/presence/.gitignore
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
class XmppController < ApplicationController
|
2
2
|
|
3
|
+
before_filter :authorization, :only => [:setConnection, :unsetConecction, :setPresence, :unsetPresence, :resetConnection, :synchronizePresence ]
|
4
|
+
|
3
5
|
#Mapping XMPP Standar Status to Social Stream Chat Status
|
4
6
|
STATUS = {
|
5
7
|
'' => 'available',
|
@@ -10,14 +12,12 @@ class XmppController < ApplicationController
|
|
10
12
|
}
|
11
13
|
|
12
14
|
|
13
|
-
|
15
|
+
##############################
|
16
|
+
########## REST API ##########
|
17
|
+
##############################
|
14
18
|
|
15
|
-
def setConnection
|
16
|
-
|
17
|
-
render :text => "Authorization error"
|
18
|
-
return
|
19
|
-
end
|
20
|
-
|
19
|
+
def setConnection
|
20
|
+
params = @dparams
|
21
21
|
user = User.find_by_slug(params[:name])
|
22
22
|
|
23
23
|
if user && !user.connected
|
@@ -28,16 +28,12 @@ class XmppController < ApplicationController
|
|
28
28
|
return
|
29
29
|
end
|
30
30
|
|
31
|
-
render :text => "
|
31
|
+
render :text => "Ok: The user was already connected"
|
32
32
|
end
|
33
33
|
|
34
34
|
|
35
35
|
def unsetConecction
|
36
|
-
|
37
|
-
render :text => "Authorization error"
|
38
|
-
return
|
39
|
-
end
|
40
|
-
|
36
|
+
params = @dparams
|
41
37
|
user = User.find_by_slug(params[:name])
|
42
38
|
|
43
39
|
if user && user.connected
|
@@ -47,16 +43,12 @@ class XmppController < ApplicationController
|
|
47
43
|
return
|
48
44
|
end
|
49
45
|
|
50
|
-
render :text => "
|
46
|
+
render :text => "Ok: The user was already disconnected"
|
51
47
|
end
|
52
48
|
|
53
49
|
|
54
|
-
def setPresence
|
55
|
-
|
56
|
-
render :text => "Authorization error"
|
57
|
-
return
|
58
|
-
end
|
59
|
-
|
50
|
+
def setPresence
|
51
|
+
params = @dparams
|
60
52
|
user = User.find_by_slug(params[:name])
|
61
53
|
status = params[:status]
|
62
54
|
|
@@ -65,20 +57,16 @@ class XmppController < ApplicationController
|
|
65
57
|
user.connected = true
|
66
58
|
user.save!
|
67
59
|
end
|
68
|
-
render :text =>
|
60
|
+
render :text => "Ok: Status changed"
|
69
61
|
else
|
70
|
-
render :text =>
|
62
|
+
render :text => "Ok: Status not changed"
|
71
63
|
end
|
72
64
|
|
73
65
|
end
|
74
66
|
|
75
67
|
|
76
|
-
def unsetPresence
|
77
|
-
|
78
|
-
render :text => "Authorization error"
|
79
|
-
return
|
80
|
-
end
|
81
|
-
|
68
|
+
def unsetPresence
|
69
|
+
params = @dparams
|
82
70
|
user = User.find_by_slug(params[:name])
|
83
71
|
|
84
72
|
if user && user.connected
|
@@ -88,44 +76,36 @@ class XmppController < ApplicationController
|
|
88
76
|
return
|
89
77
|
end
|
90
78
|
|
91
|
-
render :text => "
|
79
|
+
render :text => "Ok: The user was already disconnected"
|
92
80
|
end
|
93
81
|
|
94
82
|
|
95
83
|
def resetConnection
|
96
|
-
unless authorization
|
97
|
-
render :text => "Authorization error"
|
98
|
-
return
|
99
|
-
end
|
100
|
-
|
101
84
|
SocialStream::Presence::XmppServerOrder::resetPresence
|
102
|
-
|
103
85
|
render :text => "Ok"
|
104
86
|
end
|
105
87
|
|
106
88
|
|
107
|
-
def synchronizePresence
|
108
|
-
|
109
|
-
|
89
|
+
def synchronizePresence
|
90
|
+
params = @dparams
|
91
|
+
|
92
|
+
#Work without encrypted params
|
93
|
+
if params[:name] == nil or params[:name].empty? or params[:name]==""
|
94
|
+
render :text => "Ok: No users received"
|
110
95
|
return
|
111
|
-
end
|
112
|
-
|
113
|
-
#Actual connected users
|
114
|
-
user_slugs = params[:name]
|
96
|
+
end
|
115
97
|
|
98
|
+
#Actual connected users
|
99
|
+
user_slugs = params[:name].split(",")
|
116
100
|
SocialStream::Presence::XmppServerOrder::synchronizePresenceForSlugs(user_slugs)
|
117
|
-
|
118
|
-
render :text => "ok"
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
def authorization
|
123
|
-
return params[:password] == SocialStream::Presence.xmpp_server_password
|
101
|
+
render :text => "Ok"
|
124
102
|
end
|
125
103
|
|
126
104
|
|
127
|
-
|
128
|
-
|
105
|
+
|
106
|
+
#OPEN METHODS
|
107
|
+
|
108
|
+
def chatWindow
|
129
109
|
if current_user and current_user.chat_enabled and (params[:userConnected]=="true")
|
130
110
|
render :partial => 'chat/contacts'
|
131
111
|
elsif current_user and current_user.chat_enabled
|
@@ -183,7 +163,7 @@ class XmppController < ApplicationController
|
|
183
163
|
private
|
184
164
|
|
185
165
|
def setStatus(user,status)
|
186
|
-
if user and status and user.status != status
|
166
|
+
if user and status and validStatus(status) and user.status != STATUS[status]
|
187
167
|
user.status = STATUS[status]
|
188
168
|
user.save!
|
189
169
|
return true
|
@@ -195,4 +175,13 @@ class XmppController < ApplicationController
|
|
195
175
|
return STATUS.keys.include?(status)
|
196
176
|
end
|
197
177
|
|
178
|
+
|
179
|
+
#Authorization to use REST API
|
180
|
+
def authorization
|
181
|
+
unless SocialStream::Presence::XmppServerOrder::authorization(params)
|
182
|
+
render :text => "Authorization error"
|
183
|
+
end
|
184
|
+
@dparams = SocialStream::Presence::XmppServerOrder::decryptParams(params)
|
185
|
+
end
|
186
|
+
|
198
187
|
end
|