From 8e897131333ca074e32f9173938591dc0f10e94c Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Mon, 5 Sep 2011 01:19:21 +0800 Subject: [PATCH] Switched to 'premailer' gem for inlining css on html emails, since it supports nokogiri which is already in use (as opposed to hpricot). Required InlineCss module on all mailers. Moved email styles into public/stylesheets/email.css --- Gemfile | 2 +- Gemfile.lock | 10 ++++++---- app/mailers/mailer.rb | 2 -- app/views/layouts/mailer.html.haml | 56 -------------------------------------------------------- lib/inline_css.rb | 8 ++++++-- public/stylesheets/email.css | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 69 insertions(+), 65 deletions(-) create mode 100644 public/stylesheets/email.css diff --git a/Gemfile b/Gemfile index c7ea271..5ced90f 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ gem 'octokit' gem 'inherited_resources' gem 'SystemTimer', :platform => :ruby_18 gem 'hoptoad_notifier', "~> 2.4" -gem 'tamtam' +gem 'premailer' platform :ruby do gem 'bson_ext', '~> 1.3.1' diff --git a/Gemfile.lock b/Gemfile.lock index 43ab784..970a9a3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,6 +45,7 @@ GEM builder (2.1.2) columnize (0.3.4) crack (0.1.8) + css_parser (1.1.9) daemons (1.1.4) database_cleaner (0.6.7) devise (1.4.2) @@ -75,7 +76,7 @@ GEM hoptoad_notifier (2.4.11) activesupport builder - hpricot (0.8.4) + htmlentities (4.3.0) i18n (0.5.0) inherited_resources (1.2.2) has_scope (~> 0.5.0) @@ -122,6 +123,9 @@ GEM nokogiri (~> 1.4.1) rest-client (~> 1.5.1) polyglot (0.3.1) + premailer (1.7.1) + css_parser (>= 1.1.9) + htmlentities (>= 4.0.0) rack (1.2.2) rack-mount (0.6.14) rack (>= 1.0.0) @@ -178,8 +182,6 @@ GEM typhoeus ruby_core_source (0.1.5) archive-tar-minitar (>= 0.5.2) - tamtam (0.0.3) - hpricot thin (1.2.11) daemons (>= 1.0.9) eventmachine (>= 0.12.6) @@ -218,6 +220,7 @@ DEPENDENCIES nokogiri octokit pivotal-tracker + premailer rails (= 3.0.5) redmine_client! rspec (~> 2.5) @@ -225,7 +228,6 @@ DEPENDENCIES ruby-debug ruby-debug19 ruby-fogbugz - tamtam thin useragent (~> 0.3.1) webmock diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index c17b995..6cb80ae 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -3,8 +3,6 @@ require Rails.root.join('config/routes.rb') class Mailer < ActionMailer::Base - include InlineCss - default :from => Errbit::Config.email_from def err_notification(notice) diff --git a/app/views/layouts/mailer.html.haml b/app/views/layouts/mailer.html.haml index 5a8b8cd..5ccc6a4 100644 --- a/app/views/layouts/mailer.html.haml +++ b/app/views/layouts/mailer.html.haml @@ -1,62 +1,6 @@ %html %head - :css - td.header { - padding: 10px 20px 10px 20px; - height: 75px; - background-color: #11112f; - text-align: left; - border-bottom: 1px solid #ccccee; - } - td.header a { - display: block; - height: 31px; - width: 88px; - margin-top: 10px; - } - /* Style 'Errbit' logo alt text if image cannot be loaded. */ - td.header a img { - border: none; - color: #E3E3E3; - font-family: helvetica; - font-size: 30px; - font-weight: bold; - min-height: 31px; - text-shadow: 0 1px 0 #EEEEFF; - } - - td.section, td.content, td.footer { - font-family: Helvetica,Arial,sans-serif; - font-size: 14px; - background-color: #ffffff; - text-align: left; - } - td.section { - padding: 0; - border-bottom: 1px solid #dddddd; - } - td.content { - padding: 20px 20px 10px 20px; - line-height: 1.3em; - } - td.footer { - padding: 10px 20px 20px 20px; - font-size: 11px; - font-weight: bold; - color: #666666; - } - - a.bold, span.bold { font-weight: bold; } - span.revision { color: #3a8d3a; } - - p { margin: 0 0 15px 0; } - p.heading { - color: #6a6a6a; - margin-bottom: 4px; - } - p.monospace, p.backtrace { font-family: monospace; } - p.backtrace { margin-bottom: 2px; } %body(leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0") %center diff --git a/lib/inline_css.rb b/lib/inline_css.rb index 97346d6..ff0d5b5 100644 --- a/lib/inline_css.rb +++ b/lib/inline_css.rb @@ -4,11 +4,15 @@ module InlineCss def render(*args) if (template = args.first[:template]) && template.mime_type.html? - # TamTam expects a