simply_notify 0.2.4 → 0.2.5
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 +24 -7
- data/lib/generators/notifier_generator.rb +7 -4
- data/lib/simply_notify.rb +10 -4
- data/lib/simply_notify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ac7cf8a36814f3d0135e7e5848c6ece55f99be59
|
|
4
|
+
data.tar.gz: 493aacd2d6a3436ee41da837777c19b30b329809
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd6e2e139f38dfadfa19062fb7da8dcfab6dcdb61bda41e92a99371fc8e93e070bf7412589e46785b13a57ddd9ba1dce3146cce01f77c6903eac894b64356e23
|
|
7
|
+
data.tar.gz: d0db20b3c3805375517d7c953455749921dd72ce007d1f3c500fc4a10cc842f7d7d3c95d9bab3a9820da629fdd0b2c4c0e7f0b62c81b568e64985ea4d0609fa4
|
data/README.md
CHANGED
|
@@ -22,30 +22,47 @@ Or install it yourself as:
|
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Step 1: Generate mailer and views.
|
|
26
26
|
|
|
27
27
|
rails generate notifier
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Step 2: Setup controller where you want then notifications to be created and URL link information.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
For example, if you want each user to be notified when an assignment is created and a link to the homepage included in the email, use a call such as this (added to app/controllers/assignments_controller.rb)
|
|
33
|
+
|
|
34
|
+
# simply_notify: Most recent ID
|
|
35
|
+
most_recent_id = Assignment.maximum('id')
|
|
36
|
+
|
|
37
|
+
# simply_notify: Notification source URL link
|
|
38
|
+
url = "http://localhost:3000/assignments/postlist?id=#{most_recent_id}"
|
|
39
|
+
|
|
40
|
+
# simply_notify: Deliver email to each user
|
|
41
|
+
# use nil as parameter if you want url link to be the homepage
|
|
42
|
+
# use url as parameter if you want url link to be the source of the notification
|
|
43
|
+
@users = User.all
|
|
33
44
|
@users.each do |u|
|
|
34
|
-
Notifier.new_notification(u.email).deliver_now
|
|
45
|
+
Notifier.new_notification(u.email, url).deliver_now
|
|
35
46
|
end
|
|
36
47
|
|
|
37
48
|
|
|
38
|
-
|
|
49
|
+
Step 3: Configure SMTP settings and set homepage as absolute url.
|
|
50
|
+
|
|
51
|
+
For example, sending emails from a gmail account (added to appropriate environments, such as config/environments/development.rb):
|
|
39
52
|
|
|
40
53
|
# SMTP Config
|
|
54
|
+
config.absolute_site_url = 'http://localhost:3000/' #set as your homepage
|
|
55
|
+
config.action_mailer.default_options = {
|
|
56
|
+
from: "YOUR_FROM_EMAIL@gmail.com" #set as your from email
|
|
57
|
+
}
|
|
41
58
|
config.action_mailer.delivery_method = :smtp
|
|
42
59
|
config.action_mailer.perform_deliveries = true
|
|
43
60
|
config.action_mailer.smtp_settings = {
|
|
44
61
|
address: 'smtp.gmail.com',
|
|
45
62
|
port: 587,
|
|
46
63
|
domain: 'gmail.com',
|
|
47
|
-
user_name: 'YOUR_USERNAME@gmail.com',
|
|
48
|
-
password: 'YOUR_PASSWORD',
|
|
64
|
+
user_name: 'YOUR_USERNAME@gmail.com', #set as your email
|
|
65
|
+
password: 'YOUR_PASSWORD', #set as your password
|
|
49
66
|
authentication: 'plain',
|
|
50
67
|
enable_starttls_auto: true }
|
|
51
68
|
|
|
@@ -18,8 +18,9 @@ class NotifierGenerator < Rails::Generators::Base
|
|
|
18
18
|
<body>
|
|
19
19
|
<h1>Hello</h1>
|
|
20
20
|
<p>
|
|
21
|
-
A new assignment has been posted
|
|
22
|
-
|
|
21
|
+
A new assignment has been posted!<br><br>
|
|
22
|
+
Please visit the course website: <%= @url %><br><br>
|
|
23
|
+
Thanks!<br>
|
|
23
24
|
</p>
|
|
24
25
|
</body>
|
|
25
26
|
</html>"
|
|
@@ -28,7 +29,9 @@ class NotifierGenerator < Rails::Generators::Base
|
|
|
28
29
|
def create_text_view_file
|
|
29
30
|
create_file "app/views/notifier/new_notification.text.erb",
|
|
30
31
|
"Hello,
|
|
31
|
-
A new assignment has been posted!
|
|
32
|
-
|
|
32
|
+
A new assignment has been posted!
|
|
33
|
+
Please visit the course website: <%= @url %>.
|
|
34
|
+
|
|
35
|
+
Thanks!"
|
|
33
36
|
end
|
|
34
37
|
end
|
data/lib/simply_notify.rb
CHANGED
|
@@ -2,10 +2,16 @@ require "simply_notify/version"
|
|
|
2
2
|
require "action_mailer"
|
|
3
3
|
|
|
4
4
|
class Notifier < ActionMailer::Base
|
|
5
|
-
default from: 'brandeisapprenticeship@gmail.com'
|
|
6
5
|
|
|
7
|
-
def new_notification(recipient)
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
def new_notification(recipient, url)
|
|
7
|
+
if url.nil?
|
|
8
|
+
@url = Rails.application.config.absolute_site_url
|
|
9
|
+
mail(to: recipient,
|
|
10
|
+
subject: 'New Notification')
|
|
11
|
+
else
|
|
12
|
+
@url = url
|
|
13
|
+
mail(to: recipient,
|
|
14
|
+
subject: 'New Notification')
|
|
15
|
+
end
|
|
10
16
|
end
|
|
11
17
|
end
|
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.2.
|
|
4
|
+
version: 0.2.5
|
|
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-
|
|
11
|
+
date: 2016-03-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionmailer
|