actionmailer_inline_css 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +2 -0
- data/actionmailer_inline_css.gemspec +1 -1
- data/lib/action_mailer/inline_css_hook.rb +3 -2
- data/test/abstract_unit.rb +1 -0
- data/test/inline_css_hook_test.rb +27 -0
- data/test/premailer_stylesheet_link_tag_test.rb +6 -3
- metadata +13 -13
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "actionmailer_inline_css"
|
3
|
-
s.version = "1.
|
3
|
+
s.version = "1.4.0"
|
4
4
|
s.date = Time.now.strftime('%Y-%m-%d')
|
5
5
|
s.summary = "Always send HTML e-mails with inline CSS, using the 'premailer' gem"
|
6
6
|
s.email = "nathan.f77@gmail.com"
|
@@ -5,7 +5,9 @@ module ActionMailer
|
|
5
5
|
class InlineCssHook
|
6
6
|
def self.delivering_email(message)
|
7
7
|
if html_part = (message.html_part || (message.content_type =~ /text\/html/ && message))
|
8
|
-
premailer = ::Premailer.new(html_part.body.to_s,
|
8
|
+
premailer = ::Premailer.new(html_part.body.to_s,
|
9
|
+
:with_html_string => true,
|
10
|
+
:base_url => message.header[:host].to_s)
|
9
11
|
existing_text_part = message.text_part && message.text_part.body.to_s
|
10
12
|
# Reset the body
|
11
13
|
message.body = nil
|
@@ -23,4 +25,3 @@ module ActionMailer
|
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
26
|
-
|
data/test/abstract_unit.rb
CHANGED
@@ -26,7 +26,22 @@ TEST_HTML_UTF8 = %Q{
|
|
26
26
|
</body>
|
27
27
|
</html>}
|
28
28
|
|
29
|
+
TEST_HTML_WITH_HOST = %Q{
|
30
|
+
<html>
|
31
|
+
<head>
|
32
|
+
<style>
|
33
|
+
#test { color: #123456; }
|
34
|
+
</style>
|
35
|
+
</head>
|
36
|
+
<body>
|
37
|
+
<img src="/images/test.png" />
|
38
|
+
</body>
|
39
|
+
</html>
|
40
|
+
}
|
41
|
+
|
29
42
|
class HelperMailer < ActionMailer::Base
|
43
|
+
default :host => "http://www.example.com/"
|
44
|
+
|
30
45
|
def use_inline_css_hook_with_only_html_part
|
31
46
|
mail_with_defaults do |format|
|
32
47
|
format.html { render(:inline => TEST_HTML) }
|
@@ -46,6 +61,12 @@ class HelperMailer < ActionMailer::Base
|
|
46
61
|
end
|
47
62
|
end
|
48
63
|
|
64
|
+
def inline_css_hook_with_base_url
|
65
|
+
mail_with_defaults do |format|
|
66
|
+
format.html { render(:inline => TEST_HTML_WITH_HOST) }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
49
70
|
protected
|
50
71
|
|
51
72
|
def mail_with_defaults(&block)
|
@@ -75,5 +96,11 @@ class InlineCssHookTest < ActionMailer::TestCase
|
|
75
96
|
assert_match 'ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ', mail.html_part.body.encoded
|
76
97
|
assert_match 'ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ', mail.text_part.body.encoded
|
77
98
|
end
|
99
|
+
|
100
|
+
def test_inline_css_hook_with_base_url
|
101
|
+
mail = HelperMailer.inline_css_hook_with_base_url.deliver
|
102
|
+
assert_match '<img src="http://www.example.com/images/test.png">',
|
103
|
+
mail.html_part.body.encoded
|
104
|
+
end
|
78
105
|
end
|
79
106
|
|
@@ -3,6 +3,8 @@ require 'abstract_unit'
|
|
3
3
|
ENV["RAILS_ASSET_ID"] = "123456"
|
4
4
|
|
5
5
|
class HelperMailer < ActionMailer::Base
|
6
|
+
default :host => "http://www.example.com/"
|
7
|
+
|
6
8
|
def use_stylesheet_link_tag
|
7
9
|
mail_with_defaults do |format|
|
8
10
|
format.html { render(:inline => %Q{
|
@@ -28,9 +30,10 @@ end
|
|
28
30
|
|
29
31
|
class PremailerStylesheetLinkTagTest < ActionMailer::TestCase
|
30
32
|
def test_premailer_stylesheet_link_tag
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
stub_request(:get, /example\.com\/*/).to_return do
|
34
|
+
css = "div.test { color: #119911; }"
|
35
|
+
{ :status => 200, :body => css }
|
36
|
+
end
|
34
37
|
|
35
38
|
mail = HelperMailer.use_stylesheet_link_tag.deliver
|
36
39
|
assert_match "<div class=\"test\" style=\"color: #119911;\">", mail.html_part.body.encoded
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionmailer_inline_css
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-10 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionmailer
|
16
|
-
requirement: &
|
16
|
+
requirement: &21313620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *21313620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: premailer
|
27
|
-
requirement: &
|
27
|
+
requirement: &21312220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.7.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *21312220
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: nokogiri
|
38
|
-
requirement: &
|
38
|
+
requirement: &21310540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.4.4
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *21310540
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: mocha
|
49
|
-
requirement: &
|
49
|
+
requirement: &21308720 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 0.10.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *21308720
|
58
58
|
description: Module for ActionMailer to improve the rendering of HTML emails by using
|
59
59
|
the 'premailer' gem, which inlines CSS and makes relative links absolute.
|
60
60
|
email: nathan.f77@gmail.com
|
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
segments:
|
91
91
|
- 0
|
92
|
-
hash:
|
92
|
+
hash: 12308258948575913
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
@@ -98,10 +98,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
segments:
|
100
100
|
- 0
|
101
|
-
hash:
|
101
|
+
hash: 12308258948575913
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version: 1.8.
|
104
|
+
rubygems_version: 1.8.8
|
105
105
|
signing_key:
|
106
106
|
specification_version: 3
|
107
107
|
summary: Always send HTML e-mails with inline CSS, using the 'premailer' gem
|