mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: customization of html emails (#7934)
This feature adds the ability to customize the HTML part of all emails using a custom HTML template and optionally some CSS to style it. The CSS will be parsed and converted into inline styles because CSS is poorly supported by email clients. When writing the custom HTML and CSS, be aware of what email clients support. Keep customizations very simple. Customizations can be added and edited in Admin > Customize > Email Style. Since the summary email is already heavily styled, there is a setting to disable custom styles for summary emails called "apply custom styles to digest" found in Admin > Settings > Email. As part of this work, RTL locales are now rendered correctly for all emails.
This commit is contained in:
24
app/views/email/default_template.html
Normal file
24
app/views/email/default_template.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="%{html_lang}" xml:lang="%{html_lang}">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--[if mso]>
|
||||
<style type="text/css">
|
||||
body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !important;}
|
||||
</style>
|
||||
<![endif]-->
|
||||
|
||||
%{email_content}
|
||||
|
||||
<!-- prevent Gmail on iOS font size manipulation -->
|
||||
<div style="display:none;white-space:nowrap;font:15px courier;line-height:0">
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,11 +0,0 @@
|
||||
<div id='main' class=<%= classes %>>
|
||||
|
||||
<div class='header-instructions'>%{header_instructions}</div>
|
||||
|
||||
<% if message.present? %>
|
||||
<div><%= message %></div>
|
||||
<% end %>
|
||||
|
||||
<div class='footer'>%{respond_instructions}</div>
|
||||
|
||||
</div>
|
||||
@@ -1,13 +0,0 @@
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td style="padding: 10px;">
|
||||
<a href="<%= Discourse.base_url %>">
|
||||
<img src="<%= logo_url %>" style="max-width:100%"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="background-color: #fff; padding: 10px 10px; font-family: Arial, Helvetica, sans-serif; font-size: 14px;">
|
||||
<%= raw(html_body) %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -54,22 +54,22 @@
|
||||
|
||||
<% if @digest_unsubscribe %>
|
||||
<p>
|
||||
|
||||
|
||||
<% if @digest_frequencies[:current] %>
|
||||
<h3>
|
||||
<%= t(
|
||||
'unsubscribe.digest_frequency.title',
|
||||
'unsubscribe.digest_frequency.title',
|
||||
frequency: t("unsubscribe.digest_frequency.#{@digest_frequencies[:current]}")
|
||||
) %>
|
||||
</h3>
|
||||
<br/>
|
||||
<% end %>
|
||||
|
||||
|
||||
<label><%= t 'unsubscribe.digest_frequency.select_title' %></label>
|
||||
<%=
|
||||
select_tag :digest_after_minutes,
|
||||
options_for_select(@digest_frequencies[:frequencies], @digest_frequencies[:selected]),
|
||||
class: 'combobox'
|
||||
<%=
|
||||
select_tag :digest_after_minutes,
|
||||
options_for_select(@digest_frequencies[:frequencies], @digest_frequencies[:selected]),
|
||||
class: 'combobox'
|
||||
%>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
6
app/views/layouts/email_template.html.erb
Normal file
6
app/views/layouts/email_template.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<% if @disable_email_custom_styles %>
|
||||
<%= yield %>
|
||||
<% if defined?(html_body) %><%= html_body %><% end %>
|
||||
<% else %>
|
||||
<%= email_html_template(binding).html_safe %>
|
||||
<% end %>
|
||||
@@ -1,19 +1,4 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="<%= html_lang %>" xml:lang="<%= html_lang %>">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body dir="<%= rtl? ? 'rtl' : 'ltr' %>" style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;box-sizing:border-box;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:14px;font-weight:400;line-height:1.3;margin:0;min-width:100%;padding:0;text-align:<%= rtl? ? 'right' : 'left' %>;width:100%">
|
||||
|
||||
|
||||
<!--[if mso]>
|
||||
<style type="text/css">
|
||||
body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !important;}
|
||||
</style>
|
||||
<![endif]-->
|
||||
<div class="summary-email">
|
||||
|
||||
<span class="preheader" style="display:none!important;color:#f3f3f3;font-size:1px;line-height:1px;max-height:0;max-width:0;mso-hide:all!important;opacity:0;overflow:hidden;visibility:hidden">
|
||||
<%= @preheader_text %>
|
||||
@@ -425,10 +410,4 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
|
||||
|
||||
<%= digest_custom_html("below_footer") %>
|
||||
|
||||
<!-- prevent Gmail on iOS font size manipulation -->
|
||||
<div style="display:none;white-space:nowrap;font:15px courier;line-height:0">
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user