activity_notification 0.0.10 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +74 -58
- data/README.md +53 -26
- data/activity_notification.gemspec +2 -0
- data/app/controllers/activity_notification/notifications_controller.rb +4 -4
- data/app/mailers/activity_notification/mailer.rb +9 -3
- data/app/views/activity_notification/mailer/default/default.html.erb +9 -4
- data/app/views/activity_notification/mailer/default/default.text.erb +10 -0
- data/app/views/activity_notification/notifications/default/_default.html.erb +173 -34
- data/app/views/activity_notification/notifications/default/_index.html.erb +119 -11
- data/app/views/activity_notification/notifications/default/destroy.js.erb +2 -2
- data/app/views/activity_notification/notifications/default/index.html.erb +25 -14
- data/app/views/activity_notification/notifications/default/open.js.erb +2 -2
- data/app/views/activity_notification/notifications/default/open_all.js.erb +2 -2
- data/app/views/activity_notification/notifications/default/show.html.erb +1 -1
- data/gemfiles/Gemfile.rails-4.2 +0 -2
- data/gemfiles/Gemfile.rails-4.2.lock +3 -3
- data/gemfiles/Gemfile.rails-5.0 +1 -3
- data/lib/activity_notification.rb +10 -9
- data/lib/activity_notification/apis/notification_api.rb +108 -14
- data/lib/activity_notification/common.rb +11 -2
- data/lib/activity_notification/config.rb +13 -13
- data/lib/activity_notification/helpers/view_helpers.rb +26 -4
- data/lib/activity_notification/mailers/helpers.rb +8 -4
- data/lib/activity_notification/models.rb +4 -0
- data/lib/activity_notification/models/concerns/group.rb +32 -0
- data/lib/activity_notification/models/concerns/notifiable.rb +60 -32
- data/lib/activity_notification/models/concerns/notifier.rb +17 -1
- data/lib/activity_notification/models/concerns/target.rb +114 -55
- data/lib/activity_notification/models/notification.rb +26 -25
- data/lib/activity_notification/rails.rb +1 -0
- data/lib/activity_notification/renderable.rb +8 -3
- data/lib/activity_notification/roles/acts_as_common.rb +28 -0
- data/lib/activity_notification/roles/acts_as_group.rb +38 -0
- data/lib/activity_notification/roles/acts_as_notifiable.rb +56 -22
- data/lib/activity_notification/roles/acts_as_notifier.rb +25 -2
- data/lib/activity_notification/roles/acts_as_target.rb +27 -9
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/templates/activity_notification.rb +1 -1
- data/spec/concerns/apis/notification_api_spec.rb +361 -2
- data/spec/concerns/common_spec.rb +36 -0
- data/spec/concerns/models/group_spec.rb +61 -0
- data/spec/concerns/models/notifiable_spec.rb +37 -0
- data/spec/concerns/models/notifier_spec.rb +48 -0
- data/spec/concerns/models/target_spec.rb +81 -31
- data/spec/factories/dummy/dummy_group.rb +4 -0
- data/spec/helpers/view_helpers_spec.rb +13 -0
- data/spec/mailers/mailer_spec.rb +8 -1
- data/spec/models/dummy/dummy_group_spec.rb +6 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +15 -0
- data/spec/rails_app/app/assets/stylesheets/reset.css +85 -0
- data/spec/rails_app/app/assets/stylesheets/style.css +244 -0
- data/spec/rails_app/app/controllers/articles_controller.rb +1 -1
- data/spec/rails_app/app/models/admin.rb +2 -1
- data/spec/rails_app/app/models/article.rb +9 -2
- data/spec/rails_app/app/models/comment.rb +8 -2
- data/spec/rails_app/app/models/dummy/dummy_group.rb +4 -0
- data/spec/rails_app/app/models/user.rb +8 -3
- data/spec/rails_app/app/views/articles/_form.html.erb +14 -10
- data/spec/rails_app/app/views/articles/edit.html.erb +8 -6
- data/spec/rails_app/app/views/articles/index.html.erb +59 -67
- data/spec/rails_app/app/views/articles/new.html.erb +7 -5
- data/spec/rails_app/app/views/articles/show.html.erb +47 -36
- data/spec/rails_app/app/views/layouts/_header.html.erb +36 -9
- data/spec/rails_app/app/views/layouts/application.html.erb +8 -6
- data/spec/rails_app/config/environments/development.rb +9 -0
- data/spec/rails_app/config/initializers/activity_notification.rb +1 -1
- data/spec/rails_app/db/schema.rb +14 -20
- data/spec/rails_app/db/seeds.rb +5 -5
- data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +13 -0
- data/spec/roles/acts_as_group_spec.rb +32 -0
- data/spec/roles/acts_as_notifiable_spec.rb +1 -1
- data/spec/roles/acts_as_notifier_spec.rb +15 -0
- data/spec/roles/acts_as_target_spec.rb +1 -1
- metadata +52 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 428fe6b5adf0df335cd293284bfaa4ef7edcd415
|
4
|
+
data.tar.gz: 10d9652b853e719fd4f50886682446fabac270a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 974b2c19ee0e9fec32dd9853325076300c0b31c0c38c5516ae3c51a0122966bbb65ed442d2eca1fa53a2fd81d61e0372622679849fe32d77b09c983068d40c95
|
7
|
+
data.tar.gz: e40bc4f0b7c8570a493fd325c73937db18f7223068278ef8da5348591ffb0417bdf624c1f6ac7fda7405a2e726efcfdeedfe7599d454ba3943c6b43c91b860b9
|
data/.travis.yml
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
|
+
branches:
|
4
|
+
except:
|
5
|
+
- images
|
6
|
+
|
3
7
|
rvm:
|
4
8
|
- 2.1.9
|
5
9
|
- 2.2.5
|
@@ -15,6 +19,8 @@ matrix:
|
|
15
19
|
exclude:
|
16
20
|
- rvm: 2.1.9
|
17
21
|
gemfile: gemfiles/Gemfile.rails-5.0
|
22
|
+
- rvm: 2.1.9
|
23
|
+
gemfile: Gemfile
|
18
24
|
allow_failures:
|
19
25
|
- rvm: ruby-head
|
20
26
|
fast_finish: true
|
data/Gemfile
CHANGED
@@ -2,11 +2,14 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'rails', '~>
|
6
|
-
|
7
|
-
|
5
|
+
gem 'rails', '~> 5.0.0'
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'bullet'
|
9
|
+
end
|
8
10
|
|
9
11
|
group :test do
|
12
|
+
gem 'rails-controller-testing'
|
10
13
|
gem 'ammeter'
|
11
14
|
gem 'timecop'
|
12
15
|
gem 'coveralls', require: false
|
data/Gemfile.lock
CHANGED
@@ -1,56 +1,62 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
activity_notification (0.0
|
4
|
+
activity_notification (1.0.0)
|
5
5
|
activerecord (>= 4.2.0)
|
6
6
|
i18n (>= 0.5.0)
|
7
|
+
jquery-rails (>= 3.1.1)
|
7
8
|
railties (>= 4.2.0, < 5.1)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
|
13
|
-
actionpack (=
|
14
|
-
|
15
|
-
|
13
|
+
actioncable (5.0.0.1)
|
14
|
+
actionpack (= 5.0.0.1)
|
15
|
+
nio4r (~> 1.2)
|
16
|
+
websocket-driver (~> 0.6.1)
|
17
|
+
actionmailer (5.0.0.1)
|
18
|
+
actionpack (= 5.0.0.1)
|
19
|
+
actionview (= 5.0.0.1)
|
20
|
+
activejob (= 5.0.0.1)
|
16
21
|
mail (~> 2.5, >= 2.5.4)
|
17
|
-
rails-dom-testing (~>
|
18
|
-
actionpack (
|
19
|
-
actionview (=
|
20
|
-
activesupport (=
|
21
|
-
rack (~>
|
22
|
-
rack-test (~> 0.6.
|
23
|
-
rails-dom-testing (~>
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
actionpack (5.0.0.1)
|
24
|
+
actionview (= 5.0.0.1)
|
25
|
+
activesupport (= 5.0.0.1)
|
26
|
+
rack (~> 2.0)
|
27
|
+
rack-test (~> 0.6.3)
|
28
|
+
rails-dom-testing (~> 2.0)
|
24
29
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
25
|
-
actionview (
|
26
|
-
activesupport (=
|
30
|
+
actionview (5.0.0.1)
|
31
|
+
activesupport (= 5.0.0.1)
|
27
32
|
builder (~> 3.1)
|
28
33
|
erubis (~> 2.7.0)
|
29
|
-
rails-dom-testing (~>
|
34
|
+
rails-dom-testing (~> 2.0)
|
30
35
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
31
|
-
activejob (
|
32
|
-
activesupport (=
|
33
|
-
globalid (>= 0.3.
|
34
|
-
activemodel (
|
35
|
-
activesupport (=
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
activejob (5.0.0.1)
|
37
|
+
activesupport (= 5.0.0.1)
|
38
|
+
globalid (>= 0.3.6)
|
39
|
+
activemodel (5.0.0.1)
|
40
|
+
activesupport (= 5.0.0.1)
|
41
|
+
activerecord (5.0.0.1)
|
42
|
+
activemodel (= 5.0.0.1)
|
43
|
+
activesupport (= 5.0.0.1)
|
44
|
+
arel (~> 7.0)
|
45
|
+
activesupport (5.0.0.1)
|
46
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
42
47
|
i18n (~> 0.7)
|
43
|
-
json (~> 1.7, >= 1.7.7)
|
44
48
|
minitest (~> 5.1)
|
45
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
46
49
|
tzinfo (~> 1.1)
|
47
|
-
ammeter (1.1.
|
50
|
+
ammeter (1.1.4)
|
48
51
|
activesupport (>= 3.0)
|
49
52
|
railties (>= 3.0)
|
50
53
|
rspec-rails (>= 2.2)
|
51
|
-
arel (
|
54
|
+
arel (7.1.2)
|
52
55
|
bcrypt (3.1.11)
|
53
56
|
builder (3.2.2)
|
57
|
+
bullet (5.4.2)
|
58
|
+
activesupport (>= 3.0.0)
|
59
|
+
uniform_notifier (~> 1.10.0)
|
54
60
|
concurrent-ruby (1.0.2)
|
55
61
|
coveralls (0.8.15)
|
56
62
|
json (>= 1.8, < 3)
|
@@ -79,52 +85,57 @@ GEM
|
|
79
85
|
rails-dom-testing (>= 1, < 3)
|
80
86
|
railties (>= 4.2.0)
|
81
87
|
thor (>= 0.14, < 2.0)
|
82
|
-
json (
|
88
|
+
json (2.0.2)
|
83
89
|
loofah (2.0.3)
|
84
90
|
nokogiri (>= 1.5.9)
|
85
91
|
mail (2.6.4)
|
86
92
|
mime-types (>= 1.16, < 4)
|
93
|
+
method_source (0.8.2)
|
87
94
|
mime-types (3.1)
|
88
95
|
mime-types-data (~> 3.2015)
|
89
96
|
mime-types-data (3.2016.0521)
|
90
97
|
mini_portile2 (2.1.0)
|
91
|
-
minitest (5.9.
|
98
|
+
minitest (5.9.1)
|
99
|
+
nio4r (1.2.1)
|
92
100
|
nokogiri (1.6.8)
|
93
101
|
mini_portile2 (~> 2.1.0)
|
94
102
|
pkg-config (~> 1.1.7)
|
95
103
|
orm_adapter (0.5.0)
|
96
104
|
pkg-config (1.1.7)
|
97
|
-
rack (
|
105
|
+
rack (2.0.1)
|
98
106
|
rack-test (0.6.3)
|
99
107
|
rack (>= 1.0)
|
100
|
-
rails (
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
+
rails (5.0.0.1)
|
109
|
+
actioncable (= 5.0.0.1)
|
110
|
+
actionmailer (= 5.0.0.1)
|
111
|
+
actionpack (= 5.0.0.1)
|
112
|
+
actionview (= 5.0.0.1)
|
113
|
+
activejob (= 5.0.0.1)
|
114
|
+
activemodel (= 5.0.0.1)
|
115
|
+
activerecord (= 5.0.0.1)
|
116
|
+
activesupport (= 5.0.0.1)
|
108
117
|
bundler (>= 1.3.0, < 2.0)
|
109
|
-
railties (=
|
110
|
-
sprockets-rails
|
111
|
-
rails-
|
112
|
-
|
113
|
-
|
114
|
-
activesupport (
|
118
|
+
railties (= 5.0.0.1)
|
119
|
+
sprockets-rails (>= 2.0.0)
|
120
|
+
rails-controller-testing (1.0.1)
|
121
|
+
actionpack (~> 5.x)
|
122
|
+
actionview (~> 5.x)
|
123
|
+
activesupport (~> 5.x)
|
124
|
+
rails-dom-testing (2.0.1)
|
125
|
+
activesupport (>= 4.2.0, < 6.0)
|
115
126
|
nokogiri (~> 1.6.0)
|
116
|
-
rails-deprecated_sanitizer (>= 1.0.1)
|
117
127
|
rails-html-sanitizer (1.0.3)
|
118
128
|
loofah (~> 2.0)
|
119
|
-
railties (
|
120
|
-
actionpack (=
|
121
|
-
activesupport (=
|
129
|
+
railties (5.0.0.1)
|
130
|
+
actionpack (= 5.0.0.1)
|
131
|
+
activesupport (= 5.0.0.1)
|
132
|
+
method_source
|
122
133
|
rake (>= 0.8.7)
|
123
134
|
thor (>= 0.18.1, < 2.0)
|
124
|
-
rake (11.
|
135
|
+
rake (11.3.0)
|
125
136
|
responders (2.3.0)
|
126
137
|
railties (>= 4.2.0, < 5.1)
|
127
|
-
rspec-core (3.5.
|
138
|
+
rspec-core (3.5.4)
|
128
139
|
rspec-support (~> 3.5.0)
|
129
140
|
rspec-expectations (3.5.0)
|
130
141
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -149,12 +160,12 @@ GEM
|
|
149
160
|
sprockets (3.7.0)
|
150
161
|
concurrent-ruby (~> 1.0)
|
151
162
|
rack (> 1, < 3)
|
152
|
-
sprockets-rails (3.
|
163
|
+
sprockets-rails (3.2.0)
|
153
164
|
actionpack (>= 4.0)
|
154
165
|
activesupport (>= 4.0)
|
155
166
|
sprockets (>= 3.0.0)
|
156
167
|
sqlite3 (1.3.11)
|
157
|
-
term-ansicolor (1.
|
168
|
+
term-ansicolor (1.4.0)
|
158
169
|
tins (~> 1.0)
|
159
170
|
thor (0.19.1)
|
160
171
|
thread_safe (0.3.5)
|
@@ -162,8 +173,12 @@ GEM
|
|
162
173
|
tins (1.12.0)
|
163
174
|
tzinfo (1.2.2)
|
164
175
|
thread_safe (~> 0.1)
|
176
|
+
uniform_notifier (1.10.0)
|
165
177
|
warden (1.2.6)
|
166
178
|
rack (>= 1.0)
|
179
|
+
websocket-driver (0.6.4)
|
180
|
+
websocket-extensions (>= 0.1.0)
|
181
|
+
websocket-extensions (0.1.2)
|
167
182
|
yard (0.9.5)
|
168
183
|
yard-activesupport-concern (0.0.1)
|
169
184
|
yard (>= 0.8)
|
@@ -174,14 +189,15 @@ PLATFORMS
|
|
174
189
|
DEPENDENCIES
|
175
190
|
activity_notification!
|
176
191
|
ammeter
|
192
|
+
bullet
|
177
193
|
coveralls
|
178
194
|
devise (~> 4.2.0)
|
179
195
|
factory_girl_rails (~> 4.7.0)
|
180
|
-
|
181
|
-
rails
|
196
|
+
rails (~> 5.0.0)
|
197
|
+
rails-controller-testing
|
182
198
|
rspec-rails (~> 3.5.1)
|
183
199
|
simplecov (~> 0.12.0)
|
184
|
-
sqlite3
|
200
|
+
sqlite3 (~> 1.3.11)
|
185
201
|
timecop
|
186
202
|
yard (~> 0.9.5)
|
187
203
|
yard-activesupport-concern (~> 0.0.1)
|
data/README.md
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/simukappu/activity_notification.svg?branch=master)](https://travis-ci.org/simukappu/activity_notification)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/github/simukappu/activity_notification/badge.svg?branch=master)](https://coveralls.io/github/simukappu/activity_notification?branch=master)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/simukappu/activity_notification/badges/gpa.svg)](https://codeclimate.com/github/simukappu/activity_notification)
|
6
|
-
[![
|
6
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/simukappu/activity_notification.svg)](https://gemnasium.com/github.com/simukappu/activity_notification)
|
7
7
|
[![Inline docs](http://inch-ci.org/github/simukappu/activity_notification.svg?branch=master)](http://inch-ci.org/github/simukappu/activity_notification)
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/activity_notification.svg)](https://badge.fury.io/rb/activity_notification)
|
8
9
|
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](MIT-LICENSE)
|
9
10
|
|
10
11
|
`activity_notification` provides integrated user activity notifications for Ruby on Rails. You can easily use it to configure multiple notification targets and make activity notifications with notifiable models, like adding comments, responding etc.
|
@@ -12,6 +13,25 @@
|
|
12
13
|
`activity_notification` supports Rails 5.0 and 4.2+. Currently, it is only supported with ActiveRecord ORM.
|
13
14
|
|
14
15
|
|
16
|
+
## About
|
17
|
+
|
18
|
+
`activity_notification` provides following functions:
|
19
|
+
* Notification API (creating notifications, query for notifications and managing notification parameters)
|
20
|
+
* Notification controllers (managing open/unopen of notifications, link to notifiable activity page)
|
21
|
+
* Notification views (presentation of notifications)
|
22
|
+
* Grouping notifications (grouping like `"Kevin and 7 other users posted comments to this article"`)
|
23
|
+
* Email notification
|
24
|
+
* Integration with [Devise](https://github.com/plataformatec/devise) authentication
|
25
|
+
|
26
|
+
### Notification index
|
27
|
+
<kbd>![notification-index](https://raw.githubusercontent.com/simukappu/activity_notification/images/activity_notification_index.png)</kbd>
|
28
|
+
|
29
|
+
### Plugin notifications
|
30
|
+
<kbd>![plugin-notifications](https://raw.githubusercontent.com/simukappu/activity_notification/images/activity_notification_plugin_focus.png)</kbd>
|
31
|
+
|
32
|
+
`activity_notification` deeply uses [PublicActivity](https://github.com/pokonski/public_activity) as reference in presentation layer.
|
33
|
+
|
34
|
+
|
15
35
|
## Table of contents
|
16
36
|
|
17
37
|
1. [About](#about)
|
@@ -41,17 +61,6 @@
|
|
41
61
|
5. [Documentation](#documentation)
|
42
62
|
6. **[Common examples](#common-examples)**
|
43
63
|
|
44
|
-
## About
|
45
|
-
|
46
|
-
`activity_notification` provides following functions:
|
47
|
-
* Notification API (creating notifications, query for notifications and managing notification parameters)
|
48
|
-
* Notification controllers (managing open/unopen of notifications, link to notifiable activity page)
|
49
|
-
* Notification views (presentation of notifications)
|
50
|
-
* Grouping notifications (grouping like `"Tom and other 7 people posted comments to this article"`)
|
51
|
-
* Email notification
|
52
|
-
* Integration with [Devise](https://github.com/plataformatec/devise) authentication
|
53
|
-
|
54
|
-
`activity_notification` deeply uses [PublicActivity](https://github.com/pokonski/public_activity) as reference in presentation layer.
|
55
64
|
|
56
65
|
## Setup
|
57
66
|
|
@@ -115,7 +124,7 @@ You have to define notification targets for all notifications from this notifiab
|
|
115
124
|
```ruby
|
116
125
|
class Article < ActiveRecord::Base
|
117
126
|
belongs_to :user
|
118
|
-
has_many :comments, dependent: :
|
127
|
+
has_many :comments, dependent: :destroy
|
119
128
|
has_many :commented_users, through: :comments, source: :user
|
120
129
|
end
|
121
130
|
|
@@ -319,7 +328,7 @@ Sometimes, it's desirable to pass additional local variables to partials. It can
|
|
319
328
|
|
320
329
|
For example, if you have an notification with `:key` set to `"notification.comment.reply"` and rendered it with `:target` set to `:users`, the gem will look for a partial in `app/views/activity_notification/notifications/users/comment/_reply.html.(|erb|haml|slim|something_else)`.
|
321
330
|
|
322
|
-
*Hint*: the `"notification."` prefix in `:key` is completely optional
|
331
|
+
*Hint*: the `"notification."` prefix in `:key` is completely optional, you can skip it in your projects or use this prefix only to make namespace.
|
323
332
|
|
324
333
|
If you would like to fallback to a partial, you can utilize the `fallback` parameter to specify the path of a partial to use when one is missing:
|
325
334
|
|
@@ -343,6 +352,13 @@ If a view file does not exist then ActionView::MisingTemplate will be raised. If
|
|
343
352
|
<%= render_notification(@notification, fallback: :text) %>
|
344
353
|
```
|
345
354
|
|
355
|
+
Default views of `activity_notification` depends on jQuery and you have to add requirements to `application.js` in your apps:
|
356
|
+
|
357
|
+
```app/assets/javascripts/application.js
|
358
|
+
//= require jquery
|
359
|
+
//= require jquery_ujs
|
360
|
+
```
|
361
|
+
|
346
362
|
#### i18n for notifications
|
347
363
|
|
348
364
|
Translations are used by the `#text` method, to which you can pass additional options in form of a hash. `#render` method uses translations when view templates have not been provided. You can render pure i18n strings by passing `{i18n: true}` to `#render_notification` or `#render`.
|
@@ -361,7 +377,7 @@ notification:
|
|
361
377
|
post:
|
362
378
|
text: "<p>%{notifier_name} posted comments to your article %{article_title}</p>"
|
363
379
|
reply:
|
364
|
-
text: "<p>%{notifier_name} and %{group_member_count}
|
380
|
+
text: "<p>%{notifier_name} and %{group_member_count} other users replied for your comments</p>"
|
365
381
|
admin:
|
366
382
|
article:
|
367
383
|
post:
|
@@ -435,8 +451,8 @@ The subject of notification email can be put in your locale `.yml` files as `mai
|
|
435
451
|
notification:
|
436
452
|
user:
|
437
453
|
comment:
|
438
|
-
|
439
|
-
text: "<p
|
454
|
+
post:
|
455
|
+
text: "<p>Someone posted comments to your article</p>"
|
440
456
|
mail_subject: 'New comment to your article'
|
441
457
|
```
|
442
458
|
|
@@ -445,7 +461,16 @@ notification:
|
|
445
461
|
`activity_notification` provides the function for automatically grouping notifications. When you created a notification like this, all *unopened* notifications to the same target will be grouped by `article` set as `:group` options:
|
446
462
|
|
447
463
|
```ruby
|
448
|
-
@comment.notify :users key: 'comment.
|
464
|
+
@comment.notify :users key: 'comment.post', group: @comment.article
|
465
|
+
```
|
466
|
+
|
467
|
+
When you use default notification view, it is helpful to configure `acts_as_notification_group` (or `acts_as_group`) with `printable_name` option to render group instance.
|
468
|
+
|
469
|
+
```ruby
|
470
|
+
class Article < ActiveRecord::Base
|
471
|
+
belongs_to :user
|
472
|
+
acts_as_notification_group printable_name: ->(article) { "article \"#{article.title}\"" }
|
473
|
+
end
|
449
474
|
```
|
450
475
|
|
451
476
|
You can use `group_owners_only` scope to filter owner notifications representing each group:
|
@@ -461,27 +486,27 @@ end
|
|
461
486
|
And you can render them in a view like this:
|
462
487
|
```erb
|
463
488
|
<% if notification.group_member_exists? %>
|
464
|
-
<%= "#{notification.notifier.name} and
|
489
|
+
<%= "#{notification.notifier.name} and #{notification.group_member_count} other users" %>
|
465
490
|
<% else %>
|
466
491
|
<%= "#{notification.notifier.name}" %>
|
467
492
|
<% end %>
|
468
493
|
<%= "posted comments to your article \"#{notification.group.title}\"" %>
|
469
494
|
```
|
470
495
|
|
471
|
-
This presentation will be shown to target users as `
|
496
|
+
This presentation will be shown to target users as `Kevin and 7 other users posted comments to your article "Let's use Ruby"`.
|
472
497
|
|
473
|
-
You can also use `%{group_member_count}` in i18n text as a field:
|
498
|
+
You can also use `%{group_member_count}`, `%{group_notification_count}`, `%{group_member_notifier_count}` and `%{group_notifier_count}` in i18n text as a field:
|
474
499
|
|
475
500
|
```yaml
|
476
501
|
notification:
|
477
502
|
user:
|
478
503
|
comment:
|
479
|
-
|
480
|
-
text: "<p>%{notifier_name} and %{
|
504
|
+
post:
|
505
|
+
text: "<p>%{notifier_name} and %{group_member_notifier_count} other users posted %{group_notification_count} comments to your article</p>"
|
481
506
|
mail_subject: 'New comment to your article'
|
482
507
|
```
|
483
508
|
|
484
|
-
Then, you will see `
|
509
|
+
Then, you will see `Kevin and 7 other users replied 10 comments to your article"`.
|
485
510
|
|
486
511
|
### Integration with Devise
|
487
512
|
|
@@ -590,6 +615,8 @@ $ git pull https://github.com/simukappu/activity_notification.git
|
|
590
615
|
$ cd activity_notification
|
591
616
|
$ bundle install —path vendor/bundle
|
592
617
|
$ bundle exec rspec
|
618
|
+
- or -
|
619
|
+
$ bundle exec rake
|
593
620
|
```
|
594
621
|
|
595
622
|
#### Dummy Rails application
|
@@ -620,12 +647,12 @@ Then you can see the documents at <http://localhost:8808/docs/index>.
|
|
620
647
|
|
621
648
|
## Common examples
|
622
649
|
|
623
|
-
|
650
|
+
To be prepared. See dummy Rails application in `spec/rails_app`.
|
624
651
|
|
625
652
|
|
626
653
|
## Help
|
627
654
|
|
628
|
-
|
655
|
+
Contact us by email of this repository.
|
629
656
|
|
630
657
|
|
631
658
|
## License
|
@@ -23,7 +23,9 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency 'railties', '>= 4.2.0', '< 5.1'
|
24
24
|
s.add_dependency 'i18n', '>= 0.5.0'
|
25
25
|
s.add_dependency 'activerecord', '>= 4.2.0'
|
26
|
+
s.add_dependency 'jquery-rails', '>= 3.1.1'
|
26
27
|
|
28
|
+
s.add_development_dependency 'sqlite3', '~> 1.3.11'
|
27
29
|
s.add_development_dependency 'rspec-rails', '~> 3.5.1'
|
28
30
|
s.add_development_dependency 'factory_girl_rails', '~> 4.7.0'
|
29
31
|
s.add_development_dependency 'simplecov', '~> 0.12.0'
|