simply_notify 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -14
- data/lib/generators/notifier_generator.rb +27 -1
- data/lib/simply_notify/version.rb +1 -1
- data/lib/simply_notify.rb +12 -8
- data/simply_notify.gemspec +4 -2
- metadata +32 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f6ed495397695ae73384d15c941d23bca0b8f7d
|
4
|
+
data.tar.gz: 0e7fc593cedce54a1bb4f53144b2ef027c539c7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f64983596442469d3f6fcb9ce8c9909f0b23aeed5131483b4a6474418dc4af3b49a4f9accaacc779f4b9f6d9c7fb2120182938ee44d2fe8d6da7133aab2c7da
|
7
|
+
data.tar.gz: 1eb508d165913fcb13f3ab9f6ab08ef0c90e74cfaf4d30d0c1a1d59ae0c8f34ed897bca5cb18a4db3f321e8c77348e4bf6958de42469ba8966aabe3df0f70b10
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# SimplyNotify
|
2
2
|
|
3
|
-
simply_notify will send a user of the
|
3
|
+
simply_notify will send a user of the website an email notifying the user of a new notification that has been posted to their user account. It will also provide a link to the notifcation source (or homepage) and also track analytics such as when the user opens the notification email.
|
4
4
|
|
5
|
+
Check out ahoy_email for more information on email analytics --> https://github.com/ankane/ahoy_email
|
5
6
|
|
6
|
-
|
7
|
+
|
8
|
+
# Installation
|
7
9
|
|
8
10
|
Add this line to your application's Gemfile:
|
9
11
|
|
@@ -20,16 +22,28 @@ Or install it yourself as:
|
|
20
22
|
$ gem install simply_notify
|
21
23
|
|
22
24
|
|
23
|
-
|
25
|
+
# Usage
|
26
|
+
|
27
|
+
###Step 1
|
24
28
|
|
25
|
-
|
29
|
+
Generate Notifier Mailer, Notifier Views, and ahoy_email Initializer.
|
26
30
|
|
27
31
|
rails generate notifier
|
28
32
|
|
29
33
|
|
30
|
-
Step 2
|
34
|
+
###Step 2
|
35
|
+
|
36
|
+
Generate ahoy_messages table.
|
37
|
+
|
38
|
+
rails generate ahoy_email:install
|
39
|
+
rake db:migrate
|
40
|
+
|
41
|
+
|
42
|
+
###Step 3
|
43
|
+
|
44
|
+
Setup controller where you want the notifications to be created.
|
31
45
|
|
32
|
-
For example, if you want each user to be notified when an assignment is created
|
46
|
+
For example, if you want each user to be notified when an assignment is created, a link to the homepage included in the email, and the email subject to be 'New Assignment Posted' use a call such as this (added to app/controllers/assignments_controller.rb)
|
33
47
|
|
34
48
|
# simply_notify: Most recent ID
|
35
49
|
most_recent_id = Assignment.maximum('id')
|
@@ -42,37 +56,52 @@ For example, if you want each user to be notified when an assignment is created
|
|
42
56
|
# use url as parameter if you want url link to be the source of the notification
|
43
57
|
@users = User.all
|
44
58
|
@users.each do |u|
|
45
|
-
Notifier.new_notification(u
|
59
|
+
Notifier.new_notification(u, url, 'New Assignment Posted').deliver_now
|
46
60
|
end
|
47
61
|
|
48
62
|
|
49
|
-
Step
|
63
|
+
###Step 4
|
64
|
+
|
65
|
+
Configure SMTP settings and set homepage as absolute url.
|
50
66
|
|
51
67
|
For example, sending emails from a gmail account (added to appropriate environments, such as config/environments/development.rb):
|
52
68
|
|
53
69
|
# SMTP Config
|
54
|
-
|
70
|
+
# Set as your homepage
|
71
|
+
config.absolute_site_url = 'http://localhost:3000/'
|
72
|
+
# Set as your from email
|
55
73
|
config.action_mailer.default_options = {
|
56
|
-
from: "YOUR_FROM_EMAIL@gmail.com"
|
74
|
+
from: "YOUR_FROM_EMAIL@gmail.com"
|
57
75
|
}
|
76
|
+
# Set as the host
|
77
|
+
config.action_mailer.default_url_options = {:host => "localhost:3000"}
|
58
78
|
config.action_mailer.delivery_method = :smtp
|
59
79
|
config.action_mailer.perform_deliveries = true
|
60
80
|
config.action_mailer.smtp_settings = {
|
61
81
|
address: 'smtp.gmail.com',
|
62
82
|
port: 587,
|
63
83
|
domain: 'gmail.com',
|
64
|
-
|
65
|
-
|
84
|
+
# Set as your email
|
85
|
+
user_name: 'YOUR_USERNAME@gmail.com',
|
86
|
+
# Set as your password
|
87
|
+
password: 'YOUR_PASSWORD',
|
66
88
|
authentication: 'plain',
|
67
89
|
enable_starttls_auto: true }
|
68
90
|
|
69
91
|
|
70
|
-
|
92
|
+
###IMPORTANT NOTE
|
93
|
+
|
94
|
+
If you are using a localhost for development, such as localhost:3000, you will need to allow your system to be reachable from the outside in order to populate data into ahoy_messages table for opened_at. When the user opens their email, the image tag is fetched from your application server. The system must be reachable or it won't updated ahoy and values will appear as 'nil' in the table.
|
95
|
+
|
96
|
+
A service such as pagekite will do the trick!
|
97
|
+
|
98
|
+
|
99
|
+
# Contributing
|
71
100
|
|
72
101
|
Bug reports and pull requests are welcome on GitHub at https://github.com/tylerlichten/simply_notify.
|
73
102
|
|
74
103
|
|
75
|
-
|
104
|
+
# License
|
76
105
|
|
77
106
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
78
107
|
|
@@ -2,7 +2,7 @@ require "rails/generators"
|
|
2
2
|
require "thor"
|
3
3
|
|
4
4
|
class NotifierGenerator < Rails::Generators::Base
|
5
|
-
desc "This generator creates the Mailer and
|
5
|
+
desc "This generator creates the Notifier Mailer, Notifier Views, and ahoy_email initializer"
|
6
6
|
|
7
7
|
def create_mailer_file
|
8
8
|
create_file "app/mailers/notifier.rb", "require 'simply_notify'"
|
@@ -34,4 +34,30 @@ class NotifierGenerator < Rails::Generators::Base
|
|
34
34
|
|
35
35
|
Thanks!"
|
36
36
|
end
|
37
|
+
|
38
|
+
def create_ahoy_email_initializer
|
39
|
+
create_file "config/initializers/ahoy_email.rb",
|
40
|
+
"class EmailSubscriber
|
41
|
+
|
42
|
+
def open(event)
|
43
|
+
# :message and :controller keys
|
44
|
+
ahoy = event[:controller].ahoy
|
45
|
+
ahoy.track "Email opened", message_id: event[:message].id
|
46
|
+
end
|
47
|
+
|
48
|
+
def click(event)
|
49
|
+
# same keys as above, plus :url
|
50
|
+
ahoy = event[:controller].ahoy
|
51
|
+
ahoy.track "Email clicked", message_id: event[:message].id, url: event[:url]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
AhoyEmail.subscribers << EmailSubscriber.new"
|
56
|
+
end
|
57
|
+
|
58
|
+
def insert_association_user_model
|
59
|
+
insert_into_file "app/models/user.rb",
|
60
|
+
"has_many :messages, class_name: \"Ahoy::Message\"",
|
61
|
+
after: "has_many :groups, through: :memberships"
|
62
|
+
end
|
37
63
|
end
|
data/lib/simply_notify.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
require "simply_notify/version"
|
2
2
|
require "action_mailer"
|
3
|
+
require "ahoy_email"
|
3
4
|
|
4
5
|
class Notifier < ActionMailer::Base
|
6
|
+
track utm_campaign: "boom"
|
5
7
|
|
6
|
-
def new_notification(recipient, url)
|
7
|
-
|
8
|
+
def new_notification(recipient, url, subject)
|
9
|
+
track user: recipient
|
10
|
+
|
11
|
+
if url.nil?
|
8
12
|
@url = Rails.application.config.absolute_site_url
|
9
|
-
|
10
|
-
subject:
|
11
|
-
|
12
|
-
|
13
|
-
mail(to: recipient,
|
14
|
-
subject:
|
13
|
+
mail(to: recipient.email,
|
14
|
+
subject: subject)
|
15
|
+
else
|
16
|
+
@url = url
|
17
|
+
mail(to: recipient.email,
|
18
|
+
subject: subject)
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
data/simply_notify.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Tyler Lichten"]
|
10
10
|
spec.email = ["tlich10@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Delivers
|
13
|
-
spec.description = %q{Delivers
|
12
|
+
spec.summary = %q{Delivers notification emails to users of the website}
|
13
|
+
spec.description = %q{Delivers notification emails to users of the website}
|
14
14
|
spec.homepage = ""
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_runtime_dependency "actionmailer"
|
23
23
|
spec.add_runtime_dependency "thor"
|
24
|
+
spec.add_runtime_dependency "ahoy_email"
|
25
|
+
spec.add_runtime_dependency "ahoy_matey"
|
24
26
|
|
25
27
|
spec.add_development_dependency "bundler", "~> 1.11"
|
26
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simply_notify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Lichten
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ahoy_email
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ahoy_matey
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: bundler
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +122,7 @@ dependencies:
|
|
94
122
|
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0'
|
97
|
-
description: Delivers
|
125
|
+
description: Delivers notification emails to users of the website
|
98
126
|
email:
|
99
127
|
- tlich10@gmail.com
|
100
128
|
executables: []
|
@@ -137,5 +165,5 @@ rubyforge_project:
|
|
137
165
|
rubygems_version: 2.5.1
|
138
166
|
signing_key:
|
139
167
|
specification_version: 4
|
140
|
-
summary: Delivers
|
168
|
+
summary: Delivers notification emails to users of the website
|
141
169
|
test_files: []
|