activity_notification 2.0.0 → 2.1.0
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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.github/pull_request_template.md +13 -0
- data/.gitignore +10 -3
- data/.travis.yml +6 -5
- data/CHANGELOG.md +22 -0
- data/Gemfile +8 -2
- data/Procfile +1 -1
- data/README.md +153 -1510
- data/activity_notification.gemspec +4 -1
- data/app/channels/activity_notification/notification_api_channel.rb +12 -0
- data/app/channels/activity_notification/notification_api_with_devise_channel.rb +46 -0
- data/app/channels/activity_notification/notification_channel.rb +1 -1
- data/app/channels/activity_notification/notification_with_devise_channel.rb +1 -1
- data/app/controllers/activity_notification/apidocs_controller.rb +75 -0
- data/app/controllers/activity_notification/notifications_api_controller.rb +143 -0
- data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/notifications_controller.rb +79 -53
- data/app/controllers/activity_notification/subscriptions_api_controller.rb +197 -0
- data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/subscriptions_controller.rb +78 -69
- data/app/views/activity_notification/notifications/default/_default.html.erb +18 -18
- data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +14 -14
- data/app/views/activity_notification/notifications/default/index.html.erb +6 -6
- data/app/views/activity_notification/optional_targets/default/action_cable_channel/_default.html.erb +176 -0
- data/app/views/activity_notification/subscriptions/default/_form.html.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +3 -31
- data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +7 -7
- data/app/views/activity_notification/subscriptions/default/index.html.erb +11 -7
- data/bin/deploy_on_heroku.sh +3 -1
- data/docs/CODE_OF_CONDUCT.md +76 -0
- data/docs/CONTRIBUTING.md +36 -0
- data/docs/Functions.md +1130 -0
- data/docs/Setup.md +674 -0
- data/docs/Testing.md +148 -0
- data/gemfiles/Gemfile.rails-4.2 +3 -0
- data/gemfiles/Gemfile.rails-5.0 +3 -0
- data/gemfiles/Gemfile.rails-5.1 +3 -0
- data/gemfiles/Gemfile.rails-5.2 +3 -0
- data/gemfiles/{Gemfile.rails-6.0.rc → Gemfile.rails-6.0} +5 -3
- data/lib/activity_notification.rb +13 -1
- data/lib/activity_notification/apis/notification_api.rb +29 -92
- data/lib/activity_notification/apis/subscription_api.rb +20 -8
- data/lib/activity_notification/apis/swagger.rb +6 -0
- data/lib/activity_notification/config.rb +41 -21
- data/lib/activity_notification/controllers/common_api_controller.rb +30 -0
- data/lib/activity_notification/controllers/common_controller.rb +44 -20
- data/lib/activity_notification/controllers/concerns/swagger/error_responses.rb +55 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_api.rb +273 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb +92 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_api.rb +405 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_parameters.rb +50 -0
- data/lib/activity_notification/controllers/devise_authentication_controller.rb +7 -6
- data/lib/activity_notification/gem_version.rb +14 -0
- data/lib/activity_notification/helpers/errors.rb +2 -0
- data/lib/activity_notification/helpers/view_helpers.rb +4 -0
- data/lib/activity_notification/mailers/helpers.rb +17 -10
- data/lib/activity_notification/models/concerns/notifiable.rb +26 -10
- data/lib/activity_notification/models/concerns/subscriber.rb +12 -1
- data/lib/activity_notification/models/concerns/swagger/error_schema.rb +36 -0
- data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +209 -0
- data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +162 -0
- data/lib/activity_notification/models/concerns/target.rb +36 -10
- data/lib/activity_notification/models/notification.rb +1 -0
- data/lib/activity_notification/models/subscription.rb +1 -0
- data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +69 -0
- data/lib/activity_notification/optional_targets/action_cable_channel.rb +68 -0
- data/lib/activity_notification/optional_targets/base.rb +7 -13
- data/lib/activity_notification/orm/active_record/notification.rb +17 -1
- data/lib/activity_notification/orm/active_record/subscription.rb +1 -1
- data/lib/activity_notification/orm/dynamoid.rb +28 -0
- data/lib/activity_notification/orm/dynamoid/extension.rb +79 -1
- data/lib/activity_notification/orm/dynamoid/notification.rb +1 -1
- data/lib/activity_notification/orm/dynamoid/subscription.rb +1 -1
- data/lib/activity_notification/orm/mongoid.rb +22 -0
- data/lib/activity_notification/orm/mongoid/notification.rb +17 -1
- data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
- data/lib/activity_notification/rails/routes.rb +132 -48
- data/lib/activity_notification/renderable.rb +13 -2
- data/lib/activity_notification/roles/acts_as_notifiable.rb +38 -20
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/activity_notification/controllers_generator.rb +2 -1
- data/lib/generators/templates/activity_notification.rb +8 -0
- data/lib/generators/templates/controllers/notifications_api_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_api_with_devise_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_controller.rb +1 -37
- data/lib/generators/templates/controllers/notifications_with_devise_controller.rb +1 -45
- data/lib/generators/templates/controllers/subscriptions_api_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_api_with_devise_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_controller.rb +14 -37
- data/lib/generators/templates/controllers/subscriptions_with_devise_controller.rb +14 -45
- data/lib/generators/templates/models/README +8 -4
- data/lib/generators/templates/models/notification.rb +1 -1
- data/lib/generators/templates/models/subscription.rb +1 -1
- data/package.json +8 -0
- data/spec/channels/notification_api_channel_shared_examples.rb +59 -0
- data/spec/channels/notification_api_channel_spec.rb +51 -0
- data/spec/channels/notification_api_with_devise_channel_spec.rb +78 -0
- data/spec/concerns/apis/notification_api_spec.rb +37 -2
- data/spec/concerns/models/notifiable_spec.rb +64 -0
- data/spec/concerns/models/subscriber_spec.rb +13 -16
- data/spec/concerns/models/target_spec.rb +32 -0
- data/spec/concerns/renderable_spec.rb +2 -2
- data/spec/controllers/controller_spec_utility.rb +136 -0
- data/spec/controllers/notifications_api_controller_shared_examples.rb +506 -0
- data/spec/controllers/notifications_api_controller_spec.rb +19 -0
- data/spec/controllers/notifications_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/notifications_controller_shared_examples.rb +54 -79
- data/spec/controllers/notifications_controller_spec.rb +1 -2
- data/spec/controllers/notifications_with_devise_controller_spec.rb +3 -12
- data/spec/controllers/subscriptions_api_controller_shared_examples.rb +750 -0
- data/spec/controllers/subscriptions_api_controller_spec.rb +19 -0
- data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/subscriptions_controller_shared_examples.rb +94 -121
- data/spec/controllers/subscriptions_controller_spec.rb +1 -2
- data/spec/controllers/subscriptions_with_devise_controller_spec.rb +3 -12
- data/spec/helpers/view_helpers_spec.rb +4 -11
- data/spec/mailers/mailer_spec.rb +41 -0
- data/spec/models/notification_spec.rb +17 -0
- data/spec/models/subscription_spec.rb +0 -13
- data/spec/optional_targets/action_cable_api_channel_spec.rb +37 -0
- data/spec/optional_targets/action_cable_channel_spec.rb +44 -0
- data/spec/optional_targets/amazon_sns_spec.rb +0 -2
- data/spec/optional_targets/slack_spec.rb +0 -2
- data/spec/rails_app/Rakefile +9 -0
- data/spec/rails_app/app/assets/config/manifest.js +3 -0
- data/spec/rails_app/app/assets/images/.keep +0 -0
- data/spec/rails_app/app/controllers/admins_controller.rb +21 -0
- data/spec/rails_app/app/controllers/application_controller.rb +1 -1
- data/spec/rails_app/app/controllers/articles_controller.rb +6 -3
- data/spec/rails_app/app/controllers/spa_controller.rb +7 -0
- data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -65
- data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -73
- data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -77
- data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -85
- data/spec/rails_app/app/controllers/users_controller.rb +21 -0
- data/spec/rails_app/app/javascript/App.vue +104 -0
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +83 -0
- data/spec/rails_app/app/javascript/components/Top.vue +99 -0
- data/spec/rails_app/app/javascript/components/notifications/Index.vue +200 -0
- data/spec/rails_app/app/javascript/components/notifications/Notification.vue +133 -0
- data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +122 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +279 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +112 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +141 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +226 -0
- data/spec/rails_app/app/javascript/config/development.js +5 -0
- data/spec/rails_app/app/javascript/config/environment.js +7 -0
- data/spec/rails_app/app/javascript/config/production.js +5 -0
- data/spec/rails_app/app/javascript/config/test.js +5 -0
- data/spec/rails_app/app/javascript/packs/application.js +18 -0
- data/spec/rails_app/app/javascript/packs/spa.js +11 -0
- data/spec/rails_app/app/javascript/store/auth.js +37 -0
- data/spec/rails_app/app/models/admin.rb +16 -15
- data/spec/rails_app/app/models/article.rb +26 -21
- data/spec/rails_app/app/models/comment.rb +24 -71
- data/spec/rails_app/app/models/user.rb +43 -20
- data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +146 -0
- data/spec/rails_app/app/views/articles/index.html.erb +51 -7
- data/spec/rails_app/app/views/articles/show.html.erb +1 -1
- data/spec/rails_app/app/views/layouts/_header.html.erb +8 -10
- data/spec/rails_app/app/views/spa/index.html.erb +2 -0
- data/spec/rails_app/babel.config.js +72 -0
- data/spec/rails_app/bin/webpack +18 -0
- data/spec/rails_app/bin/webpack-dev-server +18 -0
- data/spec/rails_app/config/application.rb +15 -2
- data/spec/rails_app/config/environment.rb +2 -1
- data/spec/rails_app/config/environments/development.rb +5 -0
- data/spec/rails_app/config/environments/production.rb +3 -0
- data/spec/rails_app/config/environments/test.rb +5 -0
- data/spec/rails_app/config/initializers/activity_notification.rb +8 -0
- data/spec/rails_app/config/initializers/devise_token_auth.rb +55 -0
- data/spec/rails_app/config/initializers/mysql.rb +9 -0
- data/spec/rails_app/config/locales/activity_notification.en.yml +2 -2
- data/spec/rails_app/config/routes.rb +33 -1
- data/spec/rails_app/config/webpack/development.js +5 -0
- data/spec/rails_app/config/webpack/environment.js +7 -0
- data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
- data/spec/rails_app/config/webpack/production.js +5 -0
- data/spec/rails_app/config/webpack/test.js +5 -0
- data/spec/rails_app/config/webpacker.yml +97 -0
- data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +10 -0
- data/spec/rails_app/db/schema.rb +4 -1
- data/spec/rails_app/db/seeds.rb +1 -0
- data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +14 -0
- data/spec/rails_app/package.json +23 -0
- data/spec/rails_app/postcss.config.js +12 -0
- data/spec/roles/acts_as_group_spec.rb +0 -2
- data/spec/roles/acts_as_notifiable_spec.rb +1 -3
- data/spec/roles/acts_as_notifier_spec.rb +0 -2
- data/spec/roles/acts_as_target_spec.rb +0 -4
- data/spec/spec_helper.rb +7 -15
- data/spec/version_spec.rb +31 -0
- metadata +187 -13
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
<div class="list_button_wrapper">
|
|
11
11
|
<%= link_to 'Edit Article', edit_article_path(@article), class: "gray_button" %>
|
|
12
|
-
|
|
12
|
+
<%#= link_to 'Destroy Article', @article, method: :delete, data: { confirm: 'Are you sure?' }, class: "gray_button" %>
|
|
13
13
|
</div>
|
|
14
14
|
</div>
|
|
15
15
|
</div>
|
|
@@ -30,18 +30,16 @@
|
|
|
30
30
|
<%#= render_notifications_of current_user, fallback: :default_without_grouping, index_content: :with_attributes, with_group_members: true %>
|
|
31
31
|
<% end %>
|
|
32
32
|
</div>
|
|
33
|
-
<% if user_signed_in? and current_user.admin? and respond_to?('admins_notifications_path') %>
|
|
34
|
-
<div class="header_menu_wrapper">
|
|
35
|
-
<p>
|
|
36
|
-
<%= link_to "Admin notifications", admins_notifications_path %> /
|
|
37
|
-
<%= link_to "subscriptions", admins_subscriptions_path %>
|
|
38
|
-
</p>
|
|
39
|
-
</div>
|
|
40
|
-
<% end %>
|
|
41
33
|
<div class="header_menu_wrapper">
|
|
42
34
|
<p>
|
|
43
|
-
<%= link_to 'Preview
|
|
44
|
-
<%= " · "
|
|
35
|
+
<%= link_to 'Preview Email', "/rails/mailers" %>
|
|
36
|
+
<%= " · " if !user_signed_in? or (current_user.admin? and respond_to?('admins_notifications_path')) %>
|
|
37
|
+
</p>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="header_menu_wrapper">
|
|
40
|
+
<p>
|
|
41
|
+
<%= link_to 'SPA', "/spa/" %>
|
|
42
|
+
<%= " · " %>
|
|
45
43
|
</p>
|
|
46
44
|
</div>
|
|
47
45
|
</div>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module.exports = function(api) {
|
|
2
|
+
var validEnv = ['development', 'test', 'production']
|
|
3
|
+
var currentEnv = api.env()
|
|
4
|
+
var isDevelopmentEnv = api.env('development')
|
|
5
|
+
var isProductionEnv = api.env('production')
|
|
6
|
+
var isTestEnv = api.env('test')
|
|
7
|
+
|
|
8
|
+
if (!validEnv.includes(currentEnv)) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
'Please specify a valid `NODE_ENV` or ' +
|
|
11
|
+
'`BABEL_ENV` environment variables. Valid values are "development", ' +
|
|
12
|
+
'"test", and "production". Instead, received: ' +
|
|
13
|
+
JSON.stringify(currentEnv) +
|
|
14
|
+
'.'
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
presets: [
|
|
20
|
+
isTestEnv && [
|
|
21
|
+
'@babel/preset-env',
|
|
22
|
+
{
|
|
23
|
+
targets: {
|
|
24
|
+
node: 'current'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
(isProductionEnv || isDevelopmentEnv) && [
|
|
29
|
+
'@babel/preset-env',
|
|
30
|
+
{
|
|
31
|
+
forceAllTransforms: true,
|
|
32
|
+
useBuiltIns: 'entry',
|
|
33
|
+
corejs: 3,
|
|
34
|
+
modules: false,
|
|
35
|
+
exclude: ['transform-typeof-symbol']
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
].filter(Boolean),
|
|
39
|
+
plugins: [
|
|
40
|
+
'babel-plugin-macros',
|
|
41
|
+
'@babel/plugin-syntax-dynamic-import',
|
|
42
|
+
isTestEnv && 'babel-plugin-dynamic-import-node',
|
|
43
|
+
'@babel/plugin-transform-destructuring',
|
|
44
|
+
[
|
|
45
|
+
'@babel/plugin-proposal-class-properties',
|
|
46
|
+
{
|
|
47
|
+
loose: true
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
'@babel/plugin-proposal-object-rest-spread',
|
|
52
|
+
{
|
|
53
|
+
useBuiltIns: true
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
'@babel/plugin-transform-runtime',
|
|
58
|
+
{
|
|
59
|
+
helpers: false,
|
|
60
|
+
regenerator: true,
|
|
61
|
+
corejs: false
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
'@babel/plugin-transform-regenerator',
|
|
66
|
+
{
|
|
67
|
+
async: false
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
].filter(Boolean)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
|
|
4
|
+
ENV["NODE_ENV"] ||= "development"
|
|
5
|
+
|
|
6
|
+
require "pathname"
|
|
7
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
8
|
+
Pathname.new(__FILE__).realpath)
|
|
9
|
+
|
|
10
|
+
require "bundler/setup"
|
|
11
|
+
|
|
12
|
+
require "webpacker"
|
|
13
|
+
require "webpacker/webpack_runner"
|
|
14
|
+
|
|
15
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
|
16
|
+
Dir.chdir(APP_ROOT) do
|
|
17
|
+
Webpacker::WebpackRunner.run(ARGV)
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
|
|
4
|
+
ENV["NODE_ENV"] ||= "development"
|
|
5
|
+
|
|
6
|
+
require "pathname"
|
|
7
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
8
|
+
Pathname.new(__FILE__).realpath)
|
|
9
|
+
|
|
10
|
+
require "bundler/setup"
|
|
11
|
+
|
|
12
|
+
require "webpacker"
|
|
13
|
+
require "webpacker/dev_server_runner"
|
|
14
|
+
|
|
15
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
|
16
|
+
Dir.chdir(APP_ROOT) do
|
|
17
|
+
Webpacker::DevServerRunner.run(ARGV)
|
|
18
|
+
end
|
|
@@ -4,9 +4,10 @@ require File.expand_path('../boot', __FILE__)
|
|
|
4
4
|
if ENV['AN_ORM'] == 'mongoid'
|
|
5
5
|
require 'mongoid'
|
|
6
6
|
require 'rails'
|
|
7
|
-
|
|
7
|
+
unless Rails.env.test?
|
|
8
8
|
Mongoid.load!(File.expand_path("config/mongoid.yml"), :development)
|
|
9
9
|
end
|
|
10
|
+
# Load dynamoid configuration if necessary:
|
|
10
11
|
elsif ENV['AN_ORM'] == 'dynamoid'
|
|
11
12
|
require 'dynamoid'
|
|
12
13
|
require 'rails'
|
|
@@ -14,7 +15,9 @@ elsif ENV['AN_ORM'] == 'dynamoid'
|
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
# Pick the frameworks you want:
|
|
17
|
-
|
|
18
|
+
if ENV['AN_ORM'] == 'mongoid' && ENV['AN_TEST_DB'] == 'mongodb'
|
|
19
|
+
require "mongoid/railtie"
|
|
20
|
+
else
|
|
18
21
|
require "active_record/railtie"
|
|
19
22
|
end
|
|
20
23
|
require "action_controller/railtie"
|
|
@@ -35,6 +38,16 @@ module Dummy
|
|
|
35
38
|
if Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 2 && ENV['AN_TEST_DB'] != 'mongodb'
|
|
36
39
|
config.active_record.sqlite3.represent_boolean_as_integer = true
|
|
37
40
|
end
|
|
41
|
+
|
|
42
|
+
# Configure CORS for API mode
|
|
43
|
+
if defined?(Rack::Cors)
|
|
44
|
+
config.middleware.insert_before 0, Rack::Cors do
|
|
45
|
+
allow do
|
|
46
|
+
origins '*'
|
|
47
|
+
resource '*', :headers => :any, :methods => [:get, :post, :put, :delete]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
38
51
|
end
|
|
39
52
|
end
|
|
40
53
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# Load the Rails application.
|
|
2
2
|
require File.expand_path('../application', __FILE__)
|
|
3
3
|
|
|
4
|
-
# Demo application uses Devise
|
|
4
|
+
# Demo application uses Devise and Devise Token Auth
|
|
5
5
|
require 'devise'
|
|
6
|
+
require 'devise_token_auth'
|
|
6
7
|
|
|
7
8
|
# Initialize the Rails application.
|
|
8
9
|
Rails.application.initialize!
|
|
@@ -47,6 +47,11 @@ Rails.application.configure do
|
|
|
47
47
|
# For notification email preview
|
|
48
48
|
config.action_mailer.preview_path = "#{Rails.root}/lib/mailer_previews"
|
|
49
49
|
|
|
50
|
+
# Specifies delivery job for mail
|
|
51
|
+
if Rails::VERSION::MAJOR >= 6
|
|
52
|
+
config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
|
|
53
|
+
end
|
|
54
|
+
|
|
50
55
|
# Configration for bullet
|
|
51
56
|
config.after_initialize do
|
|
52
57
|
Bullet.enable = true
|
|
@@ -64,6 +64,9 @@ Rails.application.configure do
|
|
|
64
64
|
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
|
65
65
|
# config.action_mailer.raise_delivery_errors = false
|
|
66
66
|
|
|
67
|
+
# Specifies delivery job for mail
|
|
68
|
+
config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
|
|
69
|
+
|
|
67
70
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
|
68
71
|
# the I18n.default_locale when a translation cannot be found).
|
|
69
72
|
config.i18n.fallbacks = true
|
|
@@ -54,4 +54,9 @@ Rails.application.configure do
|
|
|
54
54
|
|
|
55
55
|
# Set default_url_options for devise and notification email.
|
|
56
56
|
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
|
57
|
+
|
|
58
|
+
# Specifies delivery job for mail
|
|
59
|
+
if Rails::VERSION::MAJOR >= 6
|
|
60
|
+
config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
|
|
61
|
+
end
|
|
57
62
|
end
|
|
@@ -71,6 +71,11 @@ ActivityNotification.configure do |config|
|
|
|
71
71
|
# Set true when you want to turn on WebSocket subscription using ActionCable as default.
|
|
72
72
|
config.action_cable_enabled = false
|
|
73
73
|
|
|
74
|
+
# Configure if WebSocket API subscription using ActionCable is enabled.
|
|
75
|
+
# Note that you can configure them for each model by acts_as roles.
|
|
76
|
+
# Set true when you want to turn on WebSocket API subscription using ActionCable as default.
|
|
77
|
+
config.action_cable_api_enabled = false
|
|
78
|
+
|
|
74
79
|
# Configure if ctivity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise.
|
|
75
80
|
# Note that you can configure them for each model by acts_as roles.
|
|
76
81
|
# Set true when you want to use Device integration with WebSocket subscription using ActionCable as default.
|
|
@@ -79,4 +84,7 @@ ActivityNotification.configure do |config|
|
|
|
79
84
|
# Configure notification channel prefix for ActionCable.
|
|
80
85
|
config.notification_channel_prefix = 'activity_notification_channel'
|
|
81
86
|
|
|
87
|
+
# Configure notification API channel prefix for ActionCable.
|
|
88
|
+
config.notification_api_channel_prefix = 'activity_notification_api_channel'
|
|
89
|
+
|
|
82
90
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
DeviseTokenAuth.setup do |config|
|
|
4
|
+
# By default the authorization headers will change after each request. The
|
|
5
|
+
# client is responsible for keeping track of the changing tokens. Change
|
|
6
|
+
# this to false to prevent the Authorization header from changing after
|
|
7
|
+
# each request.
|
|
8
|
+
config.change_headers_on_each_request = false
|
|
9
|
+
|
|
10
|
+
# By default, users will need to re-authenticate after 2 weeks. This setting
|
|
11
|
+
# determines how long tokens will remain valid after they are issued.
|
|
12
|
+
config.token_lifespan = 1.hour
|
|
13
|
+
|
|
14
|
+
# Limiting the token_cost to just 4 in testing will increase the performance of
|
|
15
|
+
# your test suite dramatically. The possible cost value is within range from 4
|
|
16
|
+
# to 31. It is recommended to not use a value more than 10 in other environments.
|
|
17
|
+
config.token_cost = Rails.env.test? ? 4 : 10
|
|
18
|
+
|
|
19
|
+
# Sets the max number of concurrent devices per user, which is 10 by default.
|
|
20
|
+
# After this limit is reached, the oldest tokens will be removed.
|
|
21
|
+
# config.max_number_of_devices = 10
|
|
22
|
+
|
|
23
|
+
# Sometimes it's necessary to make several requests to the API at the same
|
|
24
|
+
# time. In this case, each request in the batch will need to share the same
|
|
25
|
+
# auth token. This setting determines how far apart the requests can be while
|
|
26
|
+
# still using the same auth token.
|
|
27
|
+
# config.batch_request_buffer_throttle = 5.seconds
|
|
28
|
+
|
|
29
|
+
# This route will be the prefix for all oauth2 redirect callbacks. For
|
|
30
|
+
# example, using the default '/omniauth', the github oauth2 provider will
|
|
31
|
+
# redirect successful authentications to '/omniauth/github/callback'
|
|
32
|
+
# config.omniauth_prefix = "/omniauth"
|
|
33
|
+
|
|
34
|
+
# By default sending current password is not needed for the password update.
|
|
35
|
+
# Uncomment to enforce current_password param to be checked before all
|
|
36
|
+
# attribute updates. Set it to :password if you want it to be checked only if
|
|
37
|
+
# password is updated.
|
|
38
|
+
# config.check_current_password_before_update = :attributes
|
|
39
|
+
|
|
40
|
+
# By default we will use callbacks for single omniauth.
|
|
41
|
+
# It depends on fields like email, provider and uid.
|
|
42
|
+
# config.default_callbacks = true
|
|
43
|
+
|
|
44
|
+
# Makes it possible to change the headers names
|
|
45
|
+
# config.headers_names = {:'access-token' => 'access-token',
|
|
46
|
+
# :'client' => 'client',
|
|
47
|
+
# :'expiry' => 'expiry',
|
|
48
|
+
# :'uid' => 'uid',
|
|
49
|
+
# :'token-type' => 'token-type' }
|
|
50
|
+
|
|
51
|
+
# By default, only Bearer Token authentication is implemented out of the box.
|
|
52
|
+
# If, however, you wish to integrate with legacy Devise authentication, you can
|
|
53
|
+
# do so by enabling this flag. NOTE: This feature is highly experimental!
|
|
54
|
+
# config.enable_standard_devise_support = false
|
|
55
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Creates DATETIME(3) column types by default which support microseconds.
|
|
2
|
+
# Without it, only regular (second precise) DATETIME columns are created.
|
|
3
|
+
if defined?(ActiveRecord)
|
|
4
|
+
module ActiveRecord::ConnectionAdapters
|
|
5
|
+
if defined?(AbstractMysqlAdapter)
|
|
6
|
+
AbstractMysqlAdapter::NATIVE_DATABASE_TYPES[:datetime][:limit] = 3
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -7,9 +7,9 @@ en:
|
|
|
7
7
|
create:
|
|
8
8
|
text: 'Article has been created'
|
|
9
9
|
update:
|
|
10
|
-
text: 'Article %{article_title} has been updated'
|
|
10
|
+
text: 'Article "%{article_title}" has been updated'
|
|
11
11
|
destroy:
|
|
12
|
-
text: '
|
|
12
|
+
text: 'The author removed an article "%{article_title}"'
|
|
13
13
|
comment:
|
|
14
14
|
create:
|
|
15
15
|
text: '%{notifier_name} posted a comment on the article "%{article_title}"'
|
|
@@ -1,14 +1,46 @@
|
|
|
1
1
|
Rails.application.routes.draw do
|
|
2
|
+
# Routes for example Rails application
|
|
2
3
|
root to: 'articles#index'
|
|
3
4
|
devise_for :users
|
|
4
|
-
resources :articles
|
|
5
|
+
resources :articles, except: [:destroy]
|
|
5
6
|
resources :comments, only: [:create, :destroy]
|
|
6
7
|
|
|
8
|
+
# activity_notification routes for users
|
|
7
9
|
notify_to :users, with_subscription: true
|
|
8
10
|
notify_to :users, with_devise: :users, devise_default_routes: true, with_subscription: true
|
|
9
11
|
|
|
12
|
+
# activity_notification routes for admins
|
|
10
13
|
notify_to :admins, with_devise: :users, with_subscription: true
|
|
11
14
|
scope :admins, as: :admins do
|
|
12
15
|
notify_to :admins, with_devise: :users, devise_default_routes: true, with_subscription: true, routing_scope: :admins
|
|
13
16
|
end
|
|
17
|
+
|
|
18
|
+
# Routes for single page application working with activity_notification REST API backend
|
|
19
|
+
resources :spa, only: [:index]
|
|
20
|
+
namespace :api do
|
|
21
|
+
scope :"v#{ActivityNotification::GEM_VERSION::MAJOR}" do
|
|
22
|
+
mount_devise_token_auth_for 'User', at: 'auth'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Routes of activity_notification REST API backend for users
|
|
27
|
+
scope :api do
|
|
28
|
+
scope :"v#{ActivityNotification::GEM_VERSION::MAJOR}" do
|
|
29
|
+
notify_to :users, api_mode: true, with_subscription: true
|
|
30
|
+
notify_to :users, api_mode: true, with_devise: :users, devise_default_routes: true, with_subscription: true
|
|
31
|
+
resources :apidocs, only: [:index], controller: 'activity_notification/apidocs'
|
|
32
|
+
resources :users, only: [:index, :show]
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Routes of activity_notification REST API backend for admins
|
|
37
|
+
scope :api do
|
|
38
|
+
scope :"v#{ActivityNotification::GEM_VERSION::MAJOR}" do
|
|
39
|
+
notify_to :admins, api_mode: true, with_devise: :users, with_subscription: true
|
|
40
|
+
scope :admins, as: :admins do
|
|
41
|
+
notify_to :admins, api_mode: true, with_devise: :users, devise_default_routes: true, with_subscription: true
|
|
42
|
+
end
|
|
43
|
+
resources :admins, only: [:index, :show]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
14
46
|
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const { environment } = require('@rails/webpacker')
|
|
2
|
+
const { VueLoaderPlugin } = require('vue-loader')
|
|
3
|
+
const vue = require('./loaders/vue')
|
|
4
|
+
|
|
5
|
+
environment.plugins.prepend('VueLoaderPlugin', new VueLoaderPlugin())
|
|
6
|
+
environment.loaders.prepend('vue', vue)
|
|
7
|
+
module.exports = environment
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
|
2
|
+
|
|
3
|
+
default: &default
|
|
4
|
+
source_path: app/javascript
|
|
5
|
+
source_entry_path: packs
|
|
6
|
+
public_root_path: public
|
|
7
|
+
public_output_path: packs
|
|
8
|
+
cache_path: tmp/cache/webpacker
|
|
9
|
+
check_yarn_integrity: false
|
|
10
|
+
webpack_compile_output: true
|
|
11
|
+
|
|
12
|
+
# Additional paths webpack should lookup modules
|
|
13
|
+
# ['app/assets', 'engine/foo/app/assets']
|
|
14
|
+
resolved_paths: []
|
|
15
|
+
|
|
16
|
+
# Reload manifest.json on all requests so we reload latest compiled packs
|
|
17
|
+
cache_manifest: false
|
|
18
|
+
|
|
19
|
+
# Extract and emit a css file
|
|
20
|
+
extract_css: false
|
|
21
|
+
|
|
22
|
+
static_assets_extensions:
|
|
23
|
+
- .jpg
|
|
24
|
+
- .jpeg
|
|
25
|
+
- .png
|
|
26
|
+
- .gif
|
|
27
|
+
- .tiff
|
|
28
|
+
- .ico
|
|
29
|
+
- .svg
|
|
30
|
+
- .eot
|
|
31
|
+
- .otf
|
|
32
|
+
- .ttf
|
|
33
|
+
- .woff
|
|
34
|
+
- .woff2
|
|
35
|
+
|
|
36
|
+
extensions:
|
|
37
|
+
- .vue
|
|
38
|
+
- .mjs
|
|
39
|
+
- .js
|
|
40
|
+
- .sass
|
|
41
|
+
- .scss
|
|
42
|
+
- .css
|
|
43
|
+
- .module.sass
|
|
44
|
+
- .module.scss
|
|
45
|
+
- .module.css
|
|
46
|
+
- .png
|
|
47
|
+
- .svg
|
|
48
|
+
- .gif
|
|
49
|
+
- .jpeg
|
|
50
|
+
- .jpg
|
|
51
|
+
|
|
52
|
+
development:
|
|
53
|
+
<<: *default
|
|
54
|
+
compile: true
|
|
55
|
+
|
|
56
|
+
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
|
|
57
|
+
check_yarn_integrity: true
|
|
58
|
+
|
|
59
|
+
# Reference: https://webpack.js.org/configuration/dev-server/
|
|
60
|
+
dev_server:
|
|
61
|
+
https: false
|
|
62
|
+
host: localhost
|
|
63
|
+
port: 3035
|
|
64
|
+
public: localhost:3035
|
|
65
|
+
hmr: false
|
|
66
|
+
# Inline should be set to true if using HMR
|
|
67
|
+
inline: true
|
|
68
|
+
overlay: true
|
|
69
|
+
compress: true
|
|
70
|
+
disable_host_check: true
|
|
71
|
+
use_local_ip: false
|
|
72
|
+
quiet: false
|
|
73
|
+
pretty: false
|
|
74
|
+
headers:
|
|
75
|
+
'Access-Control-Allow-Origin': '*'
|
|
76
|
+
watch_options:
|
|
77
|
+
ignored: '**/node_modules/**'
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
test:
|
|
81
|
+
<<: *default
|
|
82
|
+
compile: true
|
|
83
|
+
|
|
84
|
+
# Compile test packs to a separate directory
|
|
85
|
+
public_output_path: packs-test
|
|
86
|
+
|
|
87
|
+
production:
|
|
88
|
+
<<: *default
|
|
89
|
+
|
|
90
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
|
91
|
+
compile: false
|
|
92
|
+
|
|
93
|
+
# Extract and emit a css file
|
|
94
|
+
extract_css: false
|
|
95
|
+
|
|
96
|
+
# Cache manifest.json for performance
|
|
97
|
+
cache_manifest: true
|