Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new layout for barong emails #187

Closed
wants to merge 14 commits into from
Closed

Implement new layout for barong emails #187

wants to merge 14 commits into from

Conversation

amir-budaychiev
Copy link

@amir-budaychiev amir-budaychiev commented Feb 24, 2018

Related with issue #174

@amir-budaychiev amir-budaychiev changed the title Implement new layout for barong emails [WIP] Implement new layout for barong emails Feb 24, 2018
@amir-budaychiev amir-budaychiev changed the title [WIP] Implement new layout for barong emails Implement new layout for barong emails Feb 26, 2018
websites.each do |website|
logo_url = website.logo if host.include?(website.domain)
end
domain_logo_tag(logo_url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain_logo_tag loads white logo. So we either should load black logo or change background color to darker.

</td>
<td class="container">
<div class="content">
<%= yield %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we should change texts in emails a bit

@amir-budaychiev
Copy link
Author

@gfedorenko finished

</div>
</td>
</tr>
</tbody></table>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align closing tags

</td>
</tr>
</tbody></table>
</body>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing closing html tag

<p>Hello <%= @resource.email %>!</p>
<p>Dear <%= @resource.email %>!</p>

<p>Thank you for using with CoinField.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace all "CoinField" with ENV.fetch('APP_NAME', 'Barong')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't fetch things everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have a helper method

@amir-budaychiev
Copy link
Author

@gfedorenko recheck again please

Copy link
Contributor

@mod mod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost there maybe there is a lighter way to express the style.

also we need to determine the application domain name I wonder if we can pass this context to the mailer
@dkkoval @amir-budaychiev

@@ -1,6 +1,7 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
# default from: 'from@example.com'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we define the from ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mod Please, go to /config/initializers/devise.rb line 22


def determine_logo_url
host = confirmation_url(Account.first) # TODO: need way to determine a host correctly, just tip to me, but it works!
websites = Website.all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should compare current application domain name and find it in website
we may want to make a fallback variable like APP_DOMAIN

@@ -1,13 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Barong Mailer</title>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot write barong anywhere
and normally we need to use information from website like application name

</style>
</head>

<body>
<%= yield %>
<table class="body-wrap">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure table is the best way to acheive this template ?
I was thinking just a few div.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mod It's best practice to working with tables when we building email templates, allows us to center elements and etc. You can find a lot of interesting information on this topic, for example:
https://litmus.com/blog/the-tyranny-of-tables-why-web-and-email-design-are-so-different
https://mailbakery.com/blog/how-email-html-coding-differs-from-web-html-coding/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amir-budaychiev we need to pass the current hostname when the email sending was originated I doubt you understand how websites table works.

we match domain name please read our code regarding custom logo in layout.

@amir-budaychiev
Copy link
Author

@mod I found an easier way for determine hostname. Variable URL_HOST already used in production settings, so we don't have to create other variable like APP_DOMAIN. We use this in the configuration settings the mailer config.action_mailer.default_url_options.

end

def determine_logo_url
websites = Website.all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_by_domain

# Mailer proxy to send devise emails in the background
class DeviseBackgroundMailer

def self.confirmation_instructions(record, token, opts = {})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and below methods could be DRY-ed by
%i[confirmation_instructions reset_password_instructions ..].each { |method_name| define_singleton_method(method_name) do ..

@amir-budaychiev
Copy link
Author

@mod Now it works good and get request.domain value and pass it via Rails cache. So, it works without background job. At the moment this is the best solution that I could found by studying the devise documentation and source code of gem devise.

@mod mod closed this Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants