notifications 0.6.0 → 0.6.1
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/README.md +8 -6
- data/Rakefile +1 -1
- data/app/controllers/notifications/notifications_controller.rb +1 -1
- data/db/migrate/20160328045436_create_notifications.rb +1 -1
- data/lib/generators/notifications/controllers_generator.rb +2 -2
- data/lib/generators/notifications/i18n_generator.rb +2 -2
- data/lib/generators/notifications/install_generator.rb +1 -1
- data/lib/generators/notifications/views_generator.rb +1 -1
- data/lib/notifications/version.rb +1 -1
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c4cb0d88943eedf45ead745235a72a06b5ec3762fd1d1d30b1c7b0ea12f2ad8
|
4
|
+
data.tar.gz: 970edb7122c6a3b8a1c6d057b10c5092f1ae7a5cb0b059590567205230717768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5988152884954fc797937c1236eba2c44b34878f722e25617232f9d61d37be3a1c1781a4624de77da8ff3c0cc371a0f07336931fb7ac2de682ff5e6d775d7da
|
7
|
+
data.tar.gz: c0cbe1c39d35c83a38c721a6bd96cf77aa93a1c4b97f5d75c43418aa91b85f242b527d604e1198b5a62349a6a4a341bc5f25dae3b1ffb21ce0aac2636f13d601
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Mountable notifications for any Rails applications.
|
4
4
|
|
5
|
-
[](https://badge.fury.io/rb/notifications) [](https://travis-ci.org/rails-engine/notifications) [](https://badge.fury.io/rb/notifications) [](https://travis-ci.org/rails-engine/notifications) [](https://codecov.io/github/rails-engine/notifications?branch=master)
|
6
6
|
|
7
7
|
## Example:
|
8
8
|
|
@@ -45,7 +45,7 @@ end
|
|
45
45
|
|
46
46
|
class Comment
|
47
47
|
belongs_to :post
|
48
|
-
|
48
|
+
belongs_to :user
|
49
49
|
|
50
50
|
after_commit :create_notifications, on: [:create]
|
51
51
|
def create_notifications
|
@@ -74,7 +74,7 @@ Notification.create(notify_type: 'follow' ....)
|
|
74
74
|
Notification.create(notify_type: 'mention', target: @reply, second_target: @topic, ....)
|
75
75
|
```
|
76
76
|
|
77
|
-
|
77
|
+
Your app must have:
|
78
78
|
|
79
79
|
- app/views/notifications/_follow.html.erb
|
80
80
|
- app/views/notifications/_mention.html.erb
|
@@ -82,21 +82,23 @@ You app must have:
|
|
82
82
|
```erb
|
83
83
|
# app/views/notifications/_follow.html.erb
|
84
84
|
<div class="media-heading">
|
85
|
-
<%= link_to notification.actor.title, notification.actor %> just followed you.
|
85
|
+
<%= link_to notification.actor.title, main_app.user_path(notification.actor) %> just followed you.
|
86
86
|
</div>
|
87
87
|
```
|
88
88
|
|
89
89
|
```erb
|
90
90
|
# app/views/notifications/_mention.html.erb
|
91
91
|
<div class="media-heading">
|
92
|
-
<%= link_to notification.actor.title, notification.actor %> has mentioned you in
|
93
|
-
<%= link_to notification.second_target.title, topic_path(notification.second_target) %>
|
92
|
+
<%= link_to notification.actor.title, main_app.user_path(notification.actor) %> has mentioned you in
|
93
|
+
<%= link_to notification.second_target.title, main_app.topic_path(notification.second_target) %>
|
94
94
|
</div>
|
95
95
|
<div class="media-content">
|
96
96
|
<%= notification.target.body %>
|
97
97
|
</div>
|
98
98
|
```
|
99
99
|
|
100
|
+
> NOTE: When you want use Rails route path name in notification views, you must use [main_app](http://api.rubyonrails.org/classes/Rails/Engine.html#class-Rails::Engine-label-Using+Engine-27s+routes+outside+Engine) prefix. etc: `main_app.user_path(user)`
|
101
|
+
|
100
102
|
### About Notification template N+1 performance
|
101
103
|
|
102
104
|
It is recommended that you use [second_level_cache](https://github.com/hooopo/second_level_cache) for solving N+1 performance issues.
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ rescue LoadError
|
|
4
4
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
5
|
end
|
6
6
|
|
7
|
-
APP_RAKEFILE = File.expand_path(
|
7
|
+
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
8
8
|
|
9
9
|
load 'rails/tasks/engine.rake'
|
10
10
|
load 'rails/tasks/statistics.rake'
|
@@ -17,7 +17,7 @@ module Notifications
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def notifications
|
20
|
-
raise
|
20
|
+
raise 'You need reqiure user login for /notifications page.' unless current_user
|
21
21
|
Notification.where(user_id: current_user.id)
|
22
22
|
end
|
23
23
|
end
|
@@ -2,11 +2,11 @@ require 'rails/generators'
|
|
2
2
|
module Notifications
|
3
3
|
module Generators
|
4
4
|
class ControllersGenerator < Rails::Generators::Base #:nodoc:
|
5
|
-
source_root File.expand_path('
|
5
|
+
source_root File.expand_path('../../../app/controllers', __dir__)
|
6
6
|
desc "Used to copy Notifications's controllers to your application's controllers."
|
7
7
|
|
8
8
|
def copy_controllers
|
9
|
-
%w
|
9
|
+
%w[notifications].each do |fname|
|
10
10
|
path = "#{Rails.root}/app/controllers/notifications/#{fname}_controller.rb"
|
11
11
|
if File.exist?(path)
|
12
12
|
puts "Skipping notifications/#{fname}_controller.rb creation, as file already exists!"
|
@@ -3,10 +3,10 @@ module Notifications
|
|
3
3
|
module Generators
|
4
4
|
class I18nGenerator < Rails::Generators::Base
|
5
5
|
desc "Create Notifications's default I18n files"
|
6
|
-
source_root File.expand_path('
|
6
|
+
source_root File.expand_path('../../..', __dir__)
|
7
7
|
|
8
8
|
def add_locales
|
9
|
-
%w
|
9
|
+
%w[en.yml zh-CN.yml].each do |fname|
|
10
10
|
path = "#{Rails.root}/config/locales/notifications.#{fname}"
|
11
11
|
if File.exist?(path)
|
12
12
|
puts "Skipping config/locales/notifications.#{fname} creation, as file already exists!"
|
@@ -3,7 +3,7 @@ module Notifications
|
|
3
3
|
module Generators
|
4
4
|
class InstallGenerator < Rails::Generators::Base
|
5
5
|
desc "Create Notifications's base files"
|
6
|
-
source_root File.expand_path('
|
6
|
+
source_root File.expand_path('../../..', __dir__)
|
7
7
|
|
8
8
|
def add_initializer
|
9
9
|
path = "#{Rails.root}/config/initializers/notifications.rb"
|
@@ -2,7 +2,7 @@ require 'rails/generators'
|
|
2
2
|
module Notifications
|
3
3
|
module Generators
|
4
4
|
class ViewsGenerator < Rails::Generators::Base #:nodoc:
|
5
|
-
source_root File.expand_path('
|
5
|
+
source_root File.expand_path('../../..', __dir__)
|
6
6
|
desc "Used to copy Notifications's views to your application's views."
|
7
7
|
|
8
8
|
def copy_views
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifications
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: kaminari
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0.15'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0.15'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '5'
|
41
41
|
description: Rails mountable Notification for any applications.
|
42
42
|
email:
|
43
43
|
- huacnlee@gmail.com
|
@@ -88,8 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
|
92
|
-
rubygems_version: 2.7.6
|
91
|
+
rubygems_version: 3.0.1
|
93
92
|
signing_key:
|
94
93
|
specification_version: 4
|
95
94
|
summary: Rails mountable Notification for any applications.
|