activity_notification 1.7.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.travis.yml +16 -2
- data/CHANGELOG.md +22 -2
- data/Gemfile +7 -0
- data/Procfile +2 -0
- data/README.md +366 -32
- data/Rakefile +19 -10
- data/activity_notification.gemspec +5 -3
- data/app/channels/activity_notification/notification_channel.rb +37 -0
- data/app/channels/activity_notification/notification_with_devise_channel.rb +51 -0
- data/app/controllers/activity_notification/notifications_controller.rb +1 -1
- data/app/controllers/activity_notification/subscriptions_controller.rb +1 -1
- data/app/jobs/activity_notification/notify_all_job.rb +16 -0
- data/app/jobs/activity_notification/notify_job.rb +17 -0
- data/app/jobs/activity_notification/notify_to_job.rb +16 -0
- data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +1 -1
- data/app/views/activity_notification/notifications/default/index.html.erb +55 -2
- data/bin/_dynamodblocal +4 -0
- data/{scripts → bin}/bundle_update.sh +1 -0
- data/bin/deploy_on_heroku.sh +14 -0
- data/bin/install_dynamodblocal.sh +5 -0
- data/bin/start_dynamodblocal.sh +47 -0
- data/bin/stop_dynamodblocal.sh +34 -0
- data/gemfiles/Gemfile.rails-4.2 +1 -0
- data/gemfiles/Gemfile.rails-5.0 +2 -0
- data/gemfiles/Gemfile.rails-5.1 +1 -0
- data/gemfiles/Gemfile.rails-5.2 +1 -0
- data/gemfiles/Gemfile.rails-6.0.rc +21 -0
- data/lib/activity_notification.rb +1 -0
- data/lib/activity_notification/apis/notification_api.rb +289 -136
- data/lib/activity_notification/apis/subscription_api.rb +80 -53
- data/lib/activity_notification/common.rb +3 -3
- data/lib/activity_notification/config.rb +89 -33
- data/lib/activity_notification/controllers/common_controller.rb +19 -7
- data/lib/activity_notification/helpers/errors.rb +4 -0
- data/lib/activity_notification/helpers/view_helpers.rb +1 -1
- data/lib/activity_notification/models/concerns/notifiable.rb +61 -53
- data/lib/activity_notification/models/concerns/subscriber.rb +7 -6
- data/lib/activity_notification/models/concerns/target.rb +73 -28
- data/lib/activity_notification/optional_targets/base.rb +2 -2
- data/lib/activity_notification/orm/active_record/notification.rb +4 -23
- data/lib/activity_notification/orm/dynamoid.rb +495 -0
- data/lib/activity_notification/orm/dynamoid/extension.rb +184 -0
- data/lib/activity_notification/orm/dynamoid/notification.rb +189 -0
- data/lib/activity_notification/orm/dynamoid/subscription.rb +82 -0
- data/lib/activity_notification/orm/mongoid.rb +4 -1
- data/lib/activity_notification/orm/mongoid/notification.rb +8 -25
- data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
- data/lib/activity_notification/roles/acts_as_notifiable.rb +33 -5
- data/lib/activity_notification/roles/acts_as_target.rb +62 -9
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/templates/activity_notification.rb +30 -7
- data/lib/tasks/activity_notification_tasks.rake +14 -4
- data/spec/channels/notification_channel_shared_examples.rb +59 -0
- data/spec/channels/notification_channel_spec.rb +50 -0
- data/spec/channels/notification_with_devise_channel_spec.rb +99 -0
- data/spec/concerns/apis/notification_api_spec.rb +2 -2
- data/spec/concerns/apis/subscription_api_spec.rb +2 -2
- data/spec/concerns/models/notifiable_spec.rb +72 -7
- data/spec/concerns/models/subscriber_spec.rb +53 -49
- data/spec/concerns/models/target_spec.rb +135 -13
- data/spec/config_spec.rb +41 -1
- data/spec/controllers/notifications_controller_shared_examples.rb +7 -3
- data/spec/controllers/subscriptions_controller_shared_examples.rb +7 -3
- data/spec/helpers/view_helpers_spec.rb +12 -10
- data/spec/models/dummy/dummy_group_spec.rb +4 -0
- data/spec/models/dummy/dummy_notifiable_spec.rb +4 -0
- data/spec/models/dummy/dummy_notifier_spec.rb +4 -0
- data/spec/models/dummy/dummy_subscriber_spec.rb +3 -0
- data/spec/models/dummy/dummy_target_spec.rb +4 -0
- data/spec/models/notification_spec.rb +164 -45
- data/spec/models/subscription_spec.rb +69 -14
- data/spec/orm/dynamoid_spec.rb +115 -0
- data/spec/rails_app/app/assets/javascripts/application.js +2 -1
- data/spec/rails_app/app/assets/javascripts/cable.js +12 -0
- data/spec/rails_app/app/controllers/comments_controller.rb +3 -4
- data/spec/rails_app/app/models/admin.rb +6 -4
- data/spec/rails_app/app/models/article.rb +2 -2
- data/spec/rails_app/app/models/comment.rb +17 -5
- data/spec/rails_app/app/models/user.rb +5 -3
- data/spec/rails_app/app/views/activity_notification/notifications/users/overridden/custom/_test.html.erb +1 -0
- data/spec/rails_app/config/application.rb +6 -1
- data/spec/rails_app/config/cable.yml +8 -0
- data/spec/rails_app/config/dynamoid.rb +5 -0
- data/spec/rails_app/config/environment.rb +4 -1
- data/spec/rails_app/config/environments/production.rb +1 -1
- data/spec/rails_app/config/initializers/activity_notification.rb +30 -7
- data/spec/rails_app/config/locales/activity_notification.en.yml +2 -0
- data/spec/rails_app/db/seeds.rb +21 -5
- data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +12 -4
- data/spec/roles/acts_as_notifiable_spec.rb +2 -2
- data/spec/roles/acts_as_target_spec.rb +1 -1
- data/spec/spec_helper.rb +15 -8
- metadata +67 -20
- data/spec/rails_app/app/models/.keep +0 -0
- data/spec/rails_app/app/views/activity_notification/notifications/users/overriden/custom/_test.html.erb +0 -1
data/Rakefile
CHANGED
@@ -2,18 +2,27 @@ require "bundler/gem_tasks"
|
|
2
2
|
|
3
3
|
task default: :test
|
4
4
|
|
5
|
-
|
6
|
-
require 'rspec/core
|
7
|
-
|
8
|
-
RSpec
|
9
|
-
|
5
|
+
begin
|
6
|
+
require 'rspec/core'
|
7
|
+
require 'rspec/core/rake_task'
|
8
|
+
desc 'Run RSpec test for the activity_notification plugin.'
|
9
|
+
RSpec::Core::RakeTask.new(:test) do |spec|
|
10
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
11
|
+
end
|
12
|
+
rescue LoadError
|
10
13
|
end
|
11
14
|
|
12
|
-
|
13
|
-
require 'yard
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
begin
|
16
|
+
require 'yard'
|
17
|
+
require 'yard/rake/yardoc_task'
|
18
|
+
desc 'Generate documentation for the activity_notification plugin.'
|
19
|
+
YARD::Rake::YardocTask.new do |doc|
|
20
|
+
doc.files = ['app/**/*.rb', 'lib/**/*.rb']
|
21
|
+
end
|
22
|
+
rescue LoadError
|
17
23
|
end
|
18
24
|
|
19
25
|
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require File.expand_path('../spec/rails_app/config/application', __FILE__)
|
28
|
+
Rails.application.load_tasks
|
@@ -20,14 +20,16 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
s.required_ruby_version = '>= 2.1.0'
|
22
22
|
|
23
|
-
s.add_dependency 'railties', '>= 4.2.0', '<
|
23
|
+
s.add_dependency 'railties', '>= 4.2.0', '< 6.1'
|
24
24
|
s.add_dependency 'i18n', '>= 0.5.0'
|
25
25
|
s.add_dependency 'jquery-rails', '>= 3.1.1'
|
26
26
|
|
27
|
-
s.add_development_dependency '
|
27
|
+
s.add_development_dependency 'puma', '>= 3.12.0'
|
28
|
+
s.add_development_dependency 'sqlite3', '>= 1.3.13'
|
28
29
|
s.add_development_dependency 'mysql2', '>= 0.5.2'
|
29
30
|
s.add_development_dependency 'pg', '>= 1.0.0'
|
30
|
-
s.add_development_dependency 'mongoid', '>= 4.0.0'
|
31
|
+
s.add_development_dependency 'mongoid', '>= 4.0.0'
|
32
|
+
s.add_development_dependency 'dynamoid', '>= 3.0.0', '< 3.2.0'
|
31
33
|
s.add_development_dependency 'rspec-rails', '>= 3.8.0'
|
32
34
|
s.add_development_dependency 'factory_bot_rails', '>= 4.11.0', '< 5.0.0'
|
33
35
|
s.add_development_dependency 'simplecov', '~> 0'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
if defined?(ActionCable)
|
2
|
+
# Action Cable channel to subscribe broadcasted notifications.
|
3
|
+
class ActivityNotification::NotificationChannel < ActivityNotification.config.parent_channel.constantize
|
4
|
+
before_subscribe :set_target
|
5
|
+
before_subscribe :authenticate_target!
|
6
|
+
|
7
|
+
# ActionCable::Channel::Base#subscribed
|
8
|
+
# @see https://api.rubyonrails.org/classes/ActionCable/Channel/Base.html#method-i-subscribed
|
9
|
+
def subscribed
|
10
|
+
stream_from "#{ActivityNotification.config.notification_channel_prefix}_#{@target.to_class_name}#{ActivityNotification.config.composite_key_delimiter}#{@target.id}"
|
11
|
+
rescue
|
12
|
+
reject
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
# Sets @target instance variable from request parameters.
|
18
|
+
# @api protected
|
19
|
+
# @return [Object] Target instance (Reject subscription when request parameters are not enough)
|
20
|
+
def set_target
|
21
|
+
target_type = params[:target_type]
|
22
|
+
target_class = target_type.to_s.to_model_class
|
23
|
+
@target = params[:target_id].present? ?
|
24
|
+
target_class.find_by!(id: params[:target_id]) :
|
25
|
+
target_class.find_by!(id: params["#{target_type.to_s.to_resource_name}_id"])
|
26
|
+
rescue
|
27
|
+
reject
|
28
|
+
end
|
29
|
+
|
30
|
+
# Allow the target to subscribe notification channel if notification_action_cable_with_devise? returns false
|
31
|
+
# @api protected
|
32
|
+
# @return [Responce] Returns connected or rejected
|
33
|
+
def authenticate_target!
|
34
|
+
reject if @target.nil? || @target.notification_action_cable_with_devise?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
if defined?(ActionCable)
|
2
|
+
# Action Cable channel to subscribe broadcasted notifications with Devise authentication.
|
3
|
+
class ActivityNotification::NotificationWithDeviseChannel < ActivityNotification::NotificationChannel
|
4
|
+
# Include PolymorphicHelpers to resolve string extentions
|
5
|
+
include ActivityNotification::PolymorphicHelpers
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
# Find current signed-in target from Devise session data.
|
10
|
+
# @api protected
|
11
|
+
# @param [String] devise_type Class name of authenticated Devise resource
|
12
|
+
# @return [Object] Current signed-in target
|
13
|
+
def find_current_target(devise_type = nil)
|
14
|
+
devise_type = (devise_type || @target.notification_devise_resource.class.name).to_s
|
15
|
+
devise_type.to_model_class.find(session["warden.user.#{devise_type.to_resource_name}.key"][0][0])
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get current session from cookies.
|
19
|
+
# @api protected
|
20
|
+
# @return [Hash] Session from cookies
|
21
|
+
def session
|
22
|
+
@session ||= connection.__send__(:cookies).encrypted[Rails.application.config.session_options[:key]]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Sets @target instance variable from request parameters.
|
26
|
+
# This method override super (ActivityNotiication::NotificationChannel#set_target)
|
27
|
+
# to set devise authenticated target when the target_id params is not specified.
|
28
|
+
# @api protected
|
29
|
+
# @return [Object] Target instance (Reject subscription when request parameters are not enough)
|
30
|
+
def set_target
|
31
|
+
reject and return if (target_type = params[:target_type]).blank?
|
32
|
+
if params[:target_id].blank? && params["#{target_type.to_s.to_resource_name}_id"].blank?
|
33
|
+
reject and return if params[:devise_type].blank?
|
34
|
+
current_target = find_current_target(params[:devise_type])
|
35
|
+
params[:target_id] = target_type.to_model_class.resolve_current_devise_target(current_target)
|
36
|
+
reject and return if params[:target_id].blank?
|
37
|
+
end
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
# Authenticate the target of requested notification with authenticated devise resource.
|
42
|
+
# @api protected
|
43
|
+
# @return [Responce] Returns connected or rejected
|
44
|
+
def authenticate_target!
|
45
|
+
current_resource = find_current_target
|
46
|
+
reject unless @target.authenticated_with_devise?(current_resource)
|
47
|
+
rescue
|
48
|
+
reject
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -156,7 +156,7 @@ module ActivityNotification
|
|
156
156
|
end
|
157
157
|
|
158
158
|
# Returns controller path.
|
159
|
-
# This method is called from target_view_path method and can be
|
159
|
+
# This method is called from target_view_path method and can be overridden.
|
160
160
|
# @api protected
|
161
161
|
# @return [String] "activity_notification/notifications" as controller path
|
162
162
|
def controller_path
|
@@ -213,7 +213,7 @@ module ActivityNotification
|
|
213
213
|
end
|
214
214
|
|
215
215
|
# Returns controller path.
|
216
|
-
# This method is called from target_view_path method and can be
|
216
|
+
# This method is called from target_view_path method and can be overridden.
|
217
217
|
# @api protected
|
218
218
|
# @return [String] "activity_notification/subscriptions" as controller path
|
219
219
|
def controller_path
|
@@ -1,7 +1,23 @@
|
|
1
1
|
if defined?(ActiveJob)
|
2
|
+
# Job to generate notifications by ActivityNotification::Notification#notify_all method.
|
2
3
|
class ActivityNotification::NotifyAllJob < ActivityNotification.config.parent_job.constantize
|
3
4
|
queue_as ActivityNotification.config.active_job_queue
|
4
5
|
|
6
|
+
# Generates notifications to specified targets with ActiveJob.
|
7
|
+
#
|
8
|
+
# @param [Array<Object>] targets Targets to send notifications
|
9
|
+
# @param [Object] notifiable Notifiable instance
|
10
|
+
# @param [Hash] options Options for notifications
|
11
|
+
# @option options [String] :key (notifiable.default_notification_key) Key of the notification
|
12
|
+
# @option options [Object] :group (nil) Group unit of the notifications
|
13
|
+
# @option options [ActiveSupport::Duration] :group_expiry_delay (nil) Expiry period of a notification group
|
14
|
+
# @option options [Object] :notifier (nil) Notifier of the notifications
|
15
|
+
# @option options [Hash] :parameters ({}) Additional parameters of the notifications
|
16
|
+
# @option options [Boolean] :send_email (true) Whether it sends notification email
|
17
|
+
# @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously
|
18
|
+
# @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets
|
19
|
+
# @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options
|
20
|
+
# @return [Array<Notificaion>] Array of generated notifications
|
5
21
|
def perform(targets, notifiable, options = {})
|
6
22
|
ActivityNotification::Notification.notify_all(targets, notifiable, options)
|
7
23
|
end
|
@@ -1,7 +1,24 @@
|
|
1
1
|
if defined?(ActiveJob)
|
2
|
+
# Job to generate notifications by ActivityNotification::Notification#notify method.
|
2
3
|
class ActivityNotification::NotifyJob < ActivityNotification.config.parent_job.constantize
|
3
4
|
queue_as ActivityNotification.config.active_job_queue
|
4
5
|
|
6
|
+
# Generates notifications to configured targets with notifiable model with ActiveJob.
|
7
|
+
#
|
8
|
+
# @param [Symbol, String, Class] target_type Type of target
|
9
|
+
# @param [Object] notifiable Notifiable instance
|
10
|
+
# @param [Hash] options Options for notifications
|
11
|
+
# @option options [String] :key (notifiable.default_notification_key) Key of the notification
|
12
|
+
# @option options [Object] :group (nil) Group unit of the notifications
|
13
|
+
# @option options [ActiveSupport::Duration] :group_expiry_delay (nil) Expiry period of a notification group
|
14
|
+
# @option options [Object] :notifier (nil) Notifier of the notifications
|
15
|
+
# @option options [Hash] :parameters ({}) Additional parameters of the notifications
|
16
|
+
# @option options [Boolean] :send_email (true) Whether it sends notification email
|
17
|
+
# @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously
|
18
|
+
# @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets
|
19
|
+
# @option options [Boolean] :pass_full_options (false) Whether it passes full options to notifiable.notification_targets, not a key only
|
20
|
+
# @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options
|
21
|
+
# @return [Array<Notificaion>] Array of generated notifications
|
5
22
|
def perform(target_type, notifiable, options = {})
|
6
23
|
ActivityNotification::Notification.notify(target_type, notifiable, options)
|
7
24
|
end
|
@@ -1,7 +1,23 @@
|
|
1
1
|
if defined?(ActiveJob)
|
2
|
+
# Job to generate notifications by ActivityNotification::Notification#notify_to method.
|
2
3
|
class ActivityNotification::NotifyToJob < ActivityNotification.config.parent_job.constantize
|
3
4
|
queue_as ActivityNotification.config.active_job_queue
|
4
5
|
|
6
|
+
# Generates notifications to one target with ActiveJob.
|
7
|
+
#
|
8
|
+
# @param [Object] target Target to send notifications
|
9
|
+
# @param [Object] notifiable Notifiable instance
|
10
|
+
# @param [Hash] options Options for notifications
|
11
|
+
# @option options [String] :key (notifiable.default_notification_key) Key of the notification
|
12
|
+
# @option options [Object] :group (nil) Group unit of the notifications
|
13
|
+
# @option options [ActiveSupport::Duration] :group_expiry_delay (nil) Expiry period of a notification group
|
14
|
+
# @option options [Object] :notifier (nil) Notifier of the notifications
|
15
|
+
# @option options [Hash] :parameters ({}) Additional parameters of the notifications
|
16
|
+
# @option options [Boolean] :send_email (true) Whether it sends notification email
|
17
|
+
# @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously
|
18
|
+
# @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets
|
19
|
+
# @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options
|
20
|
+
# @return [Notification] Generated notification instance
|
5
21
|
def perform(target, notifiable, options = {})
|
6
22
|
ActivityNotification::Notification.notify_to(target, notifiable, options)
|
7
23
|
end
|
data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
|
24
24
|
<div class='<%= "notification_#{notification.id}" %>'>
|
25
25
|
<% if notification.unopened? %>
|
26
|
-
<%= link_to open_notification_path_for(notification, parameters.slice(:with_group_members, :routing_scope, :devise_default_routes).merge(reload: false), method: :post, remote: true, class: "unopened_wrapper" do %>
|
26
|
+
<%= link_to open_notification_path_for(notification, parameters.slice(:with_group_members, :routing_scope, :devise_default_routes).merge(reload: false)), method: :post, remote: true, class: "unopened_wrapper" do %>
|
27
27
|
<div class="unopned_circle"></div>
|
28
28
|
<div class="unopned_description_wrapper">
|
29
29
|
<p class="unopned_description">Open</p>
|
@@ -1,13 +1,23 @@
|
|
1
1
|
<div class="notification_wrapper">
|
2
2
|
<div class="notification_header">
|
3
|
-
<h1>
|
3
|
+
<h1>
|
4
|
+
Notifications to <%= @target.printable_target_name %>
|
5
|
+
<%= link_to open_all_notifications_path_for(@target, @index_options.slice(:routing_scope, :devise_default_routes)), method: :post, remote: true do %>
|
6
|
+
<span class="notification_count"><span class="<%= 'unopened' if @target.has_unopened_notifications?(@index_options) %>">
|
7
|
+
<%= @target.unopened_notification_count(@index_options) %>
|
8
|
+
</span></span>
|
9
|
+
<% end %>
|
10
|
+
</h1>
|
11
|
+
<h3>
|
12
|
+
<span class="action_cable_status">Disabled</span>
|
13
|
+
</h3>
|
4
14
|
</div>
|
5
15
|
<div class="notifications">
|
6
16
|
<% if @index_options[:with_group_members] %>
|
7
17
|
<%= render_notification @notifications, @index_options.slice(:routing_scope, :devise_default_routes).merge(fallback: :default_without_grouping, with_group_members: true) %>
|
8
18
|
<% else %>
|
9
19
|
<%= render_notification @notifications, @index_options.slice(:routing_scope, :devise_default_routes).merge(fallback: :default) %>
|
10
|
-
<%#= render_notification @notifications, @index_options.merge(fallback: :text) %>
|
20
|
+
<%#= render_notification @notifications, @index_options.slice(:routing_scope, :devise_default_routes).merge(fallback: :text) %>
|
11
21
|
<% end %>
|
12
22
|
</div>
|
13
23
|
</div>
|
@@ -28,3 +38,46 @@
|
|
28
38
|
background-color: #f87880;
|
29
39
|
}
|
30
40
|
</style>
|
41
|
+
|
42
|
+
<% if @target.notification_action_cable_allowed? %>
|
43
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/push.js/1.0.9/push.min.js"></script>
|
44
|
+
<script>
|
45
|
+
App.activity_notification = App.cable.subscriptions.create(
|
46
|
+
{
|
47
|
+
channel: "<%= @target.notification_action_cable_channel_class_name %>",
|
48
|
+
target_type: "<%= @target.to_class_name %>", target_id: "<%= @target.id %>"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
connected: function() {
|
52
|
+
$(".action_cable_status").html("Online<%= " (authorized)" if @target.notification_action_cable_with_devise? %>");
|
53
|
+
},
|
54
|
+
disconnected: function() {
|
55
|
+
$(".action_cable_status").html("Offline");
|
56
|
+
},
|
57
|
+
rejected: function() {
|
58
|
+
$(".action_cable_status").html("Offline (unauthorized)");
|
59
|
+
},
|
60
|
+
received: function(notification) {
|
61
|
+
// Display notification
|
62
|
+
if (notification.group_owner_id == null) {
|
63
|
+
$(".notifications").prepend(notification.view);
|
64
|
+
$(".notification_count").html("<span class=unopened>" + notification.unopened_notification_count + "</span>");
|
65
|
+
} else {
|
66
|
+
$(".notification_" + notification.group_owner_id).remove();
|
67
|
+
$(".notifications").prepend(notification.group_owner_view);
|
68
|
+
$(".notification_count").html("<span class=unopened>" + notification.unopened_notification_count + "</span>");
|
69
|
+
}
|
70
|
+
// Push notificaion using Web Notification API by Push.js
|
71
|
+
Push.create('ActivityNotification', {
|
72
|
+
body: notification.text,
|
73
|
+
timeout: 5000,
|
74
|
+
onClick: function () {
|
75
|
+
location.href = notification.notifiable_path;
|
76
|
+
this.close();
|
77
|
+
}
|
78
|
+
});
|
79
|
+
}
|
80
|
+
}
|
81
|
+
);
|
82
|
+
</script>
|
83
|
+
<% end %>
|
data/bin/_dynamodblocal
ADDED
@@ -5,3 +5,4 @@ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.2 bundle update
|
|
5
5
|
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.0 bundle update
|
6
6
|
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.1 bundle update
|
7
7
|
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.2 bundle update
|
8
|
+
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-6.0.rc bundle update
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
HEROKU_DEPLOYMENT_BRANCH=heroku-deployment
|
4
|
+
|
5
|
+
CURRENT_BRANCH=`git symbolic-ref --short HEAD`
|
6
|
+
git checkout -b $HEROKU_DEPLOYMENT_BRANCH
|
7
|
+
bundle install
|
8
|
+
sed -i "" -e "s/^\/Gemfile.lock/# \/Gemfile.lock/g" .gitignore
|
9
|
+
git add .gitignore
|
10
|
+
git add Gemfile.lock
|
11
|
+
git commit -m "Add Gemfile.lock"
|
12
|
+
git push heroku ${HEROKU_DEPLOYMENT_BRANCH}:master --force
|
13
|
+
git checkout $CURRENT_BRANCH
|
14
|
+
git branch -D $HEROKU_DEPLOYMENT_BRANCH
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# Source variables
|
4
|
+
. $(dirname $0)/_dynamodblocal
|
5
|
+
|
6
|
+
if [ -z $JAVA_HOME ]; then
|
7
|
+
echo >&2 'ERROR: DynamoDBLocal requires JAVA_HOME to be set.'
|
8
|
+
exit 1
|
9
|
+
fi
|
10
|
+
|
11
|
+
if [ ! -x $JAVA_HOME/bin/java ]; then
|
12
|
+
echo >&2 'ERROR: JAVA_HOME is set, but I do not see the java executable there.'
|
13
|
+
exit 1
|
14
|
+
fi
|
15
|
+
|
16
|
+
cd $DIST_DIR
|
17
|
+
|
18
|
+
if [ ! -f DynamoDBLocal.jar ] || [ ! -d DynamoDBLocal_lib ]; then
|
19
|
+
echo >&2 "ERROR: Could not find DynamoDBLocal files in $DIST_DIR."
|
20
|
+
exit 1
|
21
|
+
fi
|
22
|
+
|
23
|
+
mkdir -p $LOG_DIR
|
24
|
+
echo "DynamoDB Local output will save to ${DIST_DIR}/${LOG_DIR}/"
|
25
|
+
hash lsof 2>/dev/null && lsof -i :$LISTEN_PORT && { echo >&2 "Something is already listening on port $LISTEN_PORT; I will not attempt to start DynamoDBLocal."; exit 1; }
|
26
|
+
|
27
|
+
NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
28
|
+
nohup $JAVA_HOME/bin/java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -delayTransientStatuses -port $LISTEN_PORT -inMemory 1>"${LOG_DIR}/${NOW}.out.log" 2>"${LOG_DIR}/${NOW}.err.log" &
|
29
|
+
PID=$!
|
30
|
+
|
31
|
+
echo 'Verifying that DynamoDBLocal actually started...'
|
32
|
+
|
33
|
+
# Allow some seconds for the JDK to start and die.
|
34
|
+
counter=0
|
35
|
+
while [ $counter -le 5 ]; do
|
36
|
+
kill -0 $PID
|
37
|
+
if [ $? -ne 0 ]; then
|
38
|
+
echo >&2 'ERROR: DynamoDBLocal died after we tried to start it!'
|
39
|
+
exit 1
|
40
|
+
else
|
41
|
+
counter=$(($counter + 1))
|
42
|
+
sleep 1
|
43
|
+
fi
|
44
|
+
done
|
45
|
+
|
46
|
+
echo "DynamoDB Local started with pid $PID listening on port $LISTEN_PORT."
|
47
|
+
echo $PID > $PIDFILE
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# Source variables
|
4
|
+
. $(dirname $0)/_dynamodblocal
|
5
|
+
|
6
|
+
cd $DIST_DIR
|
7
|
+
|
8
|
+
if [ ! -f $PIDFILE ]; then
|
9
|
+
echo 'ERROR: There is no pidfile, so if DynamoDBLocal is running you will need to kill it yourself.'
|
10
|
+
exit 1
|
11
|
+
fi
|
12
|
+
|
13
|
+
pid=$(<$PIDFILE)
|
14
|
+
|
15
|
+
echo "Killing DynamoDBLocal at pid $pid..."
|
16
|
+
kill $pid
|
17
|
+
|
18
|
+
counter=0
|
19
|
+
while [ $counter -le 5 ]; do
|
20
|
+
kill -0 $pid 2>/dev/null
|
21
|
+
if [ $? -ne 0 ]; then
|
22
|
+
echo 'Successfully shut down DynamoDBLocal.'
|
23
|
+
rm -f $PIDFILE
|
24
|
+
exit 0
|
25
|
+
else
|
26
|
+
echo 'Still waiting for DynamoDBLocal to shut down...'
|
27
|
+
counter=$(($counter + 1))
|
28
|
+
sleep 1
|
29
|
+
fi
|
30
|
+
done
|
31
|
+
|
32
|
+
echo 'Unable to shut down DynamoDBLocal; you may need to kill it yourself.'
|
33
|
+
rm -f $PIDFILE
|
34
|
+
exit 1
|