move styles to Styles

This commit is contained in:
scossar 2016-01-27 19:07:21 -08:00
parent 017820e445
commit 77167f12ad
3 changed files with 22 additions and 6 deletions

View File

@ -13,17 +13,17 @@
</style>
<![endif]-->
</head>
<body style="Margin: 0;padding:0;min-width:100%;background-color:#ffffff">
<center class="wrapper" style="width:100%;table-layout:fixed;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;">
<div class="webkit" style="max-width:600px">
<body>
<center class="wrapper">
<div class="webkit">
<!--[if (gte mso 9)|(IE)]>
<table width="600" align="center" cellspacing="0" cellpadding="0" border="0">
<table width="600" align="center">
<tr>
<td>
<![endif]-->
<table class="outer" align="center" cellspacing="0" cellpadding="0" border="0" style="Margin: 0 auto; width: 100%; max-width: 600px">
<table class="outer" align="center">
<tr>
<td style="padding: 10px;">
<td class="container">
<%= yield %>

View File

@ -91,6 +91,10 @@ module Email
style('.rtl', 'direction: rtl;')
style('td.body', 'padding-top:5px;', colspan: "2")
style('.whisper td.body', 'font-style: italic; color: #9c9c9c;')
style('.wrapper', 'width:100%;table-layout:fixed;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;')
style('.webkit', 'max-width:600px;')
style('.outer', 'Margin: 0 auto; width: 100%; max-width: 600px;')
style('.container', 'padding: 10px;')
correct_first_body_margin
correct_footer_style
reset_tables
@ -138,6 +142,7 @@ module Email
end
def format_html
style('body', 'Margin: 0;padding:0;min-width:100%;background-color:#ffffff;')
style('h3', 'margin: 15px 0 20px 0;')
style('hr', 'background-color: #ddd; height: 1px; border: 1px;')
style('a', 'text-decoration: none; font-weight: bold; color: #006699;')

View File

@ -120,6 +120,17 @@ describe Email::Styles do
doc = notification_doc("<div class='user-avatar'><img src='/some-image.png'></div>")
expect(doc.at('img')['width']).to eq('45')
end
it "adds correct styles to the wrapper" do
doc = notification_doc('<center class="wrapper"></center>')
expect(doc.at('center')['style']).to eq('width:100%;table-layout:fixed;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;')
end
it "doesn't override inline attributes" do
doc = notification_doc('<table width="600" align="center"><tr><td>test</td></tr></table>')
expect(doc.at('table')['align']).to eq('center')
expect(doc.at('table')['width']).to eq('600')
end
end
context "rewriting protocol relative URLs to the forum" do