social_stream-base 0.24.1 → 0.24.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/app/models/ability.rb +2 -1
- data/app/views/notification_mailer/new_notification_email.text.erb +2 -7
- data/app/views/notifications/_notification.html.erb +3 -9
- data/lib/generators/social_stream/base/install_generator.rb +36 -0
- data/lib/generators/social_stream/base/templates/initializer.rb +6 -5
- data/lib/social_stream/ability.rb +3 -3
- data/lib/social_stream/{ability/base.rb → base/ability.rb} +2 -2
- data/lib/social_stream/base/version.rb +1 -1
- data/lib/social_stream/controllers/helpers.rb +1 -1
- data/lib/social_stream-base.rb +4 -1
- data/lib/tasks/workers.rake +35 -11
- data/spec/dummy/config/initializers/social_stream.rb +6 -5
- metadata +3 -3
data/app/models/ability.rb
CHANGED
@@ -2,13 +2,8 @@
|
|
2
2
|
<% locale_as @receiver.subject %>
|
3
3
|
<%= t('notification.hello', :receiver => @receiver.name)%>
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
:locals =>{:activity => @notification.notified_object} %>
|
8
|
-
<% else %>
|
9
|
-
<%= render :partial => "notifications/activities/#{ @notification.notified_object.verb }",
|
10
|
-
:locals =>{:activity => @notification.notified_object}%>
|
11
|
-
<% end %>
|
5
|
+
<%= render partial: "notifications/activities/#{ @notification.notified_object.verb }",
|
6
|
+
locals: { activity: @notification.notified_object } %>
|
12
7
|
|
13
8
|
-----------------------------------------------
|
14
9
|
<%= raw t('notification.visit', :url=> notifications_url)%>
|
@@ -20,14 +20,8 @@
|
|
20
20
|
|
21
21
|
<div class="content_right">
|
22
22
|
<div class="briefing">
|
23
|
-
|
24
|
-
|
25
|
-
:locals =>{:activity => notification.notified_object} %>
|
26
|
-
<% else %>
|
27
|
-
|
28
|
-
<%= render :partial => "notifications/activities/#{ notification.notified_object.verb }",
|
29
|
-
:locals =>{:activity => notification.notified_object} %>
|
30
|
-
<% end %>
|
23
|
+
<%= render partial: "notifications/activities/#{ notification.notified_object.verb }",
|
24
|
+
locals: { activity: notification.notified_object } %>
|
31
25
|
</div>
|
32
26
|
<div class="clearfloat">
|
33
27
|
</div>
|
@@ -47,4 +41,4 @@
|
|
47
41
|
</div>
|
48
42
|
<div class="clearfloat">
|
49
43
|
</div>
|
50
|
-
<% end %>
|
44
|
+
<% end %>
|
@@ -59,4 +59,40 @@ class SocialStream::Base::InstallGenerator < Rails::Generators::Base #:nodoc:
|
|
59
59
|
Rake::Task['railties:install:migrations'].reenable
|
60
60
|
Rake::Task['social_stream_base_engine:install:migrations'].invoke
|
61
61
|
end
|
62
|
+
|
63
|
+
def create_ability_file
|
64
|
+
ability_code = [
|
65
|
+
"# Generator social_stream:install has modified this file. Please,", #0
|
66
|
+
"# check everything is working ok, specially if the former `Ability`", #1
|
67
|
+
"# class inherited from another class or included another module", #2
|
68
|
+
"class Ability", #3
|
69
|
+
" include SocialStream::Ability", #4
|
70
|
+
"", #5
|
71
|
+
" def initialize(subject)", #6
|
72
|
+
" super", #7
|
73
|
+
"", #8
|
74
|
+
" # Add your authorization rules here", #9
|
75
|
+
" # For instance:", #10
|
76
|
+
" # can :create, Comment", #11
|
77
|
+
" # can [:create, :destroy], Post do |p|", #12
|
78
|
+
" # p.actor_id == Actor.normalize_id(subject)", #13
|
79
|
+
" # end", #14
|
80
|
+
" end", #15
|
81
|
+
"end"] #16
|
82
|
+
ability_file = 'app/models/ability.rb'
|
83
|
+
|
84
|
+
if FileTest.exists? ability_file
|
85
|
+
prepend_to_file ability_file, ability_code[0..2].join("\n")+"\n"
|
86
|
+
if not File.read(ability_file).include?("include SocialStream::Ability\n")
|
87
|
+
inject_into_file ability_file, ability_code[4..5].join("\n")+"\n", :after => /class Ability(.*)\n/
|
88
|
+
end
|
89
|
+
if File.read(ability_file).include?("def initialize\n")
|
90
|
+
inject_into_file ability_file, ability_code[7..14].join("\n")+"\n", :after => /def initialize(.*)\n/
|
91
|
+
else
|
92
|
+
inject_into_file ability_file, ability_code[5..15].join("\n")+"\n", :after => /include SocialStream::Ability\n/
|
93
|
+
end
|
94
|
+
else
|
95
|
+
create_file ability_file, ability_code[3..16].join("\n")
|
96
|
+
end
|
97
|
+
end
|
62
98
|
end
|
@@ -10,13 +10,14 @@ SocialStream.setup do |config|
|
|
10
10
|
# config.devise_modules = :database_authenticatable, :registerable,
|
11
11
|
# :recoverable, :rememberable, :trackable,
|
12
12
|
# :omniauthable, :token_authenticatable
|
13
|
-
|
13
|
+
|
14
14
|
# Type of activities managed by actors
|
15
15
|
# Remember you must add an "activity_object_id" foreign key column to your migration!
|
16
|
+
# Be sure to add the other modules of Social Stream you might be using (e.g. :document, :event, :link ).
|
16
17
|
#
|
17
18
|
# config.objects = [ :post, :comment ]
|
18
|
-
|
19
|
-
# Form for activity objects to be loaded
|
19
|
+
|
20
|
+
# Form for activity objects to be loaded
|
20
21
|
# You can write your own activity objects
|
21
22
|
#
|
22
23
|
# config.activity_forms = [ :post, :document, :foo, :bar ]
|
@@ -31,10 +32,10 @@ SocialStream.setup do |config|
|
|
31
32
|
# Expose resque interface to manage background tasks at /resque
|
32
33
|
#
|
33
34
|
# config.resque_access = true
|
34
|
-
|
35
|
+
|
35
36
|
# Quick search (header) and Extended search models and its order. Remember to create
|
36
37
|
# the indexes with thinking-sphinx if you are using customized models.
|
37
|
-
#
|
38
|
+
#
|
38
39
|
# config.quick_search_models = [:user, :group]
|
39
40
|
# config.extended_search_models = [:user, :group]
|
40
41
|
|
data/lib/social_stream-base.rb
CHANGED
@@ -3,12 +3,15 @@ require 'social_stream/base/dependencies'
|
|
3
3
|
|
4
4
|
# Provides your Rails application with social network and activity stream support
|
5
5
|
module SocialStream
|
6
|
-
autoload :Ability,
|
6
|
+
autoload :Ability, 'social_stream/ability'
|
7
7
|
autoload :ActivityStreams, 'social_stream/activity_streams'
|
8
8
|
module ActivityStreams
|
9
9
|
autoload :Supertype, 'social_stream/activity_streams/supertype'
|
10
10
|
autoload :Subtype, 'social_stream/activity_streams/subtype'
|
11
11
|
end
|
12
|
+
module Base
|
13
|
+
autoload :Ability, 'social_stream/base/ability'
|
14
|
+
end
|
12
15
|
autoload :D3, 'social_stream/d3'
|
13
16
|
autoload :Populate, 'social_stream/populate'
|
14
17
|
autoload :Relations, 'social_stream/relations'
|
data/lib/tasks/workers.rake
CHANGED
@@ -52,6 +52,10 @@ namespace :workers do
|
|
52
52
|
ENV['COUNT']
|
53
53
|
end
|
54
54
|
|
55
|
+
def queue_pathname
|
56
|
+
queue.gsub(/[:\*<>\|\"\/\\\?]/, "_")
|
57
|
+
end
|
58
|
+
|
55
59
|
def Process.exists?(pid)
|
56
60
|
kill(0, pid.to_i) rescue false
|
57
61
|
end
|
@@ -61,11 +65,11 @@ namespace :workers do
|
|
61
65
|
end
|
62
66
|
|
63
67
|
def pid_directory_for_group
|
64
|
-
@pid_directory_for_group ||= Rails.root.join('tmp', 'pids', "resque",
|
68
|
+
@pid_directory_for_group ||= Rails.root.join('tmp', 'pids', "resque", queue_pathname)
|
65
69
|
end
|
66
70
|
|
67
71
|
def group_master_pid
|
68
|
-
File.read pid_directory.join("#{
|
72
|
+
File.read pid_directory.join("#{queue_pathname}.pid").to_s rescue nil
|
69
73
|
end
|
70
74
|
|
71
75
|
def group?
|
@@ -77,10 +81,20 @@ namespace :workers do
|
|
77
81
|
end
|
78
82
|
|
79
83
|
def kill_worker(pid)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
%w{QUIT TERM KILL}.each do |signal|
|
85
|
+
if Signal.list.has_key?(signal)
|
86
|
+
begin
|
87
|
+
Process.kill(signal, pid)
|
88
|
+
rescue Errno::EINVAL
|
89
|
+
next
|
90
|
+
end
|
91
|
+
|
92
|
+
puts "Killed worker with PID #{pid}"
|
93
|
+
break
|
94
|
+
end
|
95
|
+
end
|
96
|
+
rescue Errno::ESRCH => e
|
97
|
+
puts " STALE worker with PID #{pid}"
|
84
98
|
end
|
85
99
|
|
86
100
|
def kill_workers
|
@@ -97,7 +111,7 @@ namespace :workers do
|
|
97
111
|
end
|
98
112
|
end
|
99
113
|
if group_master_pid
|
100
|
-
FileUtils.rm pid_directory.join("#{
|
114
|
+
FileUtils.rm pid_directory.join("#{queue_pathname}.pid").to_s
|
101
115
|
FileUtils.rm_rf pid_directory_for_group.to_s
|
102
116
|
end
|
103
117
|
end
|
@@ -120,7 +134,13 @@ namespace :workers do
|
|
120
134
|
|
121
135
|
# Handle exit
|
122
136
|
trap('INT') { shutdown }
|
123
|
-
|
137
|
+
|
138
|
+
begin
|
139
|
+
trap('QUIT') { shutdown }
|
140
|
+
rescue ArgumentError
|
141
|
+
warn "SIGQUIT not supported"
|
142
|
+
end
|
143
|
+
|
124
144
|
trap('TERM') { shutdown }
|
125
145
|
trap('KILL') { shutdown }
|
126
146
|
trap('SIGKILL') { shutdown }
|
@@ -130,7 +150,11 @@ namespace :workers do
|
|
130
150
|
# Launch workers in separate processes, saving their PIDs
|
131
151
|
@pids = []
|
132
152
|
ENV['COUNT'].to_i.times do
|
133
|
-
|
153
|
+
if Process.respond_to?(:fork)
|
154
|
+
@pids << Process.fork { Rake::Task['resque:work'].invoke }
|
155
|
+
else
|
156
|
+
@pids << Process.spawn("rake environment resque:work", chdir: Rails.root)
|
157
|
+
end
|
134
158
|
end
|
135
159
|
|
136
160
|
if group?
|
@@ -138,7 +162,7 @@ namespace :workers do
|
|
138
162
|
FileUtils.mkdir_p pid_directory.to_s
|
139
163
|
FileUtils.mkdir_p pid_directory_for_group.to_s
|
140
164
|
# Create PID files for workers
|
141
|
-
File.open( pid_directory.join("#{
|
165
|
+
File.open( pid_directory.join("#{queue_pathname}.pid").to_s, 'w' ) do |f| f.write Process.pid end
|
142
166
|
@pids.each do |pid|
|
143
167
|
File.open( pid_directory_for_group.join("worker_#{pid}.pid").to_s, 'w' ) { |f| f.write pid }
|
144
168
|
end
|
@@ -156,7 +180,7 @@ namespace :workers do
|
|
156
180
|
Resque::Worker.all.each do |worker|
|
157
181
|
puts "Shutting down worker #{worker}"
|
158
182
|
host, pid, queues = worker.id.split(':')
|
159
|
-
|
183
|
+
kill_worker(pid.to_i)
|
160
184
|
end
|
161
185
|
end
|
162
186
|
|
@@ -10,13 +10,14 @@ SocialStream.setup do |config|
|
|
10
10
|
# config.devise_modules = :database_authenticatable, :registerable,
|
11
11
|
# :recoverable, :rememberable, :trackable,
|
12
12
|
# :omniauthable, :token_authenticatable
|
13
|
-
|
13
|
+
|
14
14
|
# Type of activities managed by actors
|
15
15
|
# Remember you must add an "activity_object_id" foreign key column to your migration!
|
16
|
+
# Be sure to add the other modules of Social Stream you might be using (e.g. :document, :event, :link ).
|
16
17
|
#
|
17
18
|
# config.objects = [ :post, :comment ]
|
18
|
-
|
19
|
-
# Form for activity objects to be loaded
|
19
|
+
|
20
|
+
# Form for activity objects to be loaded
|
20
21
|
# You can write your own activity objects
|
21
22
|
#
|
22
23
|
# config.activity_forms = [ :post, :document, :foo, :bar ]
|
@@ -31,10 +32,10 @@ SocialStream.setup do |config|
|
|
31
32
|
# Expose resque interface to manage background tasks at /resque
|
32
33
|
#
|
33
34
|
# config.resque_access = true
|
34
|
-
|
35
|
+
|
35
36
|
# Quick search (header) and Extended search models and its order. Remember to create
|
36
37
|
# the indexes with thinking-sphinx if you are using customized models.
|
37
|
-
#
|
38
|
+
#
|
38
39
|
# config.quick_search_models = [:user, :group]
|
39
40
|
# config.extended_search_models = [:user, :group]
|
40
41
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_stream-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.24.
|
4
|
+
version: 0.24.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: deep_merge
|
@@ -1113,10 +1113,10 @@ files:
|
|
1113
1113
|
- lib/rails/social_stream.rb
|
1114
1114
|
- lib/social_stream-base.rb
|
1115
1115
|
- lib/social_stream/ability.rb
|
1116
|
-
- lib/social_stream/ability/base.rb
|
1117
1116
|
- lib/social_stream/activity_streams.rb
|
1118
1117
|
- lib/social_stream/activity_streams/subtype.rb
|
1119
1118
|
- lib/social_stream/activity_streams/supertype.rb
|
1119
|
+
- lib/social_stream/base/ability.rb
|
1120
1120
|
- lib/social_stream/base/dependencies.rb
|
1121
1121
|
- lib/social_stream/base/engine.rb
|
1122
1122
|
- lib/social_stream/base/thinking-sphinx.rb
|