activity_notification 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
  4. data/.github/pull_request_template.md +13 -0
  5. data/.gitignore +10 -3
  6. data/.travis.yml +6 -5
  7. data/CHANGELOG.md +22 -0
  8. data/Gemfile +8 -2
  9. data/Procfile +1 -1
  10. data/README.md +153 -1510
  11. data/activity_notification.gemspec +4 -1
  12. data/app/channels/activity_notification/notification_api_channel.rb +12 -0
  13. data/app/channels/activity_notification/notification_api_with_devise_channel.rb +46 -0
  14. data/app/channels/activity_notification/notification_channel.rb +1 -1
  15. data/app/channels/activity_notification/notification_with_devise_channel.rb +1 -1
  16. data/app/controllers/activity_notification/apidocs_controller.rb +75 -0
  17. data/app/controllers/activity_notification/notifications_api_controller.rb +143 -0
  18. data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +7 -0
  19. data/app/controllers/activity_notification/notifications_controller.rb +79 -53
  20. data/app/controllers/activity_notification/subscriptions_api_controller.rb +197 -0
  21. data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +7 -0
  22. data/app/controllers/activity_notification/subscriptions_controller.rb +78 -69
  23. data/app/views/activity_notification/notifications/default/_default.html.erb +18 -18
  24. data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +14 -14
  25. data/app/views/activity_notification/notifications/default/index.html.erb +6 -6
  26. data/app/views/activity_notification/optional_targets/default/action_cable_channel/_default.html.erb +176 -0
  27. data/app/views/activity_notification/subscriptions/default/_form.html.erb +1 -1
  28. data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +3 -31
  29. data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +7 -7
  30. data/app/views/activity_notification/subscriptions/default/index.html.erb +11 -7
  31. data/bin/deploy_on_heroku.sh +3 -1
  32. data/docs/CODE_OF_CONDUCT.md +76 -0
  33. data/docs/CONTRIBUTING.md +36 -0
  34. data/docs/Functions.md +1130 -0
  35. data/docs/Setup.md +674 -0
  36. data/docs/Testing.md +148 -0
  37. data/gemfiles/Gemfile.rails-4.2 +3 -0
  38. data/gemfiles/Gemfile.rails-5.0 +3 -0
  39. data/gemfiles/Gemfile.rails-5.1 +3 -0
  40. data/gemfiles/Gemfile.rails-5.2 +3 -0
  41. data/gemfiles/{Gemfile.rails-6.0.rc → Gemfile.rails-6.0} +5 -3
  42. data/lib/activity_notification.rb +13 -1
  43. data/lib/activity_notification/apis/notification_api.rb +29 -92
  44. data/lib/activity_notification/apis/subscription_api.rb +20 -8
  45. data/lib/activity_notification/apis/swagger.rb +6 -0
  46. data/lib/activity_notification/config.rb +41 -21
  47. data/lib/activity_notification/controllers/common_api_controller.rb +30 -0
  48. data/lib/activity_notification/controllers/common_controller.rb +44 -20
  49. data/lib/activity_notification/controllers/concerns/swagger/error_responses.rb +55 -0
  50. data/lib/activity_notification/controllers/concerns/swagger/notifications_api.rb +273 -0
  51. data/lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb +92 -0
  52. data/lib/activity_notification/controllers/concerns/swagger/subscriptions_api.rb +405 -0
  53. data/lib/activity_notification/controllers/concerns/swagger/subscriptions_parameters.rb +50 -0
  54. data/lib/activity_notification/controllers/devise_authentication_controller.rb +7 -6
  55. data/lib/activity_notification/gem_version.rb +14 -0
  56. data/lib/activity_notification/helpers/errors.rb +2 -0
  57. data/lib/activity_notification/helpers/view_helpers.rb +4 -0
  58. data/lib/activity_notification/mailers/helpers.rb +17 -10
  59. data/lib/activity_notification/models/concerns/notifiable.rb +26 -10
  60. data/lib/activity_notification/models/concerns/subscriber.rb +12 -1
  61. data/lib/activity_notification/models/concerns/swagger/error_schema.rb +36 -0
  62. data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +209 -0
  63. data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +162 -0
  64. data/lib/activity_notification/models/concerns/target.rb +36 -10
  65. data/lib/activity_notification/models/notification.rb +1 -0
  66. data/lib/activity_notification/models/subscription.rb +1 -0
  67. data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +69 -0
  68. data/lib/activity_notification/optional_targets/action_cable_channel.rb +68 -0
  69. data/lib/activity_notification/optional_targets/base.rb +7 -13
  70. data/lib/activity_notification/orm/active_record/notification.rb +17 -1
  71. data/lib/activity_notification/orm/active_record/subscription.rb +1 -1
  72. data/lib/activity_notification/orm/dynamoid.rb +28 -0
  73. data/lib/activity_notification/orm/dynamoid/extension.rb +79 -1
  74. data/lib/activity_notification/orm/dynamoid/notification.rb +1 -1
  75. data/lib/activity_notification/orm/dynamoid/subscription.rb +1 -1
  76. data/lib/activity_notification/orm/mongoid.rb +22 -0
  77. data/lib/activity_notification/orm/mongoid/notification.rb +17 -1
  78. data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
  79. data/lib/activity_notification/rails/routes.rb +132 -48
  80. data/lib/activity_notification/renderable.rb +13 -2
  81. data/lib/activity_notification/roles/acts_as_notifiable.rb +38 -20
  82. data/lib/activity_notification/version.rb +1 -1
  83. data/lib/generators/activity_notification/controllers_generator.rb +2 -1
  84. data/lib/generators/templates/activity_notification.rb +8 -0
  85. data/lib/generators/templates/controllers/notifications_api_controller.rb +31 -0
  86. data/lib/generators/templates/controllers/notifications_api_with_devise_controller.rb +31 -0
  87. data/lib/generators/templates/controllers/notifications_controller.rb +1 -37
  88. data/lib/generators/templates/controllers/notifications_with_devise_controller.rb +1 -45
  89. data/lib/generators/templates/controllers/subscriptions_api_controller.rb +61 -0
  90. data/lib/generators/templates/controllers/subscriptions_api_with_devise_controller.rb +61 -0
  91. data/lib/generators/templates/controllers/subscriptions_controller.rb +14 -37
  92. data/lib/generators/templates/controllers/subscriptions_with_devise_controller.rb +14 -45
  93. data/lib/generators/templates/models/README +8 -4
  94. data/lib/generators/templates/models/notification.rb +1 -1
  95. data/lib/generators/templates/models/subscription.rb +1 -1
  96. data/package.json +8 -0
  97. data/spec/channels/notification_api_channel_shared_examples.rb +59 -0
  98. data/spec/channels/notification_api_channel_spec.rb +51 -0
  99. data/spec/channels/notification_api_with_devise_channel_spec.rb +78 -0
  100. data/spec/concerns/apis/notification_api_spec.rb +37 -2
  101. data/spec/concerns/models/notifiable_spec.rb +64 -0
  102. data/spec/concerns/models/subscriber_spec.rb +13 -16
  103. data/spec/concerns/models/target_spec.rb +32 -0
  104. data/spec/concerns/renderable_spec.rb +2 -2
  105. data/spec/controllers/controller_spec_utility.rb +136 -0
  106. data/spec/controllers/notifications_api_controller_shared_examples.rb +506 -0
  107. data/spec/controllers/notifications_api_controller_spec.rb +19 -0
  108. data/spec/controllers/notifications_api_with_devise_controller_spec.rb +60 -0
  109. data/spec/controllers/notifications_controller_shared_examples.rb +54 -79
  110. data/spec/controllers/notifications_controller_spec.rb +1 -2
  111. data/spec/controllers/notifications_with_devise_controller_spec.rb +3 -12
  112. data/spec/controllers/subscriptions_api_controller_shared_examples.rb +750 -0
  113. data/spec/controllers/subscriptions_api_controller_spec.rb +19 -0
  114. data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +60 -0
  115. data/spec/controllers/subscriptions_controller_shared_examples.rb +94 -121
  116. data/spec/controllers/subscriptions_controller_spec.rb +1 -2
  117. data/spec/controllers/subscriptions_with_devise_controller_spec.rb +3 -12
  118. data/spec/helpers/view_helpers_spec.rb +4 -11
  119. data/spec/mailers/mailer_spec.rb +41 -0
  120. data/spec/models/notification_spec.rb +17 -0
  121. data/spec/models/subscription_spec.rb +0 -13
  122. data/spec/optional_targets/action_cable_api_channel_spec.rb +37 -0
  123. data/spec/optional_targets/action_cable_channel_spec.rb +44 -0
  124. data/spec/optional_targets/amazon_sns_spec.rb +0 -2
  125. data/spec/optional_targets/slack_spec.rb +0 -2
  126. data/spec/rails_app/Rakefile +9 -0
  127. data/spec/rails_app/app/assets/config/manifest.js +3 -0
  128. data/spec/rails_app/app/assets/images/.keep +0 -0
  129. data/spec/rails_app/app/controllers/admins_controller.rb +21 -0
  130. data/spec/rails_app/app/controllers/application_controller.rb +1 -1
  131. data/spec/rails_app/app/controllers/articles_controller.rb +6 -3
  132. data/spec/rails_app/app/controllers/spa_controller.rb +7 -0
  133. data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -65
  134. data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -73
  135. data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -77
  136. data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -85
  137. data/spec/rails_app/app/controllers/users_controller.rb +21 -0
  138. data/spec/rails_app/app/javascript/App.vue +104 -0
  139. data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +83 -0
  140. data/spec/rails_app/app/javascript/components/Top.vue +99 -0
  141. data/spec/rails_app/app/javascript/components/notifications/Index.vue +200 -0
  142. data/spec/rails_app/app/javascript/components/notifications/Notification.vue +133 -0
  143. data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +122 -0
  144. data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +279 -0
  145. data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +112 -0
  146. data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +141 -0
  147. data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +226 -0
  148. data/spec/rails_app/app/javascript/config/development.js +5 -0
  149. data/spec/rails_app/app/javascript/config/environment.js +7 -0
  150. data/spec/rails_app/app/javascript/config/production.js +5 -0
  151. data/spec/rails_app/app/javascript/config/test.js +5 -0
  152. data/spec/rails_app/app/javascript/packs/application.js +18 -0
  153. data/spec/rails_app/app/javascript/packs/spa.js +11 -0
  154. data/spec/rails_app/app/javascript/store/auth.js +37 -0
  155. data/spec/rails_app/app/models/admin.rb +16 -15
  156. data/spec/rails_app/app/models/article.rb +26 -21
  157. data/spec/rails_app/app/models/comment.rb +24 -71
  158. data/spec/rails_app/app/models/user.rb +43 -20
  159. data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +146 -0
  160. data/spec/rails_app/app/views/articles/index.html.erb +51 -7
  161. data/spec/rails_app/app/views/articles/show.html.erb +1 -1
  162. data/spec/rails_app/app/views/layouts/_header.html.erb +8 -10
  163. data/spec/rails_app/app/views/spa/index.html.erb +2 -0
  164. data/spec/rails_app/babel.config.js +72 -0
  165. data/spec/rails_app/bin/webpack +18 -0
  166. data/spec/rails_app/bin/webpack-dev-server +18 -0
  167. data/spec/rails_app/config/application.rb +15 -2
  168. data/spec/rails_app/config/environment.rb +2 -1
  169. data/spec/rails_app/config/environments/development.rb +5 -0
  170. data/spec/rails_app/config/environments/production.rb +3 -0
  171. data/spec/rails_app/config/environments/test.rb +5 -0
  172. data/spec/rails_app/config/initializers/activity_notification.rb +8 -0
  173. data/spec/rails_app/config/initializers/devise_token_auth.rb +55 -0
  174. data/spec/rails_app/config/initializers/mysql.rb +9 -0
  175. data/spec/rails_app/config/locales/activity_notification.en.yml +2 -2
  176. data/spec/rails_app/config/routes.rb +33 -1
  177. data/spec/rails_app/config/webpack/development.js +5 -0
  178. data/spec/rails_app/config/webpack/environment.js +7 -0
  179. data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
  180. data/spec/rails_app/config/webpack/production.js +5 -0
  181. data/spec/rails_app/config/webpack/test.js +5 -0
  182. data/spec/rails_app/config/webpacker.yml +97 -0
  183. data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +10 -0
  184. data/spec/rails_app/db/schema.rb +4 -1
  185. data/spec/rails_app/db/seeds.rb +1 -0
  186. data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +14 -0
  187. data/spec/rails_app/package.json +23 -0
  188. data/spec/rails_app/postcss.config.js +12 -0
  189. data/spec/roles/acts_as_group_spec.rb +0 -2
  190. data/spec/roles/acts_as_notifiable_spec.rb +1 -3
  191. data/spec/roles/acts_as_notifier_spec.rb +0 -2
  192. data/spec/roles/acts_as_target_spec.rb +0 -4
  193. data/spec/spec_helper.rb +7 -15
  194. data/spec/version_spec.rb +31 -0
  195. 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
- <%= link_to 'Destroy Article', @article, method: :delete, data: { confirm: 'Are you sure?' }, class: "gray_button" %>
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 email', "/rails/mailers" %>
44
- <%= " · " unless user_signed_in? %>
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,2 @@
1
+ <div id='spa'/>
2
+ <%= javascript_pack_tag 'spa' %>
@@ -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
- if Rails.env != 'test'
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
- unless ENV['AN_ORM'] == 'mongoid' && ENV['AN_TEST_DB'] == 'mongodb'
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: 'Some user removed an article!'
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,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -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,6 @@
1
+ module.exports = {
2
+ test: /\.vue(\.erb)?$/,
3
+ use: [{
4
+ loader: 'vue-loader'
5
+ }]
6
+ }
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -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