spree_mail 0.40.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/README.md +19 -0
  2. data/Rakefile +94 -0
  3. data/app/controllers/admin/emails_controller.rb +61 -0
  4. data/app/controllers/admin/subscribers_controller.rb +78 -0
  5. data/app/controllers/emails_controller.rb +19 -0
  6. data/app/controllers/subscribers_controller.rb +42 -0
  7. data/app/mailers/email_mailer.rb +24 -0
  8. data/app/model/email.rb +77 -0
  9. data/app/model/subscriber.rb +39 -0
  10. data/app/views/admin/emails/_form.html.erb +78 -0
  11. data/app/views/admin/emails/edit.html.erb +15 -0
  12. data/app/views/admin/emails/index.html.erb +64 -0
  13. data/app/views/admin/emails/new.html.erb +15 -0
  14. data/app/views/admin/emails/show.html.erb +20 -0
  15. data/app/views/admin/hooks/_subscribers_tab.html.erb +1 -0
  16. data/app/views/admin/shared/_spree_mail_sub_nav.html.erb +8 -0
  17. data/app/views/admin/subscribers/_form.html.erb +19 -0
  18. data/app/views/admin/subscribers/_options.html.erb +5 -0
  19. data/app/views/admin/subscribers/edit.html.erb +15 -0
  20. data/app/views/admin/subscribers/index.html.erb +76 -0
  21. data/app/views/admin/subscribers/new.html.erb +15 -0
  22. data/app/views/admin/subscribers/show.html.erb +19 -0
  23. data/app/views/hooks/_footer_left.html.erb +1 -0
  24. data/app/views/hooks/_subscriber_sign_up_form.html.erb +4 -0
  25. data/app/views/hooks/_subscriber_static_content.html.erb +3 -0
  26. data/app/views/layouts/email.html.erb +81 -0
  27. data/app/views/subscribers/_fields.html.erb +11 -0
  28. data/app/views/subscribers/new.html.erb +17 -0
  29. data/app/views/subscribers/show.html.erb +16 -0
  30. data/config/locales/en.yml +33 -0
  31. data/config/routes.rb +20 -0
  32. data/db/migrate/install_spree_mail.rb +25 -0
  33. data/lib/spree_mail.rb +24 -0
  34. data/lib/spree_mail/custom_hooks.rb +20 -0
  35. data/lib/spree_mail/version.rb +3 -0
  36. data/lib/tasks/install.rake +36 -0
  37. data/public/images/mailer/airmail.gif +0 -0
  38. data/public/images/mailer/background.jpg +0 -0
  39. data/public/images/mailer/postmark.png +0 -0
  40. data/public/stylesheets/admin/spree_mail.css +38 -0
  41. metadata +149 -0
