Fixed bug: Changes to Setting 'html_email_css_font' are only reflected after restarting Zammad.

This commit is contained in:
Thorsten Eckel 2018-04-10 21:15:52 +02:00
parent edc39d801e
commit 16795605e4
3 changed files with 81 additions and 84 deletions

View file

@ -152,9 +152,13 @@ Check if string is a complete html document. If not, add head and css styles.
return html if html.match?(/<html>/i)
html_email_body = File.read('app/views/mailer/application_wrapper.html.erb')
html_email_body.gsub!('###html_email_css_font###', Setting.get('html_email_css_font'))
# use block form because variable html could contain backslashes and e. g. '\1' that
# must not be handled as back-references for regular expressions
Rails.configuration.html_email_body.sub('###html###') { html }
html_email_body.sub('###html###') { html }
end
=begin

View file

@ -0,0 +1,76 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<style type="text/css">
body {
###html_email_css_font###;
}
img {
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
}
a img {
border: none;
}
table td {
border-collapse: collapse;
}
table {
border-collapse: collapse;
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
border: none;
table-layout: auto;
display: block;
width: 100%;
overflow: auto;
word-break: keep-all;
}
table,
pre,
blockquote {
margin: 0 0 16px;
}
td, th {
padding: 7px 12px;
border: 1px solid hsl(0,0%,87%);
}
th {
font-weight: bold;
text-align: center;
}
tbody tr:nth-child(even) {
background: hsl(0,0%,97%);
}
col {
width: auto;
}
p {
margin: 0;
}
code {
border: none;
background: hsl(0,0%,97%);
white-space: pre-wrap;
}
blockquote {
padding: 8px 12px;
border-left: 5px solid #eee;
}
pre {
padding: 12px 15px;
font-size: 13px;
line-height: 1.45;
background: hsl(0,0%,97%);
white-space: pre-wrap;
border-radius: 3px;
border: none;
overflow: auto;
}
</style>
</head>
<body style="###html_email_css_font###">###html###</body>
</html>

View file

@ -1,83 +0,0 @@
if ActiveRecord::Base.connection.table_exists?( Setting.table_name )
html_email_css_font = Setting.get('html_email_css_font')
Rails.application.config.html_email_body = <<~HERE
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<style type="text/css">
body {
#{html_email_css_font};
}
img {
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
}
a img {
border: none;
}
table td {
border-collapse: collapse;
}
table {
border-collapse: collapse;
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
border: none;
table-layout: auto;
display: block;
width: 100%;
overflow: auto;
word-break: keep-all;
}
table,
pre,
blockquote {
margin: 0 0 16px;
}
td, th {
padding: 7px 12px;
border: 1px solid hsl(0,0%,87%);
}
th {
font-weight: bold;
text-align: center;
}
tbody tr:nth-child(even) {
background: hsl(0,0%,97%);
}
col {
width: auto;
}
p {
margin: 0;
}
code {
border: none;
background: hsl(0,0%,97%);
white-space: pre-wrap;
}
blockquote {
padding: 8px 12px;
border-left: 5px solid #eee;
}
pre {
padding: 12px 15px;
font-size: 13px;
line-height: 1.45;
background: hsl(0,0%,97%);
white-space: pre-wrap;
border-radius: 3px;
border: none;
overflow: auto;
}
</style>
</head>
<body style="#{html_email_css_font}">###html###</body>
</html>
HERE
end