social_stream 0.21.4 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -5
- data/base/app/assets/stylesheets/cheesecake.css.scss +1 -0
- data/base/app/views/cheesecake/_cheesecake.html.erb +3 -0
- data/base/app/views/cheesecake/_index.html.erb +88 -41
- data/base/app/views/cheesecake/_sector_form.html.erb +12 -12
- data/base/lib/social_stream/base/version.rb +1 -1
- data/base/lib/social_stream/test_helpers/controllers.rb +19 -2
- data/base/lib/tasks/db/populate.rake +190 -165
- data/base/social_stream-base.gemspec +1 -1
- data/base/spec/controllers/posts_controller_spec.rb +19 -1
- data/lib/social_stream/version.rb +1 -1
- data/presence/app/assets/images/status/chat.png +0 -0
- data/presence/app/assets/javascripts/chat_interface_manager.js.erb +42 -45
- data/presence/app/assets/javascripts/chat_parser.js +5 -5
- data/presence/app/assets/javascripts/chat_persistence.js +25 -26
- data/presence/app/assets/javascripts/chat_utilities.js +15 -11
- data/presence/app/assets/javascripts/chat_window_manager.js +129 -26
- data/presence/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +22 -3
- data/presence/app/assets/javascripts/social_stream-presence.js +1 -0
- data/presence/app/assets/javascripts/videochat.js.erb +459 -0
- data/presence/app/assets/javascripts/xmpp_client_management.js.erb +303 -65
- data/presence/app/assets/stylesheets/chat.css.scss +42 -1
- data/presence/app/controllers/xmpp_controller.rb +20 -3
- data/presence/app/views/chat/_index.html.erb +7 -2
- data/presence/app/views/xmpp/getOpenTokSessionIDAndToken.xml.builder +6 -0
- data/presence/config/locales/en.yml +22 -1
- data/presence/config/locales/es.yml +23 -2
- data/presence/config/routes.rb +2 -0
- data/presence/ejabberd/conf/ssconfig_example.cfg +4 -3
- data/presence/ejabberd/ejabberd_files.zip +0 -0
- data/presence/ejabberd/ejabberd_scripts/authentication_script +22 -12
- data/presence/ejabberd/ejabberd_scripts/development_scripts/show_config.sh +9 -10
- data/presence/ejabberd/ejabberd_scripts/emanagement +275 -178
- data/presence/ejabberd/ejabberd_scripts/manageWebDomains +164 -0
- data/presence/ejabberd/ejabberd_scripts/rest_api_client_script +75 -32
- data/presence/ejabberd/ejabberd_scripts/synchronize_presence_script +81 -34
- data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
- data/presence/ejabberd/mod_sspresence/mod_sspresence.erl +27 -23
- data/presence/lib/OpenTok/Exceptions.rb +11 -0
- data/presence/lib/OpenTok/OpenTokSDK.rb +184 -0
- data/presence/lib/OpenTok/Session.rb +27 -0
- data/presence/lib/generators/social_stream/presence/templates/initializer.rb +8 -2
- data/presence/lib/open_tok.rb +31 -0
- data/presence/lib/opentok.rb +29 -0
- data/presence/lib/social_stream-presence.rb +4 -0
- data/presence/lib/social_stream/presence/models/buddy_manager.rb +1 -1
- data/presence/lib/social_stream/presence/version.rb +1 -1
- data/presence/lib/social_stream/presence/xmpp_server_order.rb +96 -76
- data/presence/lib/social_stream/presence/xmpp_ssclient.rb +54 -0
- data/presence/lib/tasks/presence/multidomain.rake +45 -0
- data/presence/lib/tasks/presence/synchronize.rake +18 -4
- data/presence/vendor/assets/javascripts/TB.min.js +4329 -0
- data/social_stream.gemspec +2 -2
- metadata +40 -30
- data/presence/ejabberd/ejabberd_scripts/reset_connection_script +0 -300
- data/presence/ejabberd/ejabberd_scripts/set_script_header.sh +0 -112
data/README.rdoc
CHANGED
@@ -30,7 +30,7 @@ add your own activities easily.
|
|
30
30
|
|
31
31
|
= Installation
|
32
32
|
|
33
|
-
Add to your
|
33
|
+
Add the following to the Gemfile of the your Rails application:
|
34
34
|
|
35
35
|
gem 'social_stream', '>= 0.19.0'
|
36
36
|
|
@@ -50,12 +50,16 @@ Since {Social Stream}[http://github.com/ging/social_stream] depends on {Devise}[
|
|
50
50
|
|
51
51
|
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
52
52
|
|
53
|
-
= Social Stream
|
53
|
+
= Social Stream components
|
54
54
|
|
55
|
-
Social Stream is divided
|
56
|
-
network with the functionalities they need for each case.
|
55
|
+
Social Stream is divided into components. Developers can customize their social
|
56
|
+
network with the functionalities they need for each case. For instance, the Gemfile
|
57
|
+
in an application using documents and links only would contain the following:
|
57
58
|
|
58
|
-
|
59
|
+
gem 'social_stream-documents'
|
60
|
+
gem 'social_stream-linkser'
|
61
|
+
|
62
|
+
Current Social Stream distribution include the following components:
|
59
63
|
|
60
64
|
* {Base}[https://github.com/ging/social_stream/tree/master/base], basic functionalities of contacts, streams and walls,
|
61
65
|
along with users, group, post and comments
|
@@ -69,6 +73,8 @@ Current Social Stream distribution includes:
|
|
69
73
|
|
70
74
|
{Social Stream documentation is available at rdoc.info}[http://rubydoc.info/gems/social_stream/frames]
|
71
75
|
|
76
|
+
However, most of the documentation is in {the base gem}[http://rubydoc.info/gems/social_stream-base/frames].
|
77
|
+
|
72
78
|
= Discussion
|
73
79
|
|
74
80
|
We are reaching beta phase of development.
|
@@ -73,6 +73,9 @@ $(function(){
|
|
73
73
|
$("#sector_editor").data("hide")();
|
74
74
|
}
|
75
75
|
};
|
76
|
+
cheese.onSubsectorAdded = function(subsector){
|
77
|
+
$("#sector_editor").data("prepare")(subsector.getCheesecake(),subsector);
|
78
|
+
};
|
76
79
|
$("#contacts_filter_input").keyup(function(){
|
77
80
|
cheese.searchEngine.filter($("#contacts_filter_input").val());
|
78
81
|
//TODO: Make users unfiltered visible again
|
@@ -119,18 +119,20 @@
|
|
119
119
|
});
|
120
120
|
});
|
121
121
|
$("#sector_editor").data("hide", function(callback){
|
122
|
-
$("#sector_editor").stop().animate({width: 0},500
|
123
|
-
$(".add_subsector_clone").remove();
|
124
|
-
});
|
122
|
+
$("#sector_editor").stop().animate({width: 0},500);
|
125
123
|
$("#contacts_explorer").stop().animate({width: 300},500, function(){
|
126
124
|
if(callback) callback();
|
127
125
|
});
|
128
126
|
});
|
129
|
-
$("#sector_editor").data("prepare", function(cheese){
|
127
|
+
$("#sector_editor").data("prepare", function(cheese, newSubsector){
|
130
128
|
var sector = cheese.getFocusedSector();
|
131
|
-
var
|
132
|
-
|
129
|
+
var newIndex = -1;
|
130
|
+
if(newSubsector){
|
131
|
+
newIndex = newSubsector.getIndex();
|
132
|
+
}
|
133
133
|
if(sector){
|
134
|
+
var subsector_count = sector.subsectors.length;
|
135
|
+
var maxReached = (subsector_count==4);
|
134
136
|
$("#form_sector_name").val(sector.label);
|
135
137
|
$("#edited_sector_name").html(sector.label);
|
136
138
|
$("#form_sector_name").off("keyup");
|
@@ -138,44 +140,89 @@
|
|
138
140
|
$("#edited_sector_name").html($("#form_sector_name").val());
|
139
141
|
sector.changeLabel($("#form_sector_name").val());
|
140
142
|
});
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
if(
|
159
|
-
$("
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
$("
|
164
|
-
$("." + label_class).find(".positive_message").hide();
|
165
|
-
$("." + label_class).find(".negative_message").show();
|
143
|
+
if(maxReached){
|
144
|
+
$(".add_subsector").each(function(){
|
145
|
+
if($(this).is(':visible')){
|
146
|
+
$(this).slideToggle();
|
147
|
+
}
|
148
|
+
})
|
149
|
+
}
|
150
|
+
for(var i = 3; i >= 0; i--){
|
151
|
+
(function(){
|
152
|
+
var subsector = sector.subsectors[i];
|
153
|
+
var index = i;
|
154
|
+
var recentlyCreated = (newIndex != -1)&&(newIndex == index);
|
155
|
+
if(subsector){
|
156
|
+
if(!$("#subsector_" + i).is(':visible')){
|
157
|
+
$("#subsector_" + i).slideToggle();
|
158
|
+
}
|
159
|
+
if(recentlyCreated || ((newIndex == -1)&&(i == 0))){
|
160
|
+
if(!$("#subsector_" + i).find(".content").is(':visible')){
|
161
|
+
$("#subsector_" + i).find(".content").slideToggle();
|
162
|
+
}
|
163
|
+
}else{
|
164
|
+
if($("#subsector_" + i).find(".content").is(':visible')){
|
165
|
+
$("#subsector_" + i).find(".content").slideToggle();
|
166
166
|
}
|
167
167
|
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
168
|
+
if(!maxReached){
|
169
|
+
if(sector.subsectors[i+1]==undefined){
|
170
|
+
$("#add_subsector_" + (i+1)).off("click");
|
171
|
+
if(!$("#add_subsector_" + (i+1)).is(':visible')){
|
172
|
+
$("#add_subsector_" + (i+1)).slideToggle();
|
173
|
+
}
|
174
|
+
$("#add_subsector_" + (i+1)).on("click",function(){
|
175
|
+
cheese.addNewSubsector(index+1);
|
176
|
+
$(".subsector .content").each(function(){
|
177
|
+
if($(this).is(':visible')){
|
178
|
+
$(this).slideToggle();
|
179
|
+
}
|
180
|
+
});
|
181
|
+
});
|
182
|
+
}
|
183
|
+
$("#add_subsector_" + i).off("click");
|
184
|
+
if(!$("#add_subsector_" + i).is(':visible')){
|
185
|
+
$("#add_subsector_" + i).slideToggle();
|
186
|
+
}
|
187
|
+
$("#add_subsector_" + i).on("click",function(){
|
188
|
+
cheese.addNewSubsector(index);
|
189
|
+
$(".subsector .content").each(function(){
|
190
|
+
if($(this).is(':visible')){
|
191
|
+
$(this).slideToggle();
|
192
|
+
}
|
193
|
+
});
|
194
|
+
});
|
195
|
+
}
|
196
|
+
$("#form_subsector_name_" + i).val(subsector.label);
|
197
|
+
$("#edited_subsector_name_" + i).html(subsector.label);
|
198
|
+
$("#form_subsector_name_" + i).off("keyup");
|
199
|
+
$("#form_subsector_name_" + i).on("keyup", [i,subsector],function(event){
|
200
|
+
$("#edited_subsector_name_" + event.data[0]).html($("#form_subsector_name_" + event.data[0]).val());
|
201
|
+
event.data[1].changeLabel($("#form_subsector_name_" + event.data[0]).val());
|
202
|
+
});
|
203
|
+
$("#subsector_" + i).find(".permissions_field .permission").each(function(){
|
204
|
+
var permission_field = $(this);
|
205
|
+
var update_state = function(){
|
206
|
+
var label_class = permission_field.attr("id").replace("form_", "edited_");
|
207
|
+
if(permission_field.is(":checked")){
|
208
|
+
$("." + label_class).removeClass("negative").addClass("positive");
|
209
|
+
$("." + label_class).find(".negative_message").hide();
|
210
|
+
$("." + label_class).find(".positive_message").show();
|
211
|
+
}else{
|
212
|
+
$("." + label_class).removeClass("positive").addClass("negative");
|
213
|
+
$("." + label_class).find(".positive_message").hide();
|
214
|
+
$("." + label_class).find(".negative_message").show();
|
215
|
+
}
|
216
|
+
}
|
217
|
+
update_state();
|
218
|
+
permission_field.on("change",update_state);
|
219
|
+
});
|
220
|
+
}else{
|
221
|
+
$("#subsector_" + i).hide();
|
222
|
+
$("#add_subsector_" + i).off("click");
|
223
|
+
$("#add_subsector_" + i).hide();
|
176
224
|
}
|
177
|
-
|
178
|
-
}
|
225
|
+
})();
|
179
226
|
}
|
180
227
|
}
|
181
228
|
});
|
@@ -20,13 +20,8 @@
|
|
20
20
|
<div id="edited_sector_color_in"></div>
|
21
21
|
</div>
|
22
22
|
</div>
|
23
|
-
</div>
|
24
|
-
|
25
|
-
<div class="add_subsector">
|
26
|
-
+
|
27
|
-
</div>
|
28
|
-
</div>
|
29
|
-
<% for i in 0..3 do %>
|
23
|
+
</div>
|
24
|
+
<% 3.downto(0) do |i|%>
|
30
25
|
<div class="form_row less_padding">
|
31
26
|
<div class="subsector" id="subsector_<%= i %>">
|
32
27
|
<div class="title">
|
@@ -48,17 +43,17 @@
|
|
48
43
|
</div>
|
49
44
|
<div class="form_row less_padding">
|
50
45
|
<div class="form_field permissions_field">
|
51
|
-
<% default_permissions.each_with_index do |p,
|
46
|
+
<% default_permissions.each_with_index do |p, j| %>
|
52
47
|
<div contain=<%= dom_id p %> class="checkboxPermissionOptionLeft">
|
53
|
-
<input id="form_subsector_<%=
|
54
|
-
<label for="form_subsector_<%=
|
48
|
+
<input id="form_subsector_<%= j %>_<%= dom_id p %>" class="permission <%= dom_id p %>" type="checkbox"/>
|
49
|
+
<label for="form_subsector_<%= j %>_<%= dom_id p %>"><%= p.description(:brief, :relation => "%RELATION_NAME%", :subject => current_subject) %></label>
|
55
50
|
<div class="clearfloat"></div>
|
56
51
|
</div>
|
57
52
|
<% end %>
|
58
53
|
</div>
|
59
54
|
<div class="permissions_explanation" style="display:none;">
|
60
|
-
<% default_permissions.each_with_index do |p,
|
61
|
-
<div class="permission <%= dom_id p %> positive edited_subsector_<%=
|
55
|
+
<% default_permissions.each_with_index do |p, j| %>
|
56
|
+
<div class="permission <%= dom_id p %> positive edited_subsector_<%= j %>_<%= dom_id p %>">
|
62
57
|
<div class="positive_message">
|
63
58
|
<%= p.description(:detailed, :relation => "%RELATION_NAME%", :subject => current_subject, :state => "positive") %>
|
64
59
|
</div>
|
@@ -72,6 +67,11 @@
|
|
72
67
|
</div>
|
73
68
|
</div>
|
74
69
|
</div>
|
70
|
+
<div class="form_row less_padding">
|
71
|
+
<div class="add_subsector" id="add_subsector_<%= i %>">
|
72
|
+
+
|
73
|
+
</div>
|
74
|
+
</div>
|
75
75
|
<% end %>
|
76
76
|
</div>
|
77
77
|
</form>
|
@@ -33,9 +33,7 @@ module SocialStream
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def model_assigned_to contact, relation_ids
|
36
|
-
model_attributes[:author_id] = contact.sender.id
|
37
36
|
model_attributes[:owner_id] = contact.receiver.id
|
38
|
-
model_attributes[:user_author_id] = contact.sender.id
|
39
37
|
model_attributes[:_relation_ids] = Array(relation_ids).map(&:id)
|
40
38
|
end
|
41
39
|
|
@@ -67,6 +65,25 @@ module SocialStream
|
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
68
|
+
shared_examples_for "Allow Reading" do
|
69
|
+
it "should read" do
|
70
|
+
get :show, :id => @current_model.to_param
|
71
|
+
|
72
|
+
response.should be_success
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
shared_examples_for "Deny Reading" do
|
77
|
+
it "should not read" do
|
78
|
+
begin
|
79
|
+
get :show, :id => @current_model.to_param
|
80
|
+
|
81
|
+
assert false
|
82
|
+
rescue CanCan::AccessDenied
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
70
87
|
shared_examples_for "Allow Updating" do
|
71
88
|
it "should update" do
|
72
89
|
put :update, updating_attributes
|
@@ -7,73 +7,45 @@ namespace :db do
|
|
7
7
|
desc "Reload populate data"
|
8
8
|
task :reload => [ 'db:reset', :create ]
|
9
9
|
|
10
|
+
desc "Reload populate data for Cheesecake testing"
|
11
|
+
task :cheesecake => [ 'db:reset', :read_environment, :create_users, :create_groups, :create_cheesecake_ties, :create_avatars ]
|
12
|
+
|
10
13
|
desc "Create populate data"
|
11
|
-
task :create => :
|
14
|
+
task :create => [ :read_environment, :create_users, :create_groups, :create_ties, :create_posts, :create_messages, :create_avatars ]
|
15
|
+
|
16
|
+
desc "INTERNAL: read needed environment data and setup variables"
|
17
|
+
task :read_environment => :environment do
|
12
18
|
require 'forgery'
|
13
19
|
|
14
|
-
LOGOS_PATH = File.join(Rails.root, 'lib', 'logos')
|
15
|
-
LOGOS_TOTAL = (ENV["LOGOS_TOTAL"] || 10).to_i
|
16
|
-
USERS = (ENV["USERS"] || 9).to_i
|
17
|
-
GROUPS = (ENV["GROUPS"] || 10).to_i
|
18
|
-
CHEESECAKE = (ENV["CHEESECAKE"].present? || false)
|
19
|
-
if CHEESECAKE
|
20
|
-
puts "Cheesecake Testing mode: ON"
|
21
|
-
end
|
20
|
+
@LOGOS_PATH = File.join(Rails.root, 'lib', 'logos')
|
21
|
+
@LOGOS_TOTAL = (ENV["LOGOS_TOTAL"] || 10).to_i
|
22
|
+
@USERS = (ENV["USERS"] || 9).to_i
|
23
|
+
@GROUPS = (ENV["GROUPS"] || 10).to_i
|
22
24
|
if ENV["HARDCORE"].present?
|
23
|
-
USERS = 999
|
24
|
-
GROUPS = 1000
|
25
|
+
@USERS = 999
|
26
|
+
@GROUPS = 1000
|
25
27
|
puts "Hardcore mode: ON (May the Force be with you brave Padawan)"
|
26
|
-
if CHEESECAKE
|
27
|
-
puts "WARNING: Hardcore and Cheesecake Modes activated. This situation is really slow. Please, avoid it."
|
28
|
-
end
|
29
28
|
end
|
30
|
-
if USERS < 9
|
31
|
-
USERS = 9
|
29
|
+
if @USERS < 9
|
30
|
+
@USERS = 9
|
32
31
|
puts "WARNING: There should be at least 10 users (Demo user and 9 more). Changing USERS to 9."
|
33
32
|
end
|
34
|
-
if GROUPS < 10
|
35
|
-
GROUPS = 10
|
33
|
+
if @GROUPS < 10
|
34
|
+
@GROUPS = 10
|
36
35
|
puts "WARNING: There should be at least 10 groups. Changing GROUPS to 10."
|
37
36
|
end
|
38
37
|
|
39
38
|
Mailboxer.setup do |config|
|
40
39
|
config.uses_emails = false
|
41
40
|
end
|
41
|
+
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
avatar = Dir[File.join(LOGOS_PATH, klass.to_s.tableize, "#{ rand(LOGOS_TOTAL) + 1 }.*")].first
|
48
|
-
else
|
49
|
-
logo = Dir[File.join(LOGOS_PATH, klass.to_s.tableize, "#{ i.id }.*")].first
|
50
|
-
avatar = Dir[File.join(LOGOS_PATH, klass.to_s.tableize, "#{ i.id }.*")].first
|
51
|
-
end
|
52
|
-
|
53
|
-
if avatar.present? && File.exists?(avatar)
|
54
|
-
Avatar.copy_to_temp_file(avatar)
|
55
|
-
dimensions = Avatar.get_image_dimensions(avatar)
|
56
|
-
l = Avatar.new(:actor => i.actor,:logo => File.open(avatar), :name => File.basename(avatar), :crop_x => 0, :crop_y => 0, :crop_w => dimensions[:width], :crop_h => dimensions[:height] )
|
57
|
-
l.active = true
|
58
|
-
l.save!
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def set_tags(klass)
|
64
|
-
klass.all.each do |el|
|
65
|
-
el.tag_list = Forgery::LoremIpsum.words(1,:random => true)+", "+
|
66
|
-
Forgery::LoremIpsum.words(1,:random => true)+", "+
|
67
|
-
Forgery::LoremIpsum.words(1,:random => true)
|
68
|
-
el.save!
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
puts 'User population (Demo and ' + USERS.to_s + ' users more)'
|
43
|
+
# USERS
|
44
|
+
desc "Create users"
|
45
|
+
task :create_users => :read_environment do
|
46
|
+
puts 'User population (Demo and ' + @USERS.to_s + ' users more)'
|
73
47
|
users_start = Time.now
|
74
48
|
|
75
|
-
# = Users
|
76
|
-
|
77
49
|
# Create demo user if not present
|
78
50
|
if User.find_by_name('demo').blank?
|
79
51
|
User.create! :name => 'Demo',
|
@@ -82,27 +54,39 @@ namespace :db do
|
|
82
54
|
:password_confirmation => 'demonstration'
|
83
55
|
end
|
84
56
|
|
85
|
-
|
86
|
-
|
87
|
-
USERS.times do
|
57
|
+
@USERS.times do
|
88
58
|
User.create! :name => Forgery::Name.full_name,
|
89
59
|
:email => Forgery::Internet.email_address,
|
90
60
|
:password => 'demonstration',
|
91
61
|
:password_confirmation => 'demonstration'
|
92
62
|
end
|
93
63
|
|
64
|
+
# Reload actors to include new users
|
65
|
+
@available_actors = Actor.all
|
94
66
|
|
95
67
|
users_end = Time.now
|
96
68
|
puts ' -> ' + (users_end - users_start).round(4).to_s + 's'
|
69
|
+
end
|
70
|
+
|
97
71
|
|
98
|
-
|
72
|
+
# GROUPS
|
73
|
+
desc "Create groups"
|
74
|
+
task :create_groups => :read_environment do
|
75
|
+
puts 'Groups population (' + @GROUPS.to_s + ' groups)'
|
99
76
|
groups_start = Time.now
|
100
77
|
|
101
|
-
|
102
|
-
|
78
|
+
def set_tags(klass)
|
79
|
+
klass.all.each do |el|
|
80
|
+
el.tag_list = Forgery::LoremIpsum.words(1,:random => true)+", "+
|
81
|
+
Forgery::LoremIpsum.words(1,:random => true)+", "+
|
82
|
+
Forgery::LoremIpsum.words(1,:random => true)
|
83
|
+
el.save!
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
103
87
|
|
104
|
-
GROUPS.times do
|
105
|
-
founder = available_actors[rand(available_actors.size)]
|
88
|
+
@GROUPS.times do
|
89
|
+
founder = @available_actors[rand(@available_actors.size)]
|
106
90
|
|
107
91
|
Group.create! :name => Forgery::Name.company_name,
|
108
92
|
:email => Forgery::Internet.email_address,
|
@@ -112,147 +96,188 @@ namespace :db do
|
|
112
96
|
|
113
97
|
set_tags(Group)
|
114
98
|
|
99
|
+
# Reload actors to include groups
|
100
|
+
@available_actors = Actor.all
|
101
|
+
|
115
102
|
groups_end = Time.now
|
116
103
|
puts ' -> ' + (groups_end - groups_start).round(4).to_s + 's'
|
104
|
+
end
|
117
105
|
|
118
106
|
|
107
|
+
# TIES
|
108
|
+
desc "Create ties"
|
109
|
+
task :create_ties => :read_environment do
|
119
110
|
puts 'Ties population'
|
120
111
|
ties_start = Time.now
|
121
112
|
|
122
|
-
|
123
|
-
|
113
|
+
@available_actors.each do |a|
|
114
|
+
actors = @available_actors.dup - Array(a)
|
115
|
+
relations = a.relation_customs + Array.wrap(Relation::Reject.instance)
|
116
|
+
break if actors.size==0
|
117
|
+
Forgery::Basic.number(:at_most => actors.size).times do
|
118
|
+
actor = actors.delete_at((rand * actors.size).to_i)
|
119
|
+
contact = a.contact_to!(actor)
|
120
|
+
contact.user_author = a.user_author if a.subject_type != "User"
|
121
|
+
contact.relation_ids = Array(Forgery::Extensions::Array.new(relations).random.id) unless a==actor
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
ties_end = Time.now
|
126
|
+
puts ' -> ' + (ties_end - ties_start).round(4).to_s + 's'
|
127
|
+
end
|
124
128
|
|
125
|
-
|
126
|
-
|
127
|
-
|
129
|
+
|
130
|
+
# TIES, special version for cheesecake testing
|
131
|
+
desc "Create cheesecake ties"
|
132
|
+
task :create_cheesecake_ties => :read_environment do
|
133
|
+
puts 'Ties population (Cheesecake version)'
|
134
|
+
ties_start = Time.now
|
135
|
+
|
136
|
+
@available_actors.each do |a|
|
137
|
+
actors = @available_actors.dup - Array(a)
|
128
138
|
relations = a.relation_customs + Array.wrap(Relation::Reject.instance)
|
129
|
-
break if actors.size==0
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
contact.relation_ids = Array(Forgery::Extensions::Array.new(actor.relation_customs).random.id)
|
142
|
-
end
|
143
|
-
else
|
144
|
-
Forgery::Basic.number(:at_most => actors.size).times do
|
145
|
-
actor = actors.delete_at((rand * actors.size).to_i)
|
146
|
-
contact = a.contact_to!(actor)
|
147
|
-
contact.user_author = a.user_author if a.subject_type != "User"
|
148
|
-
contact.relation_ids = Array(Forgery::Extensions::Array.new(relations).random.id) unless a==actor
|
149
|
-
end
|
139
|
+
break if actors.size==0
|
140
|
+
actor = Actor.first
|
141
|
+
unless a==actor
|
142
|
+
puts a.name + " connecting with " + actor.name
|
143
|
+
# DRY! :-S
|
144
|
+
contact = a.contact_to!(actor)
|
145
|
+
contact.user_author = a.user_author if a.subject_type != "User"
|
146
|
+
contact.relation_ids = Array(Forgery::Extensions::Array.new(a.relation_customs).random.id)
|
147
|
+
|
148
|
+
contact = actor.contact_to!(a)
|
149
|
+
contact.user_author = actor.user_author if actor.subject_type != "User"
|
150
|
+
contact.relation_ids = Array(Forgery::Extensions::Array.new(actor.relation_customs).random.id)
|
150
151
|
end
|
151
152
|
end
|
152
153
|
|
153
154
|
ties_end = Time.now
|
154
155
|
puts ' -> ' + (ties_end - ties_start).round(4).to_s + 's'
|
156
|
+
end
|
155
157
|
|
156
|
-
|
158
|
+
|
159
|
+
# POSTS
|
160
|
+
desc "Create posts"
|
161
|
+
task :create_posts => :read_environment do
|
157
162
|
puts 'Post population'
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
:updated_at => p.updated_at)
|
179
|
-
end
|
180
|
-
|
181
|
-
posts_end = Time.now
|
182
|
-
puts ' -> ' + (posts_end - posts_start).round(4).to_s + 's'
|
183
|
-
else
|
184
|
-
puts ' -> Cheesecake Testing Mode. Avoiding Post Population.'
|
163
|
+
posts_start = Time.now
|
164
|
+
|
165
|
+
SocialStream::Populate.power_law(Tie.all) do |t|
|
166
|
+
updated = Time.at(rand(Time.now.to_i))
|
167
|
+
|
168
|
+
author = t.sender
|
169
|
+
owner = t.receiver
|
170
|
+
user_author = ( t.sender.subject_type == "User" ? t.sender : t.sender.user_author )
|
171
|
+
|
172
|
+
p = Post.create :text =>
|
173
|
+
"This post sActorhould be for #{ t.relation.name } of #{ t.sender.name }.\n#{ Forgery::LoremIpsum.paragraph(:random => true) }",
|
174
|
+
:created_at => Time.at(rand(updated.to_i)),
|
175
|
+
:updated_at => updated,
|
176
|
+
:author_id => author.id,
|
177
|
+
:owner_id => owner.id,
|
178
|
+
:user_author_id => user_author.id,
|
179
|
+
:_relation_ids => Array(t.relation_id)
|
180
|
+
|
181
|
+
p.post_activity.update_attributes(:created_at => p.created_at,
|
182
|
+
:updated_at => p.updated_at)
|
185
183
|
end
|
186
184
|
|
187
|
-
|
185
|
+
posts_end = Time.now
|
186
|
+
puts ' -> ' + (posts_end - posts_start).round(4).to_s + 's'
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
# MESSAGES
|
191
|
+
desc "Create messages using mailboxer"
|
192
|
+
task :create_messages => :read_environment do
|
188
193
|
puts 'Mailboxer population'
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
available_actors.
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
if (demo
|
214
|
-
|
215
|
-
|
194
|
+
mailboxer_start = Time.now
|
195
|
+
@available_actors = Actor.all
|
196
|
+
|
197
|
+
@available_actors.each do |a|
|
198
|
+
actors = @available_actors.dup - Array(a)
|
199
|
+
|
200
|
+
mult_recp = actors.uniq
|
201
|
+
if (demo = User.find_by_name('demo')) and !mult_recp.include? Actor.normalize(demo)
|
202
|
+
mult_recp << Actor.normalize(demo)
|
203
|
+
end
|
204
|
+
actor = mult_recp[(rand * mult_recp.size).to_i]
|
205
|
+
mult_recp.delete(actor)
|
206
|
+
mail = actor.send_message(mult_recp, "Hello all, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}", Forgery::LoremIpsum.words(10,:random => true))
|
207
|
+
actor = mult_recp[(rand * mult_recp.size).to_i]
|
208
|
+
mail = actor.reply_to_all(mail, "Well, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
209
|
+
actor = mult_recp[(rand * mult_recp.size).to_i]
|
210
|
+
mail = actor.reply_to_all(mail, "Ok, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
211
|
+
actor = mult_recp[(rand * mult_recp.size).to_i]
|
212
|
+
mail = actor.reply_to_all(mail, "Pretty well, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
213
|
+
actor = mult_recp[(rand * mult_recp.size).to_i]
|
214
|
+
actor.reply_to_all(mail, "Finally, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
215
|
+
|
216
|
+
|
217
|
+
if (demo = User.find_by_name('demo'))
|
218
|
+
next if Actor.normalize(demo)==Actor.normalize(a)
|
219
|
+
mail = a.send_message(demo, "Hello, #{demo.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}", Forgery::LoremIpsum.words(10,:random => true))
|
220
|
+
if rand > 0.5
|
221
|
+
mail = demo.reply_to_sender(mail, "Pretty well #{a.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
216
222
|
if rand > 0.5
|
217
|
-
|
218
|
-
if rand > 0.5
|
219
|
-
a.reply_to_sender(mail, "Ok #{demo.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
220
|
-
end
|
221
|
-
end
|
222
|
-
if rand > 0.75
|
223
|
-
mail.conversation.move_to_trash(demo)
|
223
|
+
a.reply_to_sender(mail, "Ok #{demo.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
224
224
|
end
|
225
225
|
end
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
226
|
+
if rand > 0.75
|
227
|
+
mail.conversation.move_to_trash(demo)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
Forgery::Basic.number(:at_most => actors.size).times do
|
232
|
+
actor = actors.delete_at((rand * actors.size).to_i)
|
233
|
+
next if Actor.normalize(actor)==Actor.normalize(a)
|
234
|
+
mail = a.send_message(actor, "Hello, #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}", Forgery::LoremIpsum.words(10,:random => true))
|
235
|
+
if rand > 0.5
|
236
|
+
mail = actor.reply_to_sender(mail, "Pretty well #{a.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
231
237
|
if rand > 0.5
|
232
|
-
|
233
|
-
if rand > 0.5
|
234
|
-
a.reply_to_sender(mail, "Ok #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
235
|
-
end
|
236
|
-
end
|
237
|
-
if rand > 0.75
|
238
|
-
mail.conversation.move_to_trash(actor)
|
238
|
+
a.reply_to_sender(mail, "Ok #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
|
239
239
|
end
|
240
240
|
end
|
241
|
+
if rand > 0.75
|
242
|
+
mail.conversation.move_to_trash(actor)
|
243
|
+
end
|
241
244
|
end
|
242
|
-
|
243
|
-
mailboxer_end = Time.now
|
244
|
-
puts ' -> ' + (mailboxer_end - mailboxer_start).round(4).to_s + 's'
|
245
|
-
else
|
246
|
-
puts ' -> Cheesecake Testing Mode. Avoiding Mailboxer Population.'
|
247
245
|
end
|
248
246
|
|
247
|
+
mailboxer_end = Time.now
|
248
|
+
puts ' -> ' + (mailboxer_end - mailboxer_start).round(4).to_s + 's'
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
# AVATARS
|
254
|
+
desc "Create avatars"
|
255
|
+
task :create_avatars => :read_environment do
|
256
|
+
def set_logos(klass)
|
257
|
+
klass.all.each do |i|
|
258
|
+
if @LOGOS_TOTAL
|
259
|
+
logo = Dir[File.join(@LOGOS_PATH, klass.to_s.tableize, "#{ rand(@LOGOS_TOTAL) + 1 }.*")].first
|
260
|
+
avatar = Dir[File.join(@LOGOS_PATH, klass.to_s.tableize, "#{ rand(@LOGOS_TOTAL) + 1 }.*")].first
|
261
|
+
else
|
262
|
+
logo = Dir[File.join(@LOGOS_PATH, klass.to_s.tableize, "#{ i.id }.*")].first
|
263
|
+
avatar = Dir[File.join(@LOGOS_PATH, klass.to_s.tableize, "#{ i.id }.*")].first
|
264
|
+
end
|
265
|
+
|
266
|
+
if avatar.present? && File.exists?(avatar)
|
267
|
+
Avatar.copy_to_temp_file(avatar)
|
268
|
+
dimensions = Avatar.get_image_dimensions(avatar)
|
269
|
+
l = Avatar.new(:actor => i.actor,:logo => File.open(avatar), :name => File.basename(avatar), :crop_x => 0, :crop_y => 0, :crop_w => dimensions[:width], :crop_h => dimensions[:height] )
|
270
|
+
l.active = true
|
271
|
+
l.save!
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
249
275
|
|
250
276
|
puts 'Avatar population'
|
251
277
|
avatar_start = Time.now
|
252
278
|
SocialStream.subjects.each {|a| set_logos(Kernel.const_get(a.to_s.classify)) }
|
253
279
|
avatar_end = Time.now
|
254
280
|
puts ' -> ' + (avatar_end - avatar_start).round(4).to_s + 's'
|
255
|
-
|
256
281
|
end
|
257
282
|
end
|
258
283
|
end
|