rails_notice 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +165 -0
- data/README.md +76 -0
- data/Rakefile +37 -0
- data/app/assets/config/rails_notice_manifest.js +3 -0
- data/app/assets/javascripts/controllers/notifications/index.js +0 -0
- data/app/assets/javascripts/controllers/rails_notice_admin/notification_settings/index.js +17 -0
- data/app/assets/javascripts/controllers/rails_notice_admin/notifications/index.js +15 -0
- data/app/assets/javascripts/controllers/rails_notice_admin/notify_settings/edit.js +3 -0
- data/app/assets/javascripts/controllers/rails_notice_admin/notify_settings/index.js +17 -0
- data/app/assets/javascripts/controllers/rails_notice_admin/notify_settings/new.js +18 -0
- data/app/assets/javascripts/rails_notice/cable.js +19 -0
- data/app/assets/javascripts/rails_notice/channels/notices.js +39 -0
- data/app/assets/javascripts/rails_notice/messenger-theme-future.js +33 -0
- data/app/assets/javascripts/rails_notice/messenger.min.js +2 -0
- data/app/assets/stylesheets/the_notify/cable.css +9 -0
- data/app/assets/stylesheets/the_notify/messenger-theme-air.css +357 -0
- data/app/assets/stylesheets/the_notify/messenger.css +105 -0
- data/app/channels/notices_channel.rb +7 -0
- data/app/channels/the_notify_connection.rb +30 -0
- data/app/controllers/concerns/rails_notice_controller.rb +18 -0
- data/app/controllers/rails_notice_admin/base_controller.rb +6 -0
- data/app/controllers/rails_notice_admin/notification_settings_controller.rb +55 -0
- data/app/controllers/rails_notice_admin/notifications_controller.rb +71 -0
- data/app/controllers/rails_notice_my/base_controller.rb +5 -0
- data/app/controllers/rails_notice_my/notification_settings_controller.rb +28 -0
- data/app/controllers/rails_notice_my/notifications_controller.rb +78 -0
- data/app/controllers/receivers_controller.rb +12 -0
- data/app/jobs/notification_job.rb +17 -0
- data/app/mailers/rails_notice_mailer.rb +21 -0
- data/app/models/annunciation.rb +4 -0
- data/app/models/concerns/i18n_helper.rb +14 -0
- data/app/models/concerns/the_notifiable.rb +33 -0
- data/app/models/concerns/the_publishable.rb +9 -0
- data/app/models/concerns/the_receivable.rb +17 -0
- data/app/models/notification.rb +156 -0
- data/app/models/notification_setting.rb +8 -0
- data/app/views/rails_notice/_link.html.erb +6 -0
- data/app/views/rails_notice_admin/base/_nav.html.erb +16 -0
- data/app/views/rails_notice_admin/notification_settings/_form.html.erb +7 -0
- data/app/views/rails_notice_admin/notification_settings/_search_form.html.erb +11 -0
- data/app/views/rails_notice_admin/notification_settings/edit.html.erb +14 -0
- data/app/views/rails_notice_admin/notification_settings/index.html.erb +52 -0
- data/app/views/rails_notice_admin/notification_settings/new.html.erb +13 -0
- data/app/views/rails_notice_admin/notification_settings/show.html.erb +0 -0
- data/app/views/rails_notice_admin/notifications/_form.html.erb +6 -0
- data/app/views/rails_notice_admin/notifications/_menu.html.erb +6 -0
- data/app/views/rails_notice_admin/notifications/_search_form.html.erb +11 -0
- data/app/views/rails_notice_admin/notifications/edit.html.erb +14 -0
- data/app/views/rails_notice_admin/notifications/index.html.erb +44 -0
- data/app/views/rails_notice_admin/notifications/new.html.erb +15 -0
- data/app/views/rails_notice_mailer/notify.html.erb +35 -0
- data/app/views/rails_notice_my/base/_nav_my.html.erb +4 -0
- data/app/views/rails_notice_my/notification_settings/_form.html.erb +5 -0
- data/app/views/rails_notice_my/notification_settings/show.html.erb +5 -0
- data/app/views/rails_notice_my/notifications/_navbar.html.erb +13 -0
- data/app/views/rails_notice_my/notifications/_notifications.html.erb +17 -0
- data/app/views/rails_notice_my/notifications/edit.html.erb +2 -0
- data/app/views/rails_notice_my/notifications/index.html.erb +28 -0
- data/app/views/rails_notice_my/notifications/index.js.erb +13 -0
- data/app/views/rails_notice_my/notifications/new.html.erb +1 -0
- data/app/views/rails_notice_my/notifications/read.js.erb +2 -0
- data/app/views/rails_notice_my/notifications/read_all.js.erb +2 -0
- data/app/views/rails_notice_my/notifications/show.html.erb +7 -0
- data/config/locales/en.yml +7 -0
- data/config/locales/zh.yml +7 -0
- data/config/routes.rb +29 -0
- data/db/migrate/20170110025557_create_notification.rb +21 -0
- data/db/migrate/20170209025946_create_notification_settings.rb +23 -0
- data/lib/rails_notice.rb +13 -0
- data/lib/rails_notice/active_record.rb +18 -0
- data/lib/rails_notice/config.rb +13 -0
- data/lib/rails_notice/engine.rb +9 -0
- data/lib/rails_notice/version.rb +3 -0
- data/lib/tasks/the_notify_tasks.rake +4 -0
- metadata +132 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="ui tabular top attached menu">
|
2
|
+
<%= link_to t('rails_notice.all_notification'), notifications_path(receiver: params[:receiver]), class: active_helper(notifications: 'index', active_class: 'item active', item_class: 'item') %>
|
3
|
+
<%= link_to t('rails_notice.notification_setting'), notification_settings_path(receiver: params[:receiver]), class: active_helper(controllers: ['notification_settings']) %>
|
4
|
+
<div class="right menu">
|
5
|
+
<% unless params[:scope] == 'have_read' %>
|
6
|
+
<%= link_to read_all_notifications_path(receiver: params[:receiver]), class: 'item', remote: true do %>
|
7
|
+
<i class="checkmark box icon"></i>Mark All
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="ui popup" id="notify_container">
|
2
|
+
<div class="ui divided items">
|
3
|
+
<% @notifications.limit(5).each do |notification| %>
|
4
|
+
<div class="item">
|
5
|
+
<div class="content">
|
6
|
+
<i class="bell icon"></i>
|
7
|
+
<%= link_to notification.title, url_notification_path(notification) %>
|
8
|
+
<p><%= notification.body %></p>
|
9
|
+
<div class="extra content">
|
10
|
+
<span><time><%= notification.created_at.to_s(:rfc822) %></time></span>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
<%= link_to t('rails_notice.all_notification'), notifications_path(receiver: params[:receiver]), target: '_blank', class: 'ui right floated tiny button' %>
|
17
|
+
</div>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= render 'navbar' %>
|
2
|
+
|
3
|
+
<div class="ui divided items bottom attached segment">
|
4
|
+
<% @notifications.each do |notification| %>
|
5
|
+
<div class="ui info item">
|
6
|
+
<div class="content">
|
7
|
+
<% if notification.title %>
|
8
|
+
<div class="header">
|
9
|
+
<%= link_to notification.title, url_notification_path(notification) %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
<div class="description">
|
13
|
+
<%= link_to notification.body, url_notification_path(notification) %>
|
14
|
+
</div>
|
15
|
+
<div class="extra">
|
16
|
+
Created At: <time><%= notification.created_at.to_s(:rfc822) %></time>
|
17
|
+
<% unless params[:scope] == 'have_read' %>
|
18
|
+
<%= link_to read_notification_path(notification), class: 'right floated notification', id: "check_#{notification.id}", remote: true do %>
|
19
|
+
<i class="checkmark red icon"></i>Mark
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<%= paginate @notifications %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
if ($('#notify_container').length === 0) {
|
2
|
+
$('body').append('<%= j(render 'notifications') %>');
|
3
|
+
} else {
|
4
|
+
$('#notify_container').replaceWith('<%= j(render 'notifications') %>');
|
5
|
+
}
|
6
|
+
|
7
|
+
$('#notify_show').popup({
|
8
|
+
popup: '#notify_container',
|
9
|
+
position: 'bottom right',
|
10
|
+
on: 'click'
|
11
|
+
}).popup('toggle');
|
12
|
+
|
13
|
+
timeForLocalized()
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
scope :admin, as: 'admin', module: 'rails_notice_admin' do
|
4
|
+
resources :notifications do
|
5
|
+
patch :push, on: :member
|
6
|
+
patch :email, on: :member
|
7
|
+
end
|
8
|
+
resources :notify_settings do
|
9
|
+
get :columns, on: :collection
|
10
|
+
end
|
11
|
+
resources :notification_settings
|
12
|
+
end
|
13
|
+
|
14
|
+
scope module: 'rails_notice_my' do
|
15
|
+
resources :notifications do
|
16
|
+
get :url, on: :member
|
17
|
+
get :read, on: :member
|
18
|
+
get :read_all, on: :collection
|
19
|
+
end
|
20
|
+
resource :notification_settings, only: [:show, :edit, :update]
|
21
|
+
end
|
22
|
+
|
23
|
+
resources :receivers do
|
24
|
+
get :search, on: :collection
|
25
|
+
end
|
26
|
+
|
27
|
+
mount ActionCable.server => '/cable'
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateNotification < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
drop_table :notifications, if_exists: true
|
4
|
+
create_table :notifications do |t|
|
5
|
+
t.references :receiver, polymorphic: true
|
6
|
+
t.references :notifiable, polymorphic: true
|
7
|
+
t.string :code
|
8
|
+
t.integer :state, default: 0
|
9
|
+
t.string :title
|
10
|
+
t.string :body, limit: 5000
|
11
|
+
t.string :link
|
12
|
+
t.datetime :sending_at
|
13
|
+
t.datetime :sent_at
|
14
|
+
t.string :sent_result
|
15
|
+
t.datetime :read_at, index: true
|
16
|
+
t.boolean :verbose, default: false
|
17
|
+
t.string :cc_emails
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateNotificationSettings < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :notification_settings do |t|
|
4
|
+
t.references :receiver, polymorphic: true, index: true
|
5
|
+
t.string :notifiable_types
|
6
|
+
t.integer :showtime
|
7
|
+
t.boolean :accept_email, default: true
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
create_table :notify_settings do |t|
|
12
|
+
t.string :notifiable_type
|
13
|
+
t.string :code
|
14
|
+
t.string :notify_mailer
|
15
|
+
t.string :notify_method
|
16
|
+
t.string :only_verbose_columns
|
17
|
+
t.string :except_verbose_columns
|
18
|
+
t.string :cc_emails
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/rails_notice.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails_notice/engine'
|
2
|
+
require 'rails_notice/config'
|
3
|
+
require 'rails_notice/active_record'
|
4
|
+
|
5
|
+
module RailsNotice
|
6
|
+
mattr_writer :notifiable_types do
|
7
|
+
[]
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.notifiable_types
|
11
|
+
(@@notifiable_types + RailsNotice.config.default_notifiable_types).uniq
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RailsNotice::ActiveRecord
|
2
|
+
|
3
|
+
# notify_mailer
|
4
|
+
# notify_method
|
5
|
+
# only
|
6
|
+
# except
|
7
|
+
# cc_emails
|
8
|
+
# tr_values
|
9
|
+
def acts_as_notify(code = 'default', **options)
|
10
|
+
include TheNotifiable
|
11
|
+
notifies[code.to_sym] = options
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
ActiveSupport.on_load :active_record do
|
17
|
+
extend RailsNotice::ActiveRecord
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_support/configurable'
|
2
|
+
|
3
|
+
module RailsNotice
|
4
|
+
include ActiveSupport::Configurable
|
5
|
+
|
6
|
+
configure do |config|
|
7
|
+
config.admin_class = 'Admin::BaseController'
|
8
|
+
config.my_class = 'My::BaseController'
|
9
|
+
config.default_notifiable_types = []
|
10
|
+
config.default_send_email = true
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_notice
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- qinmingyuan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.0.1
|
27
|
+
description: Description of RailsNotice.
|
28
|
+
email:
|
29
|
+
- mingyuan0715@foxmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- app/assets/config/rails_notice_manifest.js
|
38
|
+
- app/assets/javascripts/controllers/notifications/index.js
|
39
|
+
- app/assets/javascripts/controllers/rails_notice_admin/notification_settings/index.js
|
40
|
+
- app/assets/javascripts/controllers/rails_notice_admin/notifications/index.js
|
41
|
+
- app/assets/javascripts/controllers/rails_notice_admin/notify_settings/edit.js
|
42
|
+
- app/assets/javascripts/controllers/rails_notice_admin/notify_settings/index.js
|
43
|
+
- app/assets/javascripts/controllers/rails_notice_admin/notify_settings/new.js
|
44
|
+
- app/assets/javascripts/rails_notice/cable.js
|
45
|
+
- app/assets/javascripts/rails_notice/channels/notices.js
|
46
|
+
- app/assets/javascripts/rails_notice/messenger-theme-future.js
|
47
|
+
- app/assets/javascripts/rails_notice/messenger.min.js
|
48
|
+
- app/assets/stylesheets/the_notify/cable.css
|
49
|
+
- app/assets/stylesheets/the_notify/messenger-theme-air.css
|
50
|
+
- app/assets/stylesheets/the_notify/messenger.css
|
51
|
+
- app/channels/notices_channel.rb
|
52
|
+
- app/channels/the_notify_connection.rb
|
53
|
+
- app/controllers/concerns/rails_notice_controller.rb
|
54
|
+
- app/controllers/rails_notice_admin/base_controller.rb
|
55
|
+
- app/controllers/rails_notice_admin/notification_settings_controller.rb
|
56
|
+
- app/controllers/rails_notice_admin/notifications_controller.rb
|
57
|
+
- app/controllers/rails_notice_my/base_controller.rb
|
58
|
+
- app/controllers/rails_notice_my/notification_settings_controller.rb
|
59
|
+
- app/controllers/rails_notice_my/notifications_controller.rb
|
60
|
+
- app/controllers/receivers_controller.rb
|
61
|
+
- app/jobs/notification_job.rb
|
62
|
+
- app/mailers/rails_notice_mailer.rb
|
63
|
+
- app/models/annunciation.rb
|
64
|
+
- app/models/concerns/i18n_helper.rb
|
65
|
+
- app/models/concerns/the_notifiable.rb
|
66
|
+
- app/models/concerns/the_publishable.rb
|
67
|
+
- app/models/concerns/the_receivable.rb
|
68
|
+
- app/models/notification.rb
|
69
|
+
- app/models/notification_setting.rb
|
70
|
+
- app/views/rails_notice/_link.html.erb
|
71
|
+
- app/views/rails_notice_admin/base/_nav.html.erb
|
72
|
+
- app/views/rails_notice_admin/notification_settings/_form.html.erb
|
73
|
+
- app/views/rails_notice_admin/notification_settings/_search_form.html.erb
|
74
|
+
- app/views/rails_notice_admin/notification_settings/edit.html.erb
|
75
|
+
- app/views/rails_notice_admin/notification_settings/index.html.erb
|
76
|
+
- app/views/rails_notice_admin/notification_settings/new.html.erb
|
77
|
+
- app/views/rails_notice_admin/notification_settings/show.html.erb
|
78
|
+
- app/views/rails_notice_admin/notifications/_form.html.erb
|
79
|
+
- app/views/rails_notice_admin/notifications/_menu.html.erb
|
80
|
+
- app/views/rails_notice_admin/notifications/_search_form.html.erb
|
81
|
+
- app/views/rails_notice_admin/notifications/edit.html.erb
|
82
|
+
- app/views/rails_notice_admin/notifications/index.html.erb
|
83
|
+
- app/views/rails_notice_admin/notifications/new.html.erb
|
84
|
+
- app/views/rails_notice_mailer/notify.html.erb
|
85
|
+
- app/views/rails_notice_my/base/_nav_my.html.erb
|
86
|
+
- app/views/rails_notice_my/notification_settings/_form.html.erb
|
87
|
+
- app/views/rails_notice_my/notification_settings/show.html.erb
|
88
|
+
- app/views/rails_notice_my/notifications/_navbar.html.erb
|
89
|
+
- app/views/rails_notice_my/notifications/_notifications.html.erb
|
90
|
+
- app/views/rails_notice_my/notifications/edit.html.erb
|
91
|
+
- app/views/rails_notice_my/notifications/index.html.erb
|
92
|
+
- app/views/rails_notice_my/notifications/index.js.erb
|
93
|
+
- app/views/rails_notice_my/notifications/new.html.erb
|
94
|
+
- app/views/rails_notice_my/notifications/read.js.erb
|
95
|
+
- app/views/rails_notice_my/notifications/read_all.js.erb
|
96
|
+
- app/views/rails_notice_my/notifications/show.html.erb
|
97
|
+
- config/locales/en.yml
|
98
|
+
- config/locales/zh.yml
|
99
|
+
- config/routes.rb
|
100
|
+
- db/migrate/20170110025557_create_notification.rb
|
101
|
+
- db/migrate/20170209025946_create_notification_settings.rb
|
102
|
+
- lib/rails_notice.rb
|
103
|
+
- lib/rails_notice/active_record.rb
|
104
|
+
- lib/rails_notice/config.rb
|
105
|
+
- lib/rails_notice/engine.rb
|
106
|
+
- lib/rails_notice/version.rb
|
107
|
+
- lib/tasks/the_notify_tasks.rake
|
108
|
+
homepage: https://github.com/yougexiangfa/rails_notice
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.7.7
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Summary of RailsNotice.
|
132
|
+
test_files: []
|