@@ -0,0 +1,78 @@
1
+ <%- locals = {:f => f} %>
2
+
3
+ <% content_for :head do %>
4
+ <%= stylesheet_link_tag 'admin/spree_mail' %>
5
+
6
+ <script type="text/javascript">
7
+ //<![CDATA[
8
+
9
+ $(document).ready(function() {
10
+
11
+ $('div.selection a').click(function(evt) {
12
+ evt.preventDefault();
13
+ var a = $(this);
14
+ var href = a.attr('href');
15
+ var checkboxes = a.siblings('ul.select').find('input.checkbox');
16
+ switch(href) {
17
+ case '#select-all':
18
+ checkboxes.attr('checked', true);
19
+ break;
20
+ case '#deselect-all':
21
+ checkboxes.attr('checked', false);
22
+ break;
23
+ }
24
+ });
25
+
26
+ $('div.selection li').click(function(evt) {
27
+ if (evt.target.type == 'checkbox') return true;
28
+ evt.preventDefault();
29
+ var cb = $(this).find('input[type=checkbox]');
30
+ cb.attr('checked', cb.is(':checked') ? false : true);
31
+ });
32
+
33
+ });
34
+
35
+
36
+ //]]>
37
+ </script>
38
+
39
+ <% end %>
40
+
41
+ <%= hook :admin_email_form_fields, locals do %>
42
+
43
+ <%= render "shared/error_messages", :target => @email %>
44
+
45
+ <div class="selection left">
46
+
47
+ <h3>Select Subscribers:</h3>
48
+ <%= link_to "select all", "#select-all" %> /
49
+ <%= link_to "deselect all", "#deselect-all" %>
50
+ <ul class="select">
51
+ <% @subscribers.each do |subscriber| %>
52
+ <li class="checkbox">
53
+ <%= check_box_tag "email[to][#{subscriber.id}]", subscriber.email, @email.recipients.include?(subscriber.email), :class => 'checkbox' %>
54
+ <%= label_tag "email[to][#{subscriber.id}]", truncate("#{subscriber.name} <#{subscriber.email}>", :length => 37), :class => 'checkbox' %>
55
+ </li>
56
+ <% end %>
57
+ </ul>
58
+ <%= hidden_field_tag "email[to][0]", "" %>
59
+ </div>
60
+
61
+ <div class="right">
62
+
63
+ <h3>Message Details:</h3>
64
+ <%= f.field_container :subject do %>
65
+ <%= f.label :subject, t("subject") %><br />
66
+ <%= f.text_field :subject, :class => "title" %>
67
+ <%= error_message_on :email, :subject %>
68
+ <% end %>
69
+
70
+ <%= f.field_container :body do %>
71
+ <%= f.label :body, t("message_body") %><br />
72
+ <%= f.text_area :body %>
73
+ <%= error_message_on :email, :body %>
74
+ <% end %>
75
+
76
+ </div>
77
+
78
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%= render 'admin/shared/spree_mail_sub_nav' %>
2
+
3
+ <%= hook :admin_email_edit_form_header do %>
4
+ <h1><%= t("editing_email") %></h1>
5
+ <% end %>
6
+
7
+ <%= hook :admin_email_edit_form do %>
8
+ <%= form_for(:email, :url => object_url, :html => { :method => :put }) do |f| %>
9
+ <%= render :partial => "form", :locals => { :f => f } %>
10
+
11
+ <%= hook :admin_email_edit_form_buttons do %>
12
+ <%= render :partial => "admin/shared/edit_resource_links" %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,64 @@
1
+ <%= render 'admin/shared/spree_mail_sub_nav' %>
2
+
3
+ <div class='toolbar'>
4
+ <ul class='actions'>
5
+ <li>
6
+ <p><%= button_link_to t("new_email"), new_object_url, :icon => 'add' %></p>
7
+ </li>
8
+ </ul>
9
+ <br class='clear' />
10
+ </div>
11
+
12
+
13
+ <h1><%= t("listing_emails") %></h1>
14
+
15
+
16
+ <table class="index">
17
+ <thead>
18
+ <tr>
19
+ <%= hook :admin_emails_index_headers do %>
20
+ <th><%= order @search, :by => :subject, :as => t("subject") %></th>
21
+ <th><%= order @search, :by => :body, :as => t("message_body") %></th>
22
+ <th><%= hook :admin_emails_index_header_actions %></th>
23
+ <% end %>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
+ <% @emails.each do |email|%>
28
+ <tr id="<%= dom_id email %>">
29
+ <%- locals = {:email => email} %>
30
+ <%= hook :admin_emails_index_rows, locals do %>
31
+ <td><%=link_to email.subject, object_url(email) %></td>
32
+ <td><%= mail_to email.body.truncate(100) %></td>
33
+ <% end %>
34
+ <td>
35
+ <%= hook :admin_emails_index_row_actions, locals do %>
36
+ <%= link_to_edit email %> &nbsp;
37
+ <%= link_to_delete email %> &nbsp;
38
+ <% end %>
39
+ </td>
40
+ </tr>
41
+ <% end %>
42
+ </tbody>
43
+ </table>
44
+
45
+ <%= will_paginate(:previous_label => "&#171; #{t('previous')}", :next_label => "#{t('next')} &#187;") %>
46
+
47
+
48
+ <% content_for :sidebar do %>
49
+ <div class="box">
50
+ <h3><%= t(:search) %></h3>
51
+ <%= form_for @search do |f| %>
52
+ <%- locals = {:f => f} %>
53
+ <%= hook :admin_emails_index_search, locals do %>
54
+ <p>
55
+ <%= t("to") %><br />
56
+ <%= f.text_field :to_contains, :size=>18 %>
57
+ </p>
58
+ <% end %>
59
+ <%= hook :admin_emails_index_search_buttons, locals do %>
60
+ <p><%= button t("search") %></p>
61
+ <% end %>
62
+ <% end %>
63
+ </div>
64
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%= render 'admin/shared/spree_mail_sub_nav' %>
2
+
3
+ <%= hook :admin_email_new_form_header do %>
4
+ <h1><%= t("new_email") %></h1>
5
+ <% end %>
6
+
7
+ <%= hook :admin_email_new_form do %>
8
+ <%= form_for(:email, :url => collection_url) do |f| %>
9
+ <%= render :partial => "form", :locals => { :f => f } %>
10
+
11
+ <%= hook :admin_email_new_form_buttons do %>
12
+ <%= render :partial => "admin/shared/new_resource_links" %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <%= render 'admin/shared/spree_mail_sub_nav' %>
2
+
3
+ <h1><%= t("show_email") %></h1>
4
+
5
+ <h5>To: (<%= @email.recipients.length %>)</h5>
6
+ <p><%= @email.recipient_list %></p>
7
+
8
+ <h5>Subject:</h5>
9
+ <p><%= @email.subject %></p>
10
+
11
+ <h5>Body:</h5>
12
+ <%= simple_format @email.body %>
13
+
14
+ <hr/>
15
+
16
+ <p>
17
+ <%= link_to (image_tag("admin/icons/email.png") + " " + t("send")), deliver_admin_email_path(@email) %> &nbsp;
18
+ <%= link_to_edit @email %> <%= t('or') %>
19
+ <%= link_to t('back'), collection_url %>
20
+ </p>
@@ -0,0 +1 @@
1
+ <%= tab :emails, :subscribers, :label => "spree_mail" %>
@@ -0,0 +1,8 @@
1
+ <% content_for :sub_menu do %>
2
+ <ul id="sub_nav">
3
+ <%= hook :admin_email_sub_tabs do %>
4
+ <%= tab :emails, :match_path => '/emails' %>
5
+ <%= tab :subscribers, :match_path => '/subscribers', :css_class => 'last' %>
6
+ <% end %>
7
+ </ul>
8
+ <% end %>
@@ -0,0 +1,19 @@
1
+ <%- locals = {:f => f} %>
2
+
3
+ <%= hook :admin_subscriber_form_fields, locals do %>
4
+
5
+ <%= render "shared/error_messages", :target => @subscriber %>
6
+
7
+ <%= f.field_container :name do %>
8
+ <%= f.label :name, t("name") %><br />
9
+ <%= f.text_field :name, :class => 'title' %>
10
+ <%= error_message_on :subscriber, :name %>
11
+ <% end %>
12
+
13
+ <%= f.field_container :email do %>
14
+ <%= f.label :email, t("email") %><br />
15
+ <%= f.text_field :email, :class => 'title' %>
16
+ <%= error_message_on :subscriber, :email %>
17
+ <% end %>
18
+
19
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <% if subscriber.active? %>
2
+ <%= link_to "unsubscribe", unsubscribe_admin_subscriber_path(subscriber) %>
3
+ <% else %>
4
+ <%= link_to "resubscribe", resubscribe_admin_subscriber_path(subscriber) %>
5
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%= render 'admin/shared/spree_mail_sub_nav' %>
2
+
3
+ <%= hook :admin_subscriber_edit_form_header do %>
4
+ <h1><%= t("editing_subscriber") %></h1>
5
+ <% end %>
6
+
7
+ <%= hook :admin_subscriber_edit_form do %>
8
+ <%= form_for(:subscriber, :url => object_url, :html => { :method => :put }) do |f| %>
9
+ <%= render :partial => "form", :locals => { :f => f } %>
10
+
11
+ <%= hook :admin_subscriber_edit_form_buttons do %>
12
+ <%= render :partial => "admin/shared/edit_resource_links" %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,76 @@
1
+ <%= render 'admin/shared/spree_mail_sub_nav' %>
2
+
3
+ <div class='toolbar'>
4
+ <ul class='actions'>
5
+ <li>
6
+ <p>
7
+ <% if controller.action_name == 'unsubscribed' %>
8
+ <%= button_link_to t("view_all_subscribers"), admin_subscribers_path %>
9
+ <% else %>
10
+ <%= button_link_to t("view_unsubscribed"), unsubscribed_admin_subscribers_path %>
11
+ <% end %>
12
+ <%= button_link_to t("new_subscriber"), new_object_url, :icon => 'add' %>
13
+ </p>
14
+ </li>
15
+ </ul>
16
+ <br class='clear' />
17
+ </div>
18
+
19
+
20
+ <h1><%= t("listing_subscribers") %></h1>
21
+
22
+
23
+ <table class="index">
24
+ <thead>
25
+ <tr>
26
+ <%= hook :admin_subscribers_index_headers do %>
27
+ <th><%= order @search, :by => :name, :as => t("name") %></th>
28
+ <th><%= order @search, :by => :email, :as => t("email") %></th>
29
+ <th><%= hook :admin_subscribers_index_header_actions %></th>
30
+ <% end %>
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ <% @subscribers.each do |subscriber|%>
35
+ <tr id="<%= dom_id subscriber %>">
36
+ <%- locals = {:subscriber => subscriber} %>
37
+ <%= hook :admin_subscribers_index_rows, locals do %>
38
+ <td><%=link_to subscriber.name, object_url(subscriber) %></td>
39
+ <td><%= mail_to subscriber.email %></td>
40
+ <% end %>
41
+ <td>
42
+ <%= hook :admin_subscribers_index_row_actions, locals do %>
43
+ <%= link_to_edit subscriber %> &nbsp;
44
+ <%= link_to_delete subscriber %> &nbsp;
45
+ <%= render 'options', :subscriber => subscriber %>
46
+ <% end %>
47
+ </td>
48
+ </tr>
49
+ <% end %>
50
+ </tbody>
51
+ </table>
52
+
53
+ <%= will_paginate(:previous_label => "&#171; #{t('previous')}", :next_label => "#{t('next')} &#187;") %>
54
+
55
+
56
+ <% content_for :sidebar do %>
57
+ <div class="box">
58
+ <h3><%= t(:search) %></h3>
59
+ <%= form_for @search do |f| %>
60
+ <%- locals = {:f => f} %>
61
+ <%= hook :admin_subscribers_index_search, locals do %>
62
+ <p>
63
+ <%= t("name") %><br />
64
+ <%= f.text_field :name_contains, :size=>18 %>
65
+ <p>
66
+ <%= t("email") %><br />
67
+ <%= f.text_field :email_contains, :size=>18 %>
68
+ </p>
69
+
70
+ <% end %>
71
+ <%= hook :admin_subscribers_index_search_buttons, locals do %>
72
+ <p><%= button t("search") %></p>
73
+ <% end %>
74
+ <% end %>
75
+ </div>
76
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%= render 'admin/shared/spree_mail_sub_nav' %>
2
+
3
+ <%= hook :admin_subscriber_new_form_header do %>
4
+ <h1><%= t("new_subscriber") %></h1>
5
+ <% end %>
6
+
7
+ <%= hook :admin_subscriber_new_form do %>
8
+ <%= form_for(:subscriber, :url => collection_url) do |f| %>
9
+ <%= render :partial => "form", :locals => { :f => f } %>
10
+
11
+ <%= hook :admin_subscriber_new_form_buttons do %>
12
+ <%= render :partial => "admin/shared/new_resource_links" %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,19 @@
1
+ <%= render 'admin/shared/spree_mail_sub_nav' %>
2
+
3
+ <h1><%= t("show_subscriber") %></h1>
4
+
5
+ <h5>Name:</h5>
6
+ <h3><%= @subscriber.name %></h3>
7
+
8
+ <h5>Email:</h5>
9
+ <h3><%= mail_to @subscriber.email %></h3>
10
+
11
+ <h5>Token:</h5>
12
+ <p><%= @subscriber.token %></p>
13
+
14
+ <hr/>
15
+
16
+ <p>
17
+ <%= link_to_edit @subscriber %> <%= t('or') %>
18
+ <%= link_to t('back'), collection_url %>
19
+ </p>
@@ -0,0 +1 @@
1
+ <%= link_to "sign up for our newsletter", new_subscriber_path %>
@@ -0,0 +1,4 @@
1
+ <%= render "shared/error_messages", :target => @subscriber %>
2
+ <%= form_for @subscriber do |form| %>
3
+ <%= render 'subscribers/fields', :form => form %>
4
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <h1><%= t('newsletter_sign_up') %></h1>
2
+
3
+ <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin vel ante a orci tempus eleifend ut et magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris, quis sollicitudin sapien justo in libero. Vestibulum mollis mauris enim. Morbi euismod magna ac lorem rutrum elementum. Donec viverra auctor lobortis. Pellentesque eu est.</p>
@@ -0,0 +1,81 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
+ <html>
3
+ <head>
4
+ <title><%= @email_subject %> - <%= Spree::Config[:site_name] %></title>
5
+ <meta name="viewport" content="width = 640"/>
6
+
7
+ <style type="text/css">
8
+ #content a { color: #5b8fb1; }
9
+ </style>
10
+
11
+ </head>
12
+
13
+
14
+ <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
+
16
+ <table cellpadding="5" cellspacing="0" border="0" align="center" width="600" bgcolor="#fff" style="background-color: #fff; border: 1px solid #e0e0e0;">
17
+ <tr>
18
+ <td height="27" style="height: 27px;"><%= image_tag @base_url + "/images/mailer/airmail.gif", :alt => "Email" %></td>
19
+ </tr>
20
+ <tr>
21
+ <td>
22
+ <table cellpadding="15" cellspacing="0" border="0" align="center" width="100%">
23
+ <tr>
24
+ <td><%= link_to image_tag(@base_url + Spree::Config[:logo], :alt => Spree::Config[:site_name], :style => "border: 0"), root_url %></td>
25
+ <td align="right">
26
+ <p><%= @email.created_at.strftime("%B %d, %Y").downcase.capitalize.gsub(/\s0/, " ") %></p>
27
+ <p><b>Subject:</b> <%= @email_subject %></p>
28
+ </td>
29
+ </tr>
30
+ <tr>
31
+ <td colspan="2" style="font-family: Courier, serif; font-size: 14px; line-height: 19px; color: #575757;">
32
+ <%= yield %>
33
+ </td>
34
+ </tr>
35
+ </table>
36
+ <table cellpadding="15" cellspacing="0" border="0" align="center" width="100%" style="border-top: 1px solid #e0e0e0;">
37
+ <tr>
38
+ <td>
39
+ <p style="font-size: 12px;">This is a message from the <%= Spree::Config[:site_name] %> if you believe you have recieved this in error please let us know.</p>
40
+ <p style="font-size: 12px;">Contact: <b><%= mail_to @email.from, @email.from, :style => "color: #5b8fb1;" %></b></p>
41
+ <p style="font-size: 12px;">If you would like to Unsubscribe <%= link_to "click here", subscriber_url(@subscriber.token), :style => "color: #5b8fb1;" %></p>
42
+ <h4 style="padding: 10px 0; margin: 0; border-top: 1px solid #e0e0e0;">
43
+ <%= link_to Spree::Config[:site_name], root_url, :style => "color: #5b8fb1;" %>
44
+ </h4>
45
+ <h5 style="padding: 0; margin: 0;">
46
+ <a href="mailto:<%= @email.from %>" style="color: #5b8fb1;"><%= @email.from %></a>
47
+ </h5>
48
+ </td>
49
+ <td align="right"><%= image_tag @base_url + "/images/mailer/postmark.png", :alt => Spree::Config[:site_name], :style => "margin-right: -50px;" %></td>
50
+ </tr>
51
+ </table>
52
+ </td>
53
+ </tr>
54
+ </table>
55
+ <table cellpadding="5" cellspacing="0" border="0" align="center" width="600" bgcolor="transparent">
56
+ <tr>
57
+ <td>
58
+ <p style="font-size: 12px">&copy; <%= Time.now.year %> <%= link_to Spree::Config[:site_name], root_url, :style => "color: #5b8fb1;" %></p>
59
+ </td>
60
+ <td align="right">
61
+ <p style="font-size: 12px">
62
+ <% if @link_to_browser %>
63
+ <%= link_to "click here", @link_to_browser, :style => "color: #5b8fb1;" %>
64
+ to view this email in your browser
65
+ <% else %>
66
+ visit us online at
67
+ <%= link_to Spree::Config[:site_url], root_url, :style => "color: #5b8fb1;" %>
68
+ <% end %>
69
+ </p>
70
+ </td>
71
+ </tr>
72
+ <tr>
73
+ <td colspan="2" align="center">
74
+ <br/>
75
+ <p style="font-size: 11px; color: #999;">This message was sent to <%= mail_to @subscriber.email, @subscriber.email, :style => "color: #5b8fb1;" %> from <%= mail_to @email.from, @email.from, :style => "color: #5b8fb1;" %> on <%= @email.created_at.strftime('%b %d, %Y at %I:%M:%S %p').gsub(/\s0/, ' ') %>.</p>
76
+ </td>
77
+ </tr>
78
+ </table>
79
+
80
+ </html>
81
+ </body>