-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prettify and rework the emails sent by devise, including signup confirmation, password reset, and a few others. Include some branding and improve the text. Up until now we were using the standard default devise emails which are very generic and not very nice. Introduce the bootstrap-mailer gem for generating email client compatible html because that is very hard to do apparently. We'll haml instead of erb for consistency and since that's how we like to do it. Also improve the after_registration page, and include some troubleshooting advice on it. Closes #3
- Loading branch information
1 parent
6ea7d6e
commit 3d64ba0
Showing
27 changed files
with
318 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# See also test/mailers/previews/devise_bootstrap_mailer_preview | ||
# Based on https://github.com/bootstrap-email/bootstrap-email/issues/41 | ||
# | ||
class DeviseBootstrapMailer < Devise::Mailer | ||
|
||
layout 'bootstrap-mailer' | ||
default template_path: 'devise/mailer' | ||
|
||
def devise_mail(record, action, opts = {}, &block) | ||
initialize_from_record(record) | ||
|
||
@email_title = email_title_for(action) | ||
|
||
# Use bootstrap mail | ||
make_bootstrap_mail(headers_for(action, opts.merge(to: record.pretty_email)), &block) | ||
end | ||
|
||
private | ||
|
||
# See docker/bundle/ruby/3.1.0/gems/devise-4.8.1/lib/devise/mailers/helpers.rb | ||
# (IIUC the more correct way to change the email subject wording would be to | ||
# create an I18n locale file but let's save that for another day.) | ||
|
||
# Save the method from the base class so we can use it below | ||
alias_method :orig_subject_for, :subject_for | ||
|
||
def email_title_for(action) | ||
orig_subject_for(action). | ||
# Tweak the defaults a little | ||
sub(/Changed$/i, "change notification"). | ||
sub(/^Confirmation/i, "Email confirmation"). | ||
sub(/^Reset password/i, "Password reset"). | ||
sub(/instructions$/i, "") | ||
end | ||
|
||
def subject_for(action) | ||
"Tiddlyhost #{email_title_for(action).downcase}" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
%p.pt-2 | ||
=link_to link_text, link_url, class: "btn btn-success", style: "font-weight: bold;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
%p | ||
Hi #{@resource.short_name}, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%p.pt-4 | ||
%small | ||
Your Tiddlyhost account email address is <b>#{@resource.email}</b>. |
5 changes: 0 additions & 5 deletions
5
rails/app/views/devise/mailer/confirmation_instructions.html.erb
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
rails/app/views/devise/mailer/confirmation_instructions.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
=render 'salutation' | ||
|
||
-if @resource.email_change_in_progress? | ||
-# Actually we're confirming an email address change | ||
%p | ||
To verify the change to your Tiddlyhost account email address | ||
please click 'Confirm email' below. | ||
|
||
=render 'button_link', link_text: 'Confirm email', link_url: confirmation_url(@resource, confirmation_token: @token) | ||
|
||
-else | ||
-# It's a new signup | ||
%p | ||
Welcome to Tiddlyhost! | ||
|
||
%p | ||
To complete the signup process please confirm your | ||
email address by clicking 'Confirm account' below. | ||
|
||
=render 'button_link', link_text: 'Confirm account', link_url: confirmation_url(@resource, confirmation_token: @token) | ||
|
||
=render 'show_email' | ||
|
||
%p.pt-5 | ||
%small.text-gray-600 | ||
You received this email because you or someone else submitted the | ||
=link_to 'Tiddlyhost sign up', "#{Settings.main_site_url}/users/sign_up", target: "_blank" | ||
form using this email address. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-# | ||
-# Possibly unused..? | ||
-# | ||
-if @resource&.unconfirmed_email? | ||
%p | ||
This is a notification to inform you that your Tiddlyhost account email address | ||
is being changed from <b>#{@resource.email}</b> to <b>#{@resource.unconfirmed_email}</b>. | ||
|
||
%p | ||
A confirmation from the new email address is required to verify the change. | ||
|
||
-else | ||
%p | ||
This is a notification to inform you that that your Tiddlyhost account email address | ||
has been successfully changed to <b>#{@resource.email}</b>. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-# | ||
-# Possibly unused..? | ||
-# | ||
%p | ||
This is a notification to inform you that that your Tiddlyhost account | ||
password has been successfully changed. |
8 changes: 0 additions & 8 deletions
8
rails/app/views/devise/mailer/reset_password_instructions.html.erb
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
rails/app/views/devise/mailer/reset_password_instructions.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
=render 'salutation' | ||
|
||
%p | ||
You can set a new Tiddlyhost account password by clicking 'Change password' below. | ||
|
||
=render 'button_link', link_text: 'Change password', link_url: edit_password_url(@resource, reset_password_token: @token) | ||
|
||
=render 'show_email' | ||
|
||
%p.pt-4 | ||
%small | ||
If you didn't request a password reset please ignore this email. | ||
|
||
%p.pt-5 | ||
%small.text-gray-600 | ||
You received this email because you or someone else submitted the | ||
=link_to 'Forgot password?', "#{Settings.main_site_url}/users/password/new", target: "_blank" | ||
form using this email address. |
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
rails/app/views/devise/mailer/unlock_instructions.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-# | ||
-# Possibly unused..? | ||
-# | ||
=render 'salutation' | ||
|
||
%p | ||
Your Tiddlyhost account has been locked due to an excessive number of unsuccessful login attempts. | ||
|
||
%p | ||
To unlock your account click the 'Unlock account' link below. | ||
|
||
=render 'button_link', link_text: 'Unlock account', link_url: unlock_url(@resource, unlock_token: @token) | ||
|
||
=render 'show_email' |
1 change: 0 additions & 1 deletion
1
rails/app/views/devise/registrations/after_registration.html.erb
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
rails/app/views/devise/registrations/after_registration.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
=render layout: 'form_wrapper', | ||
locals: { heading: "#{bi_icon('check-circle', fill: 'green', style: 'opacity: 85%; font-size: 65%;')}Account created".html_safe } do | ||
|
||
%p.pt-4 | ||
Thanks for signing up! | ||
|
||
%p.pb-5 | ||
A confirmation email has been sent to your email address. | ||
To complete the signup process please click the confirmation link | ||
in that email. | ||
|
||
%hr.mt-5.mb-4 | ||
|
||
%h6.text-muted Troubleshooting | ||
|
||
%ul.pt-2.pe-2 | ||
%li.text-muted.pb-3.small | ||
If the confirmation email did not arrive it may be being classified as spam. | ||
Check your spam folder or try adding 'tiddlyhost@gmail.com' to your email | ||
contacts and then use | ||
=link_to 'this form', new_confirmation_path(:user) | ||
to resend the email. | ||
|
||
%li.text-muted.small | ||
If you're still unable to receive the confirmation link, | ||
=mail_to Settings.support_email, 'email me', subject: "Tiddlyhost signup problems", | ||
body: "I signed up and I didn't receive my confirmation email.\n\nPlease send it to me manually if you can." | ||
and I'll see if I can send it to you directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<%# | ||
# | ||
# This will be converted into email friendly html with tables and inlined styles. | ||
# The email content is defined under app/views/devise/mailer. | ||
# | ||
# See also: | ||
# - https://bootstrapemail.com/ | ||
# - app/mailers/devise_bootstrap_mailer.rb | ||
# - test/mailers/previews/devise_bootstrap_mailer_preview.rb | ||
# - http://tiddlyhost.local:3333/rails/mailers/devise_bootstrap_mailer | ||
# - or https://tiddlyhost.local/rails/mailers/devise_bootstrap_mailer | ||
# | ||
-%> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html lang="en"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<meta name="x-apple-disable-message-reformatting"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no"> | ||
</head> | ||
<body class="bg-light"> | ||
<div class="container"> | ||
<div class="card my-10"> | ||
<div class="card-header" style="background-color: #3c60b9; color: white; height: 2.5em;" class="navbar nav bg-gradient"> | ||
<%= link_to Settings.main_site_url, target: '_blank' do %> | ||
<%# Let's take the image from github instead of using the local asset so old emails are less likely to have a broken image url %> | ||
<%= image_tag("https://raw.githubusercontent.com/simonbaird/tiddlyhost/devel/rails/app/assets/images/email-banner.png", style: "display: inline; height: 100%;") %> | ||
<% end %> | ||
</div> | ||
<div class="card-body"> | ||
<% if @email_title.present? %><h1 class="h3 mb-2 mt-2"><%= @email_title %></h1><% end %> | ||
<div class="space-y-3 p-2 pt-5"> | ||
<%= yield %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.