spree_mail 0.40.0.2 → 0.40.0.3
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.
- data/README.md +4 -2
- data/app/controllers/subscribers_controller.rb +5 -5
- data/app/model/email.rb +1 -1
- data/app/model/subscriber.rb +2 -2
- data/app/validators/email_validator.rb +20 -0
- data/app/views/admin/emails/_form.html.erb +5 -5
- data/app/views/admin/emails/show.html.erb +3 -3
- data/app/views/admin/subscribers/_options.html.erb +3 -3
- data/app/views/hooks/_footer_left.html.erb +1 -1
- data/app/views/hooks/_subscriber_static_content.html.erb +1 -1
- data/app/views/layouts/email.html.erb +12 -10
- data/app/views/subscribers/show.html.erb +5 -5
- data/config/locales/en.yml +34 -1
- data/lib/spree_mail/custom_hooks.rb +0 -12
- data/lib/spree_mail/version.rb +1 -1
- data/lib/spree_mail.rb +2 -10
- metadata +24 -9
data/README.md
CHANGED
@@ -14,7 +14,7 @@ To create a spree mail demo app, run the following:
|
|
14
14
|
rails new spree_mail_example
|
15
15
|
cd spree_mail_example
|
16
16
|
echo "gem 'spree', '0.40.2'" >> Gemfile
|
17
|
-
echo "gem 'spree_mail', '0.40.0.
|
17
|
+
echo "gem 'spree_mail', '0.40.0.3'" >> Gemfile
|
18
18
|
rm public/index.html
|
19
19
|
bundle install
|
20
20
|
rake spree:install spree_mail:install db:migrate db:seed
|
@@ -22,7 +22,7 @@ To create a spree mail demo app, run the following:
|
|
22
22
|
|
23
23
|
Or all at once:
|
24
24
|
|
25
|
-
rails new spree_mail_example; cd spree_mail_example; echo "gem 'spree', '0.40.2'" >> Gemfile; echo "gem 'spree_mail', '0.40.0.
|
25
|
+
rails new spree_mail_example; cd spree_mail_example; echo "gem 'spree', '0.40.2'" >> Gemfile; echo "gem 'spree_mail', '0.40.0.3'" >> Gemfile; rm public/index.html; bundle install; rake spree:install spree_mail:install db:migrate db:seed
|
26
26
|
|
27
27
|
`rake db:sample` if you want to...
|
28
28
|
|
@@ -48,6 +48,8 @@ To Do
|
|
48
48
|
* Add user help to email form
|
49
49
|
* Add email tracking functionality
|
50
50
|
* Add a selection of products to emails
|
51
|
+
* Add an 'assets' upload admin and an easy way to link images or files to an email
|
52
|
+
* Maybe add a wysiwyg editor for email composition
|
51
53
|
|
52
54
|
|
53
55
|
License
|
@@ -16,19 +16,19 @@ class SubscribersController < Spree::BaseController
|
|
16
16
|
def create
|
17
17
|
@subscriber = Subscriber.new(params[:subscriber])
|
18
18
|
if @subscriber.valid? && @subscriber.save
|
19
|
-
flash[:notice] =
|
19
|
+
flash[:notice] = I18n.t( :subscribe_thanks)
|
20
20
|
redirect_to new_subscriber_path
|
21
21
|
else
|
22
|
-
flash[:error] =
|
22
|
+
flash[:error] = I18n.t( :subscribe_failed)
|
23
23
|
render :action => 'new'
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def unsubscribe
|
28
28
|
if @subscriber.email == params[:subscriber][:email] && @subscriber.unsubscribe!
|
29
|
-
flash[:notice] =
|
29
|
+
flash[:notice] = I18n.t(:unsubscribe_success_public)
|
30
30
|
else
|
31
|
-
flash[:error] =
|
31
|
+
flash[:error] = I18n.t(:unsubscribe_failed_public)
|
32
32
|
end
|
33
33
|
redirect_to new_subscriber_path
|
34
34
|
end
|
@@ -39,4 +39,4 @@ class SubscribersController < Spree::BaseController
|
|
39
39
|
@subscriber = Subscriber.find_by_token(params[:id])
|
40
40
|
end
|
41
41
|
|
42
|
-
end
|
42
|
+
end
|
data/app/model/email.rb
CHANGED
data/app/model/subscriber.rb
CHANGED
@@ -6,7 +6,7 @@ class Subscriber < ActiveRecord::Base
|
|
6
6
|
scope :unsubscribed, where("unsubscribed_at IS NOT NULL").order(:name)
|
7
7
|
|
8
8
|
validates :name, :presence => true
|
9
|
-
validates :email, :
|
9
|
+
validates :email, :email => true, :uniqueness => true
|
10
10
|
|
11
11
|
before_create :set_token
|
12
12
|
|
@@ -36,4 +36,4 @@ class Subscriber < ActiveRecord::Base
|
|
36
36
|
write_attribute :token, Digest::SHA1.hexdigest(Time.now.to_s)
|
37
37
|
end
|
38
38
|
|
39
|
-
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class EmailValidator < ActiveModel::EachValidator
|
2
|
+
def validate_each(record,attribute,value)
|
3
|
+
begin
|
4
|
+
m = Mail::Address.new(value)
|
5
|
+
# We must check that value contains a domain and that value is an email address
|
6
|
+
r = m.domain && m.address == value
|
7
|
+
t = m.__send__(:tree)
|
8
|
+
# We need to dig into treetop
|
9
|
+
# A valid domain must have dot_atom_text elements size > 1
|
10
|
+
# user@localhost is excluded
|
11
|
+
# treetop must respond to domain
|
12
|
+
# We exclude valid email values like <user@localhost.com>
|
13
|
+
# Hence we use m.__send__(tree).domain
|
14
|
+
r &&= (t.domain.dot_atom_text.elements.size > 1)
|
15
|
+
rescue Exception => e
|
16
|
+
r = false
|
17
|
+
end
|
18
|
+
record.errors[attribute] << (options[:message] || I18n.t(:invalid_email, :scope => [:activerecord, :errors, :messages])) unless r
|
19
|
+
end
|
20
|
+
end
|
@@ -44,9 +44,9 @@
|
|
44
44
|
|
45
45
|
<div class="selection left">
|
46
46
|
|
47
|
-
<h3
|
48
|
-
<%= link_to "
|
49
|
-
<%= link_to "
|
47
|
+
<h3><%= t("select_subscribers") %>:</h3>
|
48
|
+
<%= link_to t("select_all"), "#select-all" %> /
|
49
|
+
<%= link_to t("deselect_all"), "#deselect-all" %>
|
50
50
|
<ul class="select">
|
51
51
|
<% @subscribers.each do |subscriber| %>
|
52
52
|
<li class="checkbox">
|
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
<div class="right">
|
62
62
|
|
63
|
-
<h3
|
63
|
+
<h3><%= t("message_details")%></h3>
|
64
64
|
<%= f.field_container :subject do %>
|
65
65
|
<%= f.label :subject, t("subject") %><br />
|
66
66
|
<%= f.text_field :subject, :class => "title" %>
|
@@ -75,4 +75,4 @@
|
|
75
75
|
|
76
76
|
</div>
|
77
77
|
|
78
|
-
<% end %>
|
78
|
+
<% end %>
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
<h1><%= t("show_email") %></h1>
|
4
4
|
|
5
|
-
<h5
|
5
|
+
<h5><%= t("to") %>: (<%= @email.recipients.length %>)</h5>
|
6
6
|
<p><%= @email.recipient_list %></p>
|
7
7
|
|
8
|
-
<h5
|
8
|
+
<h5><%= t("subject") %>:</h5>
|
9
9
|
<p><%= @email.subject %></p>
|
10
10
|
|
11
|
-
<h5
|
11
|
+
<h5><%= t("body") %>:</h5>
|
12
12
|
<%= simple_format @email.body %>
|
13
13
|
|
14
14
|
<hr/>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if subscriber.active? %>
|
2
|
-
<%= link_to "unsubscribe", unsubscribe_admin_subscriber_path(subscriber) %>
|
2
|
+
<%= link_to t("unsubscribe"), unsubscribe_admin_subscriber_path(subscriber) %>
|
3
3
|
<% else %>
|
4
|
-
<%= link_to "resubscribe", resubscribe_admin_subscriber_path(subscriber) %>
|
5
|
-
<% end %>
|
4
|
+
<%= link_to t("resubscribe"), resubscribe_admin_subscriber_path(subscriber) %>
|
5
|
+
<% end %>
|
@@ -1 +1 @@
|
|
1
|
-
<%= link_to "
|
1
|
+
<%= link_to t("sign_up_for_our_newsletter"), new_subscriber_path %>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<h1><%= t('newsletter_sign_up') %></h1>
|
2
2
|
|
3
|
-
<p
|
3
|
+
<p><%= t("newsletter_text_signup") %></p>
|
@@ -10,7 +10,6 @@
|
|
10
10
|
|
11
11
|
</head>
|
12
12
|
|
13
|
-
|
14
13
|
<body style="min-width: 500px; margin: 0; padding: 15px; background-color: #ddd; background-image: url(<%= @base_url %>/images/mailer/background.jpg); background-repeat: repeat; font-family: Courier, serif; font-size: 14px; line-height: 19px; color: #575757; -webkit-text-size-adjust: 135%;">
|
15
14
|
|
16
15
|
<table cellpadding="5" cellspacing="0" border="0" align="center" width="600" bgcolor="#fff" style="background-color: #fff; border: 1px solid #e0e0e0;">
|
@@ -23,8 +22,8 @@
|
|
23
22
|
<tr>
|
24
23
|
<td><%= link_to image_tag(@base_url + Spree::Config[:logo], :alt => Spree::Config[:site_name], :style => "border: 0"), root_url %></td>
|
25
24
|
<td align="right">
|
26
|
-
<p><%= @email.created_at
|
27
|
-
<p><b
|
25
|
+
<p><%= l @email.created_at, :format => "%B %d, %Y" %></p>
|
26
|
+
<p><b><%= t("subject") %>:</b> <%= @email_subject %></p>
|
28
27
|
</td>
|
29
28
|
</tr>
|
30
29
|
<tr>
|
@@ -36,9 +35,9 @@
|
|
36
35
|
<table cellpadding="15" cellspacing="0" border="0" align="center" width="100%" style="border-top: 1px solid #e0e0e0;">
|
37
36
|
<tr>
|
38
37
|
<td>
|
39
|
-
<p style="font-size: 12px;"
|
40
|
-
<p style="font-size: 12px;"
|
41
|
-
<p style="font-size: 12px;"
|
38
|
+
<p style="font-size: 12px;"><%= t :received_in_error, :site_name => Spree::Config[:site_name] %></p>
|
39
|
+
<p style="font-size: 12px;"><%= t("contact") %>: <b><%= mail_to @email.from, @email.from, :style => "color: #5b8fb1;" %></b></p>
|
40
|
+
<p style="font-size: 12px;"><%= t("unsubscribe_text", :site_name => Spree::Config[:site_name]) %> <%= link_to t("click_here"), subscriber_url(@subscriber.token), :style => "color: #5b8fb1;" %></p>
|
42
41
|
<h4 style="padding: 10px 0; margin: 0; border-top: 1px solid #e0e0e0;">
|
43
42
|
<%= link_to Spree::Config[:site_name], root_url, :style => "color: #5b8fb1;" %>
|
44
43
|
</h4>
|
@@ -60,10 +59,10 @@
|
|
60
59
|
<td align="right">
|
61
60
|
<p style="font-size: 12px">
|
62
61
|
<% if @link_to_browser %>
|
63
|
-
<%= link_to "
|
64
|
-
|
62
|
+
<%= link_to t("click_here"), @link_to_browser, :style => "color: #5b8fb1;" %>
|
63
|
+
<%= t("view_in_browser") %>
|
65
64
|
<% else %>
|
66
|
-
|
65
|
+
<%= t("visit_online") %>
|
67
66
|
<%= link_to Spree::Config[:site_url], root_url, :style => "color: #5b8fb1;" %>
|
68
67
|
<% end %>
|
69
68
|
</p>
|
@@ -72,7 +71,10 @@
|
|
72
71
|
<tr>
|
73
72
|
<td colspan="2" align="center">
|
74
73
|
<br/>
|
75
|
-
<p style="font-size: 11px; color: #999;"
|
74
|
+
<p style="font-size: 11px; color: #999;"><%= t(:message_sent_to_from_on,
|
75
|
+
:to => @subscriber.email,
|
76
|
+
:from => @email.from,
|
77
|
+
:on => l(@email.created_at, :format => "%b %d, %Y at %I:%M:%S %p")) %>.</p>
|
76
78
|
</td>
|
77
79
|
</tr>
|
78
80
|
</table>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<h1
|
1
|
+
<h1><%= t("unsubscribe_title") %></h1>
|
2
2
|
|
3
|
-
<p
|
3
|
+
<p><%= t("unsubscribe_mail") %>:</p>
|
4
4
|
|
5
5
|
<% token = Digest::SHA1.hexdigest(Time.now.to_s) %>
|
6
6
|
<%= form_for @subscriber, :url => unsubscribe_subscriber_path(@subscriber.token) do |form| %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<%= form.hidden_field :token, :value => token %>
|
11
11
|
</p>
|
12
12
|
<p>
|
13
|
-
<%= form.submit "
|
14
|
-
<%= link_to "
|
13
|
+
<%= form.submit t("unsubscribe") %> or
|
14
|
+
<%= link_to t("cancel"), root_path %>
|
15
15
|
</p>
|
16
|
-
<% end %>
|
16
|
+
<% end %>
|
data/config/locales/en.yml
CHANGED
@@ -10,10 +10,15 @@ en:
|
|
10
10
|
view_unsubscribed: View Unsubscribed
|
11
11
|
view_all_subscribers: View All Subscribers
|
12
12
|
|
13
|
+
resubscribe: Resubscribe
|
13
14
|
resubscribe_success: "Successfully Resubscribed"
|
14
15
|
resubscribe_failed: "Resubscribe Failed"
|
15
16
|
unsubscribe_success: "Successfully Unsubscribed"
|
17
|
+
unsubscribe_success_public: "You were successfully unsubscribed from the mailing list."
|
16
18
|
unsubscribe_failed: "Unsubscribed failed"
|
19
|
+
unsubscribe_failed_public: "We're sorry, you could not be unsubscribed at this time."
|
20
|
+
subscribe_thanks: "Thanks for signing up for our newsletter!"
|
21
|
+
subscribe_failed: "Sorry, we could not sign you up."
|
17
22
|
|
18
23
|
listing_emails: Listing Emails
|
19
24
|
show_email: Show Email
|
@@ -24,10 +29,38 @@ en:
|
|
24
29
|
|
25
30
|
to: To
|
26
31
|
send: Send
|
32
|
+
body: Body
|
27
33
|
subject: Subject
|
28
34
|
message_body: Message Body
|
29
35
|
|
30
36
|
delivery_success: Your email was successfully sent!
|
31
37
|
delivery_failed: Sorry, your email could not be sent.
|
32
38
|
|
33
|
-
|
39
|
+
contact: "Contact"
|
40
|
+
|
41
|
+
received_in_error: 'This is a message from the %{site_name} if you believe you have received this in error please let us know.'
|
42
|
+
unsubscribe_text: "If you would like to Unsubscribe"
|
43
|
+
click_here: "Click here"
|
44
|
+
view_in_browser: "to view this email in your browser"
|
45
|
+
visit_online: "visit us online at"
|
46
|
+
message_sent_to_from_on: "This message was sent to %{to} from %{from} on %{on}."
|
47
|
+
|
48
|
+
|
49
|
+
unsubscribe_title: "Unsubscribe from our Mailing List"
|
50
|
+
unsubscribe_mail: "Please enter your email address below"
|
51
|
+
unsubscribe: "Unsubscribe"
|
52
|
+
|
53
|
+
select_subscribers: "Select subscribers"
|
54
|
+
select_all: "Select All"
|
55
|
+
deselect_all: "Deselect All"
|
56
|
+
message_details: "Message Details"
|
57
|
+
|
58
|
+
sign_up_for_our_newsletter: "Sign up for our newsletter"
|
59
|
+
|
60
|
+
newsletter_text_signup: "Lorem Ipsum dolor sit amet..."
|
61
|
+
|
62
|
+
|
63
|
+
activerecord:
|
64
|
+
errors:
|
65
|
+
messages:
|
66
|
+
invalid_email: "appears to be invalid"
|
@@ -1,17 +1,5 @@
|
|
1
1
|
module SpreeMail
|
2
2
|
class CustomHooks < Spree::ThemeSupport::HookListener
|
3
|
-
# custom hooks go here
|
4
|
-
|
5
|
-
#replace :admin_product_form_right, 'admin/hooks/product_form_right'
|
6
|
-
#
|
7
|
-
#replace :cart_item_price, 'hooks/cart_item_price'
|
8
|
-
#replace :cart_item_total, 'hooks/cart_item_total'
|
9
|
-
#
|
10
|
-
#insert_before :inside_cart_form, 'hooks/wholesale_customer_id'
|
11
|
-
#
|
12
|
-
#insert_after :admin_orders_index_headers, 'admin/hooks/admin_orders_index_headers'
|
13
|
-
#insert_after :admin_orders_index_rows, 'admin/hooks/admin_orders_index_rows'
|
14
|
-
#insert_after :admin_orders_index_search, 'admin/hooks/admin_orders_index_search'
|
15
3
|
|
16
4
|
insert_after :footer_left, 'hooks/footer_left'
|
17
5
|
insert_after :admin_tabs, 'admin/hooks/subscribers_tab'
|
data/lib/spree_mail/version.rb
CHANGED
data/lib/spree_mail.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
+
require 'mail'
|
1
2
|
require 'mustache'
|
2
|
-
require 'spree_mail/version'
|
3
3
|
require 'spree_mail/custom_hooks'
|
4
4
|
|
5
5
|
module SpreeMail
|
@@ -9,16 +9,8 @@ module SpreeMail
|
|
9
9
|
config.autoload_paths += %W(#{config.root}/lib)
|
10
10
|
|
11
11
|
initializer "static assets" do |app|
|
12
|
-
app.middleware.
|
12
|
+
app.middleware.insert_before ::Rack::Lock, ::ActionDispatch::Static, "#{config.root}/public"
|
13
13
|
end
|
14
14
|
|
15
|
-
#def self.activate
|
16
|
-
# #Dir["../app/**/*.rb"].each do |c|
|
17
|
-
# # puts c
|
18
|
-
# # #Rails.env.production? ? require(c) : load(c)
|
19
|
-
# #end
|
20
|
-
#end
|
21
|
-
|
22
|
-
#config.to_prepare &method(:activate).to_proc
|
23
15
|
end
|
24
16
|
end
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 40
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.40.0.
|
9
|
+
- 3
|
10
|
+
version: 0.40.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Spencer Steffen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-29 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -28,9 +28,9 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
segments:
|
30
30
|
- 0
|
31
|
-
-
|
32
|
-
-
|
33
|
-
version: 0.
|
31
|
+
- 30
|
32
|
+
- 1
|
33
|
+
version: 0.30.1
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -43,9 +43,9 @@ dependencies:
|
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
segments:
|
45
45
|
- 0
|
46
|
-
-
|
47
|
-
-
|
48
|
-
version: 0.
|
46
|
+
- 30
|
47
|
+
- 1
|
48
|
+
version: 0.30.1
|
49
49
|
type: :runtime
|
50
50
|
version_requirements: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,20 @@ dependencies:
|
|
63
63
|
version: 0.12.0
|
64
64
|
type: :runtime
|
65
65
|
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: mail
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 2
|
76
|
+
- 2
|
77
|
+
version: "2.2"
|
78
|
+
type: :runtime
|
79
|
+
version_requirements: *id004
|
66
80
|
description: Spree Mail extends Spree by adding a mailing list subscriber model, sign up forms and an admin to send messages.
|
67
81
|
email:
|
68
82
|
- spencer@citrusme.com
|
@@ -87,6 +101,7 @@ files:
|
|
87
101
|
- app/mailers/email_mailer.rb
|
88
102
|
- app/model/email.rb
|
89
103
|
- app/model/subscriber.rb
|
104
|
+
- app/validators/email_validator.rb
|
90
105
|
- app/views/admin/emails/_form.html.erb
|
91
106
|
- app/views/admin/emails/edit.html.erb
|
92
107
|
- app/views/admin/emails/index.html.erb
|