Skip to content

Commit

Permalink
Use markerb for emails
Browse files Browse the repository at this point in the history
* Add markerb to the Gemfile
* Update mailer classes to send multipart text+html emails
* Simplify all email templates and convert to Markdown+ERB

This required stripping the CSS and images from the emails. All
Markdown templates are based on the original HTML version except
for the inviter, where it was much easier to work with the text
version (and the i18n contains the whole message anyway).
  • Loading branch information
stevenh512 committed May 8, 2012
1 parent 4c7e82f commit 56db268
Show file tree
Hide file tree
Showing 41 changed files with 98 additions and 450 deletions.
7 changes: 4 additions & 3 deletions Gemfile
Expand Up @@ -29,6 +29,7 @@ gem 'rails_admin'

# mail

gem 'markerb', '~> 1.0.0'
gem 'messagebus_ruby_api', '1.0.3'
gem 'airbrake'
gem 'newrelic_rpm'
Expand Down Expand Up @@ -116,12 +117,12 @@ group :assets do
# install Node.js or use 'therubyracer'.
#
# See https://github.com/sstephenson/execjs#readme for more supported runtimes

# gem 'therubyracer', :platform => :ruby

gem 'handlebars_assets'
gem 'uglifier'

# asset_sync is required as needed by application.rb
gem "asset_sync", :require => nil
end
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Expand Up @@ -263,6 +263,8 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
markerb (1.0.0)
redcarpet (>= 2.0)
messagebus_ruby_api (1.0.3)
mime-types (1.18)
mini_magick (3.4)
Expand Down Expand Up @@ -543,6 +545,7 @@ DEPENDENCIES
json
jwt
linecache (= 0.46)
markerb (~> 1.0.0)
messagebus_ruby_api (= 1.0.3)
mini_magick (= 3.4)
mobile-fu
Expand Down
15 changes: 12 additions & 3 deletions app/mailers/notifier.rb
Expand Up @@ -30,7 +30,10 @@ def single_admin(string, recipient, opts={})



mail(default_opts)
mail(default_opts) do |format|
format.text
format.html
end
end

def invite(email, message, inviter, invitation_code, locale)
Expand All @@ -44,7 +47,10 @@ def invite(email, message, inviter, invitation_code, locale)
:host => AppConfig[:pod_uri].host}

I18n.with_locale(locale) do
mail(mail_opts)
mail(mail_opts) do |format|
forat.text
forat.html
end
end
end

Expand Down Expand Up @@ -85,7 +91,10 @@ def send_notification(type, *args)
@notification = NotificationMailers.const_get(type.to_s.camelize).new(*args)

with_recipient_locale do
mail(@notification.headers)
mail(@notification.headers) do |format|
format.text
format.html
end
end
end

Expand Down
18 changes: 0 additions & 18 deletions app/views/devise/mailer/_inviter.erb

This file was deleted.

13 changes: 0 additions & 13 deletions app/views/devise/mailer/confirmation_instructions.haml

This file was deleted.

7 changes: 7 additions & 0 deletions app/views/devise/mailer/confirmation_instructions.markerb
@@ -0,0 +1,7 @@
<%= t('devise.mailer.welcome', :email => @resource.email) %>

<%= t('.you_can_confirm') %>

[<%= t('.confirm') %>][1]

[1]: <%= confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
174 changes: 0 additions & 174 deletions app/views/devise/mailer/invitation_instructions.erb

This file was deleted.

File renamed without changes.
15 changes: 0 additions & 15 deletions app/views/devise/mailer/reset_password_instructions.haml

This file was deleted.

11 changes: 11 additions & 0 deletions app/views/devise/mailer/reset_password_instructions.markerb
@@ -0,0 +1,11 @@
<%= t('devise.mailer.hello', :email => @resource.email) %>

<%= t('.someone_requested') %>

[<%= t('.change') %>][1]

[1]: <%= edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>

<%= t('.wont_change') %>

<%= t('.ignore') %>
14 changes: 0 additions & 14 deletions app/views/devise/mailer/unlock_instructions.haml

This file was deleted.

9 changes: 9 additions & 0 deletions app/views/devise/mailer/unlock_instructions.markerb
@@ -0,0 +1,9 @@
<%= t('devise.mailer.hello', :email => @resource.email) %>

<%= t('.account_locked') %>

<%= t('.click_to_unlock') %>

[<%= t('.unlock') %>][1]

[1]: <%= unlock_url(@resource, :unlock_token => @resource.unlock_token) %>
4 changes: 0 additions & 4 deletions app/views/notifier/also_commented.html.haml

This file was deleted.

5 changes: 5 additions & 0 deletions app/views/notifier/also_commented.markerb
@@ -0,0 +1,5 @@
<%= comment_message(@notification.comment, :process_newlines => true) %>

[<%= t('notifier.comment_on_post.reply', :name => @notification.comment.post.author.first_name) %>][1]

[1]: <%= post_url(@notification.comment.post) %>
1 change: 0 additions & 1 deletion app/views/notifier/also_commented.text.haml

This file was deleted.

4 changes: 0 additions & 4 deletions app/views/notifier/comment_on_post.html.haml

This file was deleted.

5 changes: 5 additions & 0 deletions app/views/notifier/comment_on_post.markerb
@@ -0,0 +1,5 @@
<%= comment_message(@notification.comment, :process_newlines => true) %>

[<%= t('notifier.comment_on_post.reply', :name => @notification.comment.post.author.name) %>][1]

[1]: <%= post_url(@notification.comment.post) %>
1 change: 0 additions & 1 deletion app/views/notifier/comment_on_post.text.haml

This file was deleted.

7 changes: 0 additions & 7 deletions app/views/notifier/confirm_email.html.haml

This file was deleted.

5 changes: 5 additions & 0 deletions app/views/notifier/confirm_email.markerb
@@ -0,0 +1,5 @@
<%= t('notifier.hello', :name => @notification.recipient.profile.first_name) %>

<%= t('notifier.confirm_email.click_link', :unconfirmed_email => @notification.recipient.unconfirmed_email) %>

<<%= confirm_email_url(:token => @notification.recipient.confirm_email_token) %>>
4 changes: 0 additions & 4 deletions app/views/notifier/confirm_email.text.haml

This file was deleted.

0 comments on commit 56db268

Please sign in to comment.