Commit 8e897131333ca074e32f9173938591dc0f10e94c
1 parent
d4a738df
Exists in
master
and in
1 other branch
Switched to 'premailer' gem for inlining css on html emails, since it supports n…
…okogiri which is already in use (as opposed to hpricot). Required InlineCss module on all mailers. Moved email styles into public/stylesheets/email.css
Showing
6 changed files
with
69 additions
and
65 deletions
Show diff stats
Gemfile
@@ -16,7 +16,7 @@ gem 'octokit' | @@ -16,7 +16,7 @@ gem 'octokit' | ||
16 | gem 'inherited_resources' | 16 | gem 'inherited_resources' |
17 | gem 'SystemTimer', :platform => :ruby_18 | 17 | gem 'SystemTimer', :platform => :ruby_18 |
18 | gem 'hoptoad_notifier', "~> 2.4" | 18 | gem 'hoptoad_notifier', "~> 2.4" |
19 | -gem 'tamtam' | 19 | +gem 'premailer' |
20 | 20 | ||
21 | platform :ruby do | 21 | platform :ruby do |
22 | gem 'bson_ext', '~> 1.3.1' | 22 | gem 'bson_ext', '~> 1.3.1' |
Gemfile.lock
@@ -45,6 +45,7 @@ GEM | @@ -45,6 +45,7 @@ GEM | ||
45 | builder (2.1.2) | 45 | builder (2.1.2) |
46 | columnize (0.3.4) | 46 | columnize (0.3.4) |
47 | crack (0.1.8) | 47 | crack (0.1.8) |
48 | + css_parser (1.1.9) | ||
48 | daemons (1.1.4) | 49 | daemons (1.1.4) |
49 | database_cleaner (0.6.7) | 50 | database_cleaner (0.6.7) |
50 | devise (1.4.2) | 51 | devise (1.4.2) |
@@ -75,7 +76,7 @@ GEM | @@ -75,7 +76,7 @@ GEM | ||
75 | hoptoad_notifier (2.4.11) | 76 | hoptoad_notifier (2.4.11) |
76 | activesupport | 77 | activesupport |
77 | builder | 78 | builder |
78 | - hpricot (0.8.4) | 79 | + htmlentities (4.3.0) |
79 | i18n (0.5.0) | 80 | i18n (0.5.0) |
80 | inherited_resources (1.2.2) | 81 | inherited_resources (1.2.2) |
81 | has_scope (~> 0.5.0) | 82 | has_scope (~> 0.5.0) |
@@ -122,6 +123,9 @@ GEM | @@ -122,6 +123,9 @@ GEM | ||
122 | nokogiri (~> 1.4.1) | 123 | nokogiri (~> 1.4.1) |
123 | rest-client (~> 1.5.1) | 124 | rest-client (~> 1.5.1) |
124 | polyglot (0.3.1) | 125 | polyglot (0.3.1) |
126 | + premailer (1.7.1) | ||
127 | + css_parser (>= 1.1.9) | ||
128 | + htmlentities (>= 4.0.0) | ||
125 | rack (1.2.2) | 129 | rack (1.2.2) |
126 | rack-mount (0.6.14) | 130 | rack-mount (0.6.14) |
127 | rack (>= 1.0.0) | 131 | rack (>= 1.0.0) |
@@ -178,8 +182,6 @@ GEM | @@ -178,8 +182,6 @@ GEM | ||
178 | typhoeus | 182 | typhoeus |
179 | ruby_core_source (0.1.5) | 183 | ruby_core_source (0.1.5) |
180 | archive-tar-minitar (>= 0.5.2) | 184 | archive-tar-minitar (>= 0.5.2) |
181 | - tamtam (0.0.3) | ||
182 | - hpricot | ||
183 | thin (1.2.11) | 185 | thin (1.2.11) |
184 | daemons (>= 1.0.9) | 186 | daemons (>= 1.0.9) |
185 | eventmachine (>= 0.12.6) | 187 | eventmachine (>= 0.12.6) |
@@ -218,6 +220,7 @@ DEPENDENCIES | @@ -218,6 +220,7 @@ DEPENDENCIES | ||
218 | nokogiri | 220 | nokogiri |
219 | octokit | 221 | octokit |
220 | pivotal-tracker | 222 | pivotal-tracker |
223 | + premailer | ||
221 | rails (= 3.0.5) | 224 | rails (= 3.0.5) |
222 | redmine_client! | 225 | redmine_client! |
223 | rspec (~> 2.5) | 226 | rspec (~> 2.5) |
@@ -225,7 +228,6 @@ DEPENDENCIES | @@ -225,7 +228,6 @@ DEPENDENCIES | ||
225 | ruby-debug | 228 | ruby-debug |
226 | ruby-debug19 | 229 | ruby-debug19 |
227 | ruby-fogbugz | 230 | ruby-fogbugz |
228 | - tamtam | ||
229 | thin | 231 | thin |
230 | useragent (~> 0.3.1) | 232 | useragent (~> 0.3.1) |
231 | webmock | 233 | webmock |
app/mailers/mailer.rb
@@ -3,8 +3,6 @@ | @@ -3,8 +3,6 @@ | ||
3 | require Rails.root.join('config/routes.rb') | 3 | require Rails.root.join('config/routes.rb') |
4 | 4 | ||
5 | class Mailer < ActionMailer::Base | 5 | class Mailer < ActionMailer::Base |
6 | - include InlineCss | ||
7 | - | ||
8 | default :from => Errbit::Config.email_from | 6 | default :from => Errbit::Config.email_from |
9 | 7 | ||
10 | def err_notification(notice) | 8 | def err_notification(notice) |
app/views/layouts/mailer.html.haml
1 | %html | 1 | %html |
2 | %head | 2 | %head |
3 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | 3 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
4 | - :css | ||
5 | - td.header { | ||
6 | - padding: 10px 20px 10px 20px; | ||
7 | - height: 75px; | ||
8 | - background-color: #11112f; | ||
9 | - text-align: left; | ||
10 | - border-bottom: 1px solid #ccccee; | ||
11 | - } | ||
12 | - td.header a { | ||
13 | - display: block; | ||
14 | - height: 31px; | ||
15 | - width: 88px; | ||
16 | - margin-top: 10px; | ||
17 | - } | ||
18 | - /* Style 'Errbit' logo alt text if image cannot be loaded. */ | ||
19 | - td.header a img { | ||
20 | - border: none; | ||
21 | - color: #E3E3E3; | ||
22 | - font-family: helvetica; | ||
23 | - font-size: 30px; | ||
24 | - font-weight: bold; | ||
25 | - min-height: 31px; | ||
26 | - text-shadow: 0 1px 0 #EEEEFF; | ||
27 | - } | ||
28 | - | ||
29 | - td.section, td.content, td.footer { | ||
30 | - font-family: Helvetica,Arial,sans-serif; | ||
31 | - font-size: 14px; | ||
32 | - background-color: #ffffff; | ||
33 | - text-align: left; | ||
34 | - } | ||
35 | - td.section { | ||
36 | - padding: 0; | ||
37 | - border-bottom: 1px solid #dddddd; | ||
38 | - } | ||
39 | - td.content { | ||
40 | - padding: 20px 20px 10px 20px; | ||
41 | - line-height: 1.3em; | ||
42 | - } | ||
43 | - td.footer { | ||
44 | - padding: 10px 20px 20px 20px; | ||
45 | - font-size: 11px; | ||
46 | - font-weight: bold; | ||
47 | - color: #666666; | ||
48 | - } | ||
49 | - | ||
50 | - a.bold, span.bold { font-weight: bold; } | ||
51 | - span.revision { color: #3a8d3a; } | ||
52 | - | ||
53 | - p { margin: 0 0 15px 0; } | ||
54 | - p.heading { | ||
55 | - color: #6a6a6a; | ||
56 | - margin-bottom: 4px; | ||
57 | - } | ||
58 | - p.monospace, p.backtrace { font-family: monospace; } | ||
59 | - p.backtrace { margin-bottom: 2px; } | ||
60 | 4 | ||
61 | %body(leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0") | 5 | %body(leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0") |
62 | %center | 6 | %center |
lib/inline_css.rb
@@ -4,11 +4,15 @@ | @@ -4,11 +4,15 @@ | ||
4 | module InlineCss | 4 | module InlineCss |
5 | def render(*args) | 5 | def render(*args) |
6 | if (template = args.first[:template]) && template.mime_type.html? | 6 | if (template = args.first[:template]) && template.mime_type.html? |
7 | - # TamTam expects a <style> tag in the head of your layout. | ||
8 | - TamTam.inline(:document => super) | 7 | + premailer = Premailer.new(super, |
8 | + :with_html_string => true, | ||
9 | + :css => [Rails.root.join("public/stylesheets/email.css").to_s]) | ||
10 | + premailer.to_inline_css | ||
9 | else | 11 | else |
10 | super | 12 | super |
11 | end | 13 | end |
12 | end | 14 | end |
13 | end | 15 | end |
14 | 16 | ||
17 | +ActionMailer::Base.send :include, InlineCss | ||
18 | + |
@@ -0,0 +1,56 @@ | @@ -0,0 +1,56 @@ | ||
1 | +td.header { | ||
2 | + padding: 10px 20px 10px 20px; | ||
3 | + height: 75px; | ||
4 | + background-color: #11112f; | ||
5 | + text-align: left; | ||
6 | + border-bottom: 1px solid #ccccee; | ||
7 | +} | ||
8 | + td.header a { | ||
9 | + display: block; | ||
10 | + height: 31px; | ||
11 | + width: 88px; | ||
12 | + margin-top: 10px; | ||
13 | + } | ||
14 | + /* Style 'Errbit' logo alt text if image cannot be loaded. */ | ||
15 | + td.header a img { | ||
16 | + border: none; | ||
17 | + color: #E3E3E3; | ||
18 | + font-family: helvetica; | ||
19 | + font-size: 30px; | ||
20 | + font-weight: bold; | ||
21 | + min-height: 31px; | ||
22 | + text-shadow: 0 1px 0 #EEEEFF; | ||
23 | + } | ||
24 | + | ||
25 | +td.section, td.content, td.footer { | ||
26 | + font-family: Helvetica,Arial,sans-serif; | ||
27 | + font-size: 14px; | ||
28 | + background-color: #ffffff; | ||
29 | + text-align: left; | ||
30 | +} | ||
31 | +td.section { | ||
32 | + padding: 0; | ||
33 | + border-bottom: 1px solid #dddddd; | ||
34 | +} | ||
35 | +td.content { | ||
36 | + padding: 20px 20px 10px 20px; | ||
37 | + line-height: 1.3em; | ||
38 | +} | ||
39 | +td.footer { | ||
40 | + padding: 10px 20px 20px 20px; | ||
41 | + font-size: 11px; | ||
42 | + font-weight: bold; | ||
43 | + color: #666666; | ||
44 | +} | ||
45 | + | ||
46 | +a.bold, span.bold { font-weight: bold; } | ||
47 | +span.revision { color: #3a8d3a; } | ||
48 | + | ||
49 | +p { margin: 0 0 15px 0; } | ||
50 | +p.heading { | ||
51 | + color: #6a6a6a; | ||
52 | + margin-bottom: 4px; | ||
53 | +} | ||
54 | +p.monospace, p.backtrace { font-family: monospace; } | ||
55 | +p.backtrace { margin-bottom: 2px; } | ||
56 | + |