Added Setting to define custom HTML Email CSS font.
This commit is contained in:
parent
95e5eb57a8
commit
2ecc60f22a
3 changed files with 115 additions and 79 deletions
|
@ -1,81 +1,83 @@
|
||||||
|
if ActiveRecord::Base.connection.table_exists?( Setting.table_name )
|
||||||
|
|
||||||
Rails.application.config.html_email_css_font = "font-family:'Helvetica Neue', Helvetica, Arial, Geneva, sans-serif; font-size: 12px;"
|
html_email_css_font = Setting.get('html_email_css_font')
|
||||||
|
|
||||||
Rails.application.config.html_email_body = <<~HERE
|
Rails.application.config.html_email_body = <<~HERE
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body {
|
body {
|
||||||
#{Rails.application.config.html_email_css_font};
|
#{html_email_css_font};
|
||||||
}
|
}
|
||||||
img {
|
img {
|
||||||
outline: none;
|
outline: none;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
-ms-interpolation-mode: bicubic;
|
-ms-interpolation-mode: bicubic;
|
||||||
}
|
}
|
||||||
a img {
|
a img {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
table td {
|
table td {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
mso-table-lspace: 0pt;
|
mso-table-lspace: 0pt;
|
||||||
mso-table-rspace: 0pt;
|
mso-table-rspace: 0pt;
|
||||||
border: none;
|
border: none;
|
||||||
table-layout: auto;
|
table-layout: auto;
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
word-break: keep-all;
|
word-break: keep-all;
|
||||||
}
|
}
|
||||||
table,
|
table,
|
||||||
pre,
|
pre,
|
||||||
blockquote {
|
blockquote {
|
||||||
margin: 0 0 16px;
|
margin: 0 0 16px;
|
||||||
}
|
}
|
||||||
td, th {
|
td, th {
|
||||||
padding: 7px 12px;
|
padding: 7px 12px;
|
||||||
border: 1px solid hsl(0,0%,87%);
|
border: 1px solid hsl(0,0%,87%);
|
||||||
}
|
}
|
||||||
th {
|
th {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
tbody tr:nth-child(even) {
|
tbody tr:nth-child(even) {
|
||||||
background: hsl(0,0%,97%);
|
background: hsl(0,0%,97%);
|
||||||
}
|
}
|
||||||
col {
|
col {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
p {
|
p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
code {
|
code {
|
||||||
border: none;
|
border: none;
|
||||||
background: hsl(0,0%,97%);
|
background: hsl(0,0%,97%);
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
blockquote {
|
blockquote {
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
border-left: 5px solid #eee;
|
border-left: 5px solid #eee;
|
||||||
}
|
}
|
||||||
pre {
|
pre {
|
||||||
padding: 12px 15px;
|
padding: 12px 15px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 1.45;
|
line-height: 1.45;
|
||||||
background: hsl(0,0%,97%);
|
background: hsl(0,0%,97%);
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border: none;
|
border: none;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body style="#{Rails.application.config.html_email_css_font}">###html###</body>
|
<body style="#{html_email_css_font}">###html###</body>
|
||||||
</html>
|
</html>
|
||||||
HERE
|
HERE
|
||||||
|
end
|
||||||
|
|
21
db/migrate/20180306084119_custom_html_email_css_font.rb
Normal file
21
db/migrate/20180306084119_custom_html_email_css_font.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
class CustomHtmlEmailCssFont < ActiveRecord::Migration[5.1]
|
||||||
|
def change
|
||||||
|
|
||||||
|
# return if it's a new setup
|
||||||
|
return if !Setting.find_by(name: 'system_init_done')
|
||||||
|
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
title: 'HTML Email CSS Font',
|
||||||
|
name: 'html_email_css_font',
|
||||||
|
area: 'Core',
|
||||||
|
description: 'Defines the CSS font information for HTML Emails.',
|
||||||
|
options: {},
|
||||||
|
state: "font-family:'Helvetica Neue', Helvetica, Arial, Geneva, sans-serif; font-size: 12px;",
|
||||||
|
preferences: {
|
||||||
|
permission: ['admin'],
|
||||||
|
},
|
||||||
|
frontend: false
|
||||||
|
)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -3739,3 +3739,16 @@ Setting.create_if_not_exists(
|
||||||
preferences: { online_service_disable: true },
|
preferences: { online_service_disable: true },
|
||||||
frontend: false
|
frontend: false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
title: 'HTML Email CSS Font',
|
||||||
|
name: 'html_email_css_font',
|
||||||
|
area: 'Core',
|
||||||
|
description: 'Defines the CSS font information for HTML Emails.',
|
||||||
|
options: {},
|
||||||
|
state: "font-family:'Helvetica Neue', Helvetica, Arial, Geneva, sans-serif; font-size: 12px;",
|
||||||
|
preferences: {
|
||||||
|
permission: ['admin'],
|
||||||
|
},
|
||||||
|
frontend: false
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue