premailer-rails 1.9.5 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +64 -0
- data/.gitignore +4 -0
- data/CHANGELOG.md +40 -0
- data/Gemfile +15 -11
- data/README.md +32 -37
- data/VERSION +1 -1
- data/examples/rails5/Gemfile +4 -0
- data/{example → examples/rails5}/Rakefile +1 -1
- data/{example → examples/rails5}/bin/rails +1 -1
- data/{example → examples/rails5}/config/application.rb +4 -1
- data/examples/rails5/config/boot.rb +3 -0
- data/{example → examples/rails5}/config/environment.rb +1 -1
- data/{example → examples/rails5}/config.ru +2 -1
- data/examples/rails6/.gitignore +16 -0
- data/examples/rails6/Gemfile +5 -0
- data/examples/rails6/README.md +10 -0
- data/examples/rails6/Rakefile +6 -0
- data/examples/rails6/app/assets/config/manifest.js +1 -0
- data/examples/rails6/app/assets/stylesheets/email.css +32 -0
- data/examples/rails6/app/mailers/example_mailer.rb +7 -0
- data/examples/rails6/app/views/example_mailer/test_message.html.erb +18 -0
- data/examples/rails6/bin/rails +4 -0
- data/examples/rails6/config/application.rb +15 -0
- data/examples/rails6/config/boot.rb +3 -0
- data/examples/rails6/config/environment.rb +5 -0
- data/examples/rails6/config/environments/development.rb +9 -0
- data/examples/rails6/config/environments/production.rb +9 -0
- data/examples/rails6/config/routes.rb +3 -0
- data/examples/rails6/config.ru +6 -0
- data/examples/rails6/test/mailers/previews/example_mailer_preview.rb +5 -0
- data/examples/rails7-propshaft/.gitignore +16 -0
- data/examples/rails7-propshaft/Gemfile +6 -0
- data/examples/rails7-propshaft/README.md +10 -0
- data/examples/rails7-propshaft/Rakefile +6 -0
- data/examples/rails7-propshaft/app/assets/stylesheets/email.css +32 -0
- data/examples/rails7-propshaft/app/mailers/example_mailer.rb +7 -0
- data/examples/rails7-propshaft/app/views/example_mailer/test_message.html.erb +18 -0
- data/examples/rails7-propshaft/bin/rails +4 -0
- data/examples/rails7-propshaft/config/application.rb +14 -0
- data/examples/rails7-propshaft/config/boot.rb +3 -0
- data/examples/rails7-propshaft/config/environment.rb +5 -0
- data/examples/rails7-propshaft/config/environments/development.rb +9 -0
- data/examples/rails7-propshaft/config/environments/production.rb +9 -0
- data/examples/rails7-propshaft/config/routes.rb +3 -0
- data/examples/rails7-propshaft/config.ru +6 -0
- data/examples/rails7-propshaft/test/mailers/previews/example_mailer_preview.rb +5 -0
- data/examples/rails7-sprockets/.gitignore +16 -0
- data/examples/rails7-sprockets/Gemfile +6 -0
- data/examples/rails7-sprockets/README.md +10 -0
- data/examples/rails7-sprockets/Rakefile +6 -0
- data/examples/rails7-sprockets/app/assets/config/manifest.js +1 -0
- data/examples/rails7-sprockets/app/assets/stylesheets/email.css +32 -0
- data/examples/rails7-sprockets/app/mailers/example_mailer.rb +7 -0
- data/examples/rails7-sprockets/app/views/example_mailer/test_message.html.erb +18 -0
- data/examples/rails7-sprockets/bin/rails +4 -0
- data/examples/rails7-sprockets/config/application.rb +14 -0
- data/examples/rails7-sprockets/config/boot.rb +3 -0
- data/examples/rails7-sprockets/config/environment.rb +5 -0
- data/examples/rails7-sprockets/config/environments/development.rb +9 -0
- data/examples/rails7-sprockets/config/environments/production.rb +9 -0
- data/examples/rails7-sprockets/config/routes.rb +3 -0
- data/examples/rails7-sprockets/config.ru +6 -0
- data/examples/rails7-sprockets/test/mailers/previews/example_mailer_preview.rb +5 -0
- data/lib/premailer/rails/css_helper.rb +32 -11
- data/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb +16 -15
- data/lib/premailer/rails/css_loaders/file_system_loader.rb +24 -2
- data/lib/premailer/rails/css_loaders/network_loader.rb +2 -2
- data/lib/premailer/rails/css_loaders/propshaft_loader.rb +38 -0
- data/lib/premailer/rails/css_loaders.rb +1 -1
- data/lib/premailer/rails/customized_premailer.rb +4 -4
- data/lib/premailer/rails/hook.rb +2 -6
- data/lib/premailer/rails/railtie.rb +1 -1
- data/lib/premailer/rails.rb +2 -1
- data/premailer-rails.gemspec +4 -3
- data/spec/integration/css_helper_spec.rb +262 -129
- data/spec/integration/delivery_spec.rb +13 -0
- data/spec/integration/hook_spec.rb +36 -11
- data/spec/rails_app/app/assets/config/manifest.js +3 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +3 -0
- data/spec/rails_app/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_app/app/mailers/welcome_mailer.rb +6 -0
- data/spec/rails_app/app/views/layouts/mailer.html.erb +11 -0
- data/spec/rails_app/app/views/welcome_mailer/welcome_email.html.erb +1 -0
- data/spec/rails_app/config/application.rb +19 -0
- data/spec/rails_app/config/boot.rb +5 -0
- data/spec/rails_app/config/environment.rb +2 -0
- data/spec/rails_app/config/environments/test.rb +10 -0
- data/spec/rails_app/config/initializers/assets.rb +1 -0
- data/spec/rails_app/config/routes.rb +3 -0
- data/spec/rails_app/config.ru +5 -0
- data/spec/rails_app/log/.keep +0 -0
- data/spec/rails_app/tmp/.keep +0 -0
- data/spec/spec_helper.rb +3 -17
- data/spec/support/fixtures/message.rb +40 -0
- data/spec/unit/css_loaders/asset_pipeline_loader_spec.rb +44 -32
- data/spec/unit/css_loaders/file_system_loader_spec.rb +37 -0
- data/spec/unit/css_loaders/network_loader_spec.rb +1 -1
- data/spec/unit/css_loaders/propshaft_loader_spec.rb +57 -0
- data/spec/unit/customized_premailer_spec.rb +32 -40
- metadata +121 -81
- data/.coveralls.yml +0 -1
- data/.travis.yml +0 -22
- data/example/Gemfile +0 -10
- data/example/config/boot.rb +0 -3
- data/example/config/secrets.yml +0 -2
- data/lib/premailer/rails/css_loaders/cache_loader.rb +0 -29
- data/spec/integration/hook_registration_spec.rb +0 -11
- data/spec/support/stubs/action_mailer.rb +0 -5
- data/spec/support/stubs/rails.rb +0 -51
- /data/{example → examples/rails5}/.gitignore +0 -0
- /data/{example → examples/rails5}/README.md +0 -0
- /data/{example → examples/rails5}/app/assets/stylesheets/email.css +0 -0
- /data/{example → examples/rails5}/app/mailers/example_mailer.rb +0 -0
- /data/{example → examples/rails5}/app/views/example_mailer/test_message.html.erb +0 -0
- /data/{example → examples/rails5}/config/environments/development.rb +0 -0
- /data/{example → examples/rails5}/config/environments/production.rb +0 -0
- /data/{example → examples/rails5}/config/initializers/assets.rb +0 -0
- /data/{example → examples/rails5}/config/routes.rb +0 -0
- /data/{example → examples/rails5}/test/mailers/previews/example_mailer_preview.rb +0 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset='utf-8'>
|
5
|
+
<%= stylesheet_link_tag :email %>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div class='wrap'>
|
9
|
+
<p class='greeting'>Hi, John Doe</p>
|
10
|
+
<p>
|
11
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
12
|
+
</p>
|
13
|
+
<div class='footer'>
|
14
|
+
To unsubscribe, <a href='http://www.google.com/'>click here</a>.
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative 'boot'
|
2
|
+
|
3
|
+
require 'action_controller/railtie'
|
4
|
+
require 'action_mailer/railtie'
|
5
|
+
|
6
|
+
# Require the gems listed in Gemfile, including any gems
|
7
|
+
# you've limited to :test, :development, or :production.
|
8
|
+
Bundler.require(*Rails.groups)
|
9
|
+
|
10
|
+
module Example
|
11
|
+
class Application < Rails::Application
|
12
|
+
config.load_defaults 7.0
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.cache_classes = false
|
3
|
+
config.eager_load = false
|
4
|
+
config.consider_all_requests_local = true
|
5
|
+
config.action_controller.perform_caching = false
|
6
|
+
config.assets.debug = true
|
7
|
+
config.assets.digest = true
|
8
|
+
config.assets.raise_runtime_errors = true
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.cache_classes = true
|
3
|
+
config.eager_load = true
|
4
|
+
config.consider_all_requests_local = false
|
5
|
+
config.action_controller.perform_caching = true
|
6
|
+
config.assets.compile = false
|
7
|
+
config.assets.digest = true
|
8
|
+
config.log_level = :info
|
9
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*.log
|
16
|
+
/tmp
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link email.css
|
@@ -0,0 +1,32 @@
|
|
1
|
+
body {
|
2
|
+
background: #efefef;
|
3
|
+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
4
|
+
}
|
5
|
+
|
6
|
+
p {
|
7
|
+
line-height: 1.4;
|
8
|
+
}
|
9
|
+
|
10
|
+
.wrap {
|
11
|
+
max-width: 40em;
|
12
|
+
margin: 0 auto;
|
13
|
+
padding: 1em;
|
14
|
+
background: white;
|
15
|
+
}
|
16
|
+
|
17
|
+
.greeting {
|
18
|
+
text-align: center;
|
19
|
+
font-weight: bold;
|
20
|
+
font-size: 110%;
|
21
|
+
}
|
22
|
+
|
23
|
+
.footer {
|
24
|
+
font-size: 90%;
|
25
|
+
color: #666;
|
26
|
+
}
|
27
|
+
|
28
|
+
a {
|
29
|
+
color: green;
|
30
|
+
text-decoration: none;
|
31
|
+
border-bottom: 2px solid green;
|
32
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset='utf-8'>
|
5
|
+
<%= stylesheet_link_tag :email %>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div class='wrap'>
|
9
|
+
<p class='greeting'>Hi, John Doe</p>
|
10
|
+
<p>
|
11
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
12
|
+
</p>
|
13
|
+
<div class='footer'>
|
14
|
+
To unsubscribe, <a href='http://www.google.com/'>click here</a>.
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative 'boot'
|
2
|
+
|
3
|
+
require 'action_controller/railtie'
|
4
|
+
require 'action_mailer/railtie'
|
5
|
+
|
6
|
+
# Require the gems listed in Gemfile, including any gems
|
7
|
+
# you've limited to :test, :development, or :production.
|
8
|
+
Bundler.require(*Rails.groups)
|
9
|
+
|
10
|
+
module Example
|
11
|
+
class Application < Rails::Application
|
12
|
+
config.load_defaults 7.0
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.cache_classes = false
|
3
|
+
config.eager_load = false
|
4
|
+
config.consider_all_requests_local = true
|
5
|
+
config.action_controller.perform_caching = false
|
6
|
+
config.assets.debug = true
|
7
|
+
config.assets.digest = true
|
8
|
+
config.assets.raise_runtime_errors = true
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.cache_classes = true
|
3
|
+
config.eager_load = true
|
4
|
+
config.consider_all_requests_local = false
|
5
|
+
config.action_controller.perform_caching = true
|
6
|
+
config.assets.compile = false
|
7
|
+
config.assets.digest = true
|
8
|
+
config.log_level = :info
|
9
|
+
end
|
@@ -5,12 +5,8 @@ class Premailer
|
|
5
5
|
|
6
6
|
FileNotFound = Class.new(StandardError)
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
CSSLoaders::FileSystemLoader,
|
11
|
-
CSSLoaders::AssetPipelineLoader,
|
12
|
-
CSSLoaders::NetworkLoader
|
13
|
-
]
|
8
|
+
attr_accessor :cache
|
9
|
+
self.cache = {}
|
14
10
|
|
15
11
|
# Returns all linked CSS files concatenated as string.
|
16
12
|
def css_for_doc(doc)
|
@@ -18,8 +14,10 @@ class Premailer
|
|
18
14
|
end
|
19
15
|
|
20
16
|
def css_for_url(url)
|
21
|
-
|
22
|
-
|
17
|
+
if cache_enabled?
|
18
|
+
load_css_with_cache(url)
|
19
|
+
else
|
20
|
+
load_css(url)
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -36,14 +34,37 @@ class Premailer
|
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
37
|
+
def load_css_with_cache(url)
|
38
|
+
self.cache[url] ||= load_css(url)
|
39
|
+
end
|
40
|
+
|
41
|
+
def cache_enabled?
|
42
|
+
defined?(::Rails.env) && ::Rails.env.production?
|
43
|
+
end
|
44
|
+
|
39
45
|
def load_css(url)
|
40
|
-
|
41
|
-
css = strategy.load(url)
|
42
|
-
return css
|
46
|
+
Premailer::Rails.config.fetch(:strategies).each do |strategy|
|
47
|
+
css = find_strategy(strategy).load(url)
|
48
|
+
return css if css
|
43
49
|
end
|
44
50
|
|
45
51
|
raise FileNotFound, %{File with URL "#{url}" could not be loaded by any strategy.}
|
46
52
|
end
|
53
|
+
|
54
|
+
def find_strategy(key)
|
55
|
+
case key
|
56
|
+
when :filesystem
|
57
|
+
CSSLoaders::FileSystemLoader
|
58
|
+
when :asset_pipeline
|
59
|
+
CSSLoaders::AssetPipelineLoader
|
60
|
+
when :propshaft
|
61
|
+
CSSLoaders::PropshaftLoader
|
62
|
+
when :network
|
63
|
+
CSSLoaders::NetworkLoader
|
64
|
+
else
|
65
|
+
key
|
66
|
+
end
|
67
|
+
end
|
47
68
|
end
|
48
69
|
end
|
49
70
|
end
|
@@ -5,30 +5,31 @@ class Premailer
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def load(url)
|
8
|
-
|
9
|
-
file = file_name(url)
|
10
|
-
asset = ::Rails.application.assets.find_asset(file)
|
11
|
-
asset.to_s if asset
|
12
|
-
end
|
13
|
-
end
|
8
|
+
return unless asset_pipeline_present?
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
::Rails.application.respond_to?(:assets) &&
|
19
|
-
::Rails.application.assets
|
10
|
+
file = file_name(url)
|
11
|
+
::Rails.application.assets_manifest.find_sources(file).first
|
12
|
+
rescue Errno::ENOENT, TypeError => _error
|
20
13
|
end
|
21
14
|
|
22
15
|
def file_name(url)
|
23
|
-
prefix =
|
24
|
-
::Rails.configuration.relative_url_root,
|
25
|
-
::Rails.configuration.assets.prefix,
|
16
|
+
prefix = File.join(
|
17
|
+
::Rails.configuration.relative_url_root.to_s,
|
18
|
+
::Rails.configuration.assets.prefix.to_s,
|
26
19
|
'/'
|
27
|
-
|
20
|
+
)
|
28
21
|
URI(url).path
|
29
22
|
.sub(/\A#{prefix}/, '')
|
30
23
|
.sub(/-(\h{32}|\h{64})\.css\z/, '.css')
|
31
24
|
end
|
25
|
+
|
26
|
+
def asset_pipeline_present?
|
27
|
+
defined?(::Rails) &&
|
28
|
+
::Rails.respond_to?(:application) &&
|
29
|
+
::Rails.application &&
|
30
|
+
::Rails.application.respond_to?(:assets_manifest) &&
|
31
|
+
::Rails.application.assets_manifest
|
32
|
+
end
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -5,9 +5,31 @@ class Premailer
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def load(url)
|
8
|
+
file = file_name(url)
|
9
|
+
File.read(file) if File.file?(file)
|
10
|
+
end
|
11
|
+
|
12
|
+
def file_name(url)
|
8
13
|
path = URI(url).path
|
9
|
-
|
10
|
-
|
14
|
+
if relative_url_root
|
15
|
+
path = path.sub(/\A#{relative_url_root.chomp('/')}/, '')
|
16
|
+
end
|
17
|
+
asset_filename(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def asset_filename(filename)
|
21
|
+
if defined?(::Rails) && ::Rails.respond_to?(:root)
|
22
|
+
File.join(::Rails.root, 'public', filename)
|
23
|
+
else
|
24
|
+
File.join('public', filename)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def relative_url_root
|
29
|
+
defined?(::Rails) &&
|
30
|
+
::Rails.respond_to?(:configuration) &&
|
31
|
+
::Rails.configuration.respond_to?(:relative_url_root) &&
|
32
|
+
::Rails.configuration.relative_url_root
|
11
33
|
end
|
12
34
|
end
|
13
35
|
end
|
@@ -6,7 +6,7 @@ class Premailer
|
|
6
6
|
|
7
7
|
def load(url)
|
8
8
|
uri = uri_for_url(url)
|
9
|
-
Net::HTTP.get(uri) if uri
|
9
|
+
Net::HTTP.get(uri, { 'Accept' => 'text/css' }) if uri
|
10
10
|
end
|
11
11
|
|
12
12
|
def uri_for_url(url)
|
@@ -14,7 +14,7 @@ class Premailer
|
|
14
14
|
|
15
15
|
if uri.host.present?
|
16
16
|
return uri if uri.scheme.present?
|
17
|
-
URI("http
|
17
|
+
URI("http:#{uri}")
|
18
18
|
elsif asset_host_present?
|
19
19
|
scheme, host = asset_host(url).split(%r{:?//})
|
20
20
|
scheme, host = host, scheme if host.nil?
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Premailer
|
2
|
+
module Rails
|
3
|
+
module CSSLoaders
|
4
|
+
module PropshaftLoader
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def load(url)
|
8
|
+
return unless propshaft_present?
|
9
|
+
|
10
|
+
file = file_name(url)
|
11
|
+
asset = ::Rails.application.assets.load_path.find(file)
|
12
|
+
|
13
|
+
::Rails.application.assets.compilers.compile(asset) if asset
|
14
|
+
end
|
15
|
+
|
16
|
+
def file_name(url)
|
17
|
+
prefix = File.join(
|
18
|
+
::Rails.configuration.relative_url_root.to_s,
|
19
|
+
::Rails.configuration.assets.prefix.to_s,
|
20
|
+
'/'
|
21
|
+
)
|
22
|
+
|
23
|
+
# Path extraction logic from Propshaft.
|
24
|
+
# See https://github.com/rails/propshaft/blob/390381548b125e8721c8aef1b9d894b7cc8bd868/lib/propshaft/server.rb#L35-L41
|
25
|
+
full_path = URI(url).path.sub(/\A#{prefix}/, '')
|
26
|
+
digest = full_path[/-([0-9a-zA-Z]{7,128}(?:\.digested)?)\.[^.]+\z/, 1]
|
27
|
+
path = digest ? full_path.sub("-#{digest}", "") : full_path
|
28
|
+
|
29
|
+
path
|
30
|
+
end
|
31
|
+
|
32
|
+
def propshaft_present?
|
33
|
+
defined?(::Propshaft) && defined?(::Rails)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'uri'
|
2
2
|
|
3
|
-
require 'premailer/rails/css_loaders/cache_loader'
|
4
3
|
require 'premailer/rails/css_loaders/file_system_loader'
|
5
4
|
require 'premailer/rails/css_loaders/asset_pipeline_loader'
|
5
|
+
require 'premailer/rails/css_loaders/propshaft_loader'
|
6
6
|
require 'premailer/rails/css_loaders/network_loader'
|
@@ -4,10 +4,10 @@ class Premailer
|
|
4
4
|
def initialize(html)
|
5
5
|
# In order to pass the CSS as string to super it is necessary to access
|
6
6
|
# the parsed HTML beforehand. To do so, the adapter needs to be
|
7
|
-
# initialized. The ::Premailer::
|
8
|
-
# suitable
|
9
|
-
#
|
10
|
-
#
|
7
|
+
# initialized. The ::Premailer::Adapter handles the discovery of
|
8
|
+
# a suitable adapter. To make load_html work, an adapter needs to be
|
9
|
+
# included and @options[:with_html_string] needs to be set. For further
|
10
|
+
# information, refer to ::Premailer#initialize.
|
11
11
|
@options = Rails.config.merge(with_html_string: true)
|
12
12
|
Premailer.send(:include, Adapter.find(Adapter.use))
|
13
13
|
doc = load_html(html)
|
data/lib/premailer/rails/hook.rb
CHANGED
@@ -73,10 +73,8 @@ class Premailer
|
|
73
73
|
part = html_part
|
74
74
|
html = premailer.to_inline_css
|
75
75
|
Mail::Part.new do
|
76
|
-
|
77
|
-
content_type "text/html; charset=#{part.charset}"
|
76
|
+
content_type "text/html; charset=#{html.encoding}"
|
78
77
|
body html
|
79
|
-
body_encoding part.body.encoding
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
@@ -85,10 +83,8 @@ class Premailer
|
|
85
83
|
part = html_part
|
86
84
|
text = premailer.to_plain_text
|
87
85
|
Mail::Part.new do
|
88
|
-
|
89
|
-
content_type "text/plain; charset=#{part.charset}"
|
86
|
+
content_type "text/plain; charset=#{text.encoding}"
|
90
87
|
body text
|
91
|
-
body_encoding part.body.encoding
|
92
88
|
end
|
93
89
|
end
|
94
90
|
end
|
data/lib/premailer/rails.rb
CHANGED
data/premailer-rails.gemspec
CHANGED
@@ -16,16 +16,17 @@ Gem::Specification.new do |s|
|
|
16
16
|
include a CSS file as you do in a normal HTML document and
|
17
17
|
premailer will inline the included CSS.}
|
18
18
|
|
19
|
+
s.metadata["changelog_uri"] = "https://github.com/fphilipe/premailer-rails/blob/v#{Premailer::Rails::VERSION}/CHANGELOG.md"
|
20
|
+
|
19
21
|
s.files = `git ls-files`.split("\n")
|
20
22
|
s.test_files = `git ls-files -- {example,spec}/*`.split("\n")
|
21
23
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
24
|
s.require_paths = ["lib"]
|
23
25
|
|
24
26
|
s.add_dependency 'premailer', '~> 1.7', '>= 1.7.9'
|
25
|
-
s.add_dependency 'actionmailer', '>= 3'
|
27
|
+
s.add_dependency 'actionmailer', '>= 3'
|
28
|
+
s.add_dependency 'net-smtp' if RUBY_VERSION >= '3'
|
26
29
|
|
27
30
|
s.add_development_dependency 'rspec', '~> 3.3'
|
28
31
|
s.add_development_dependency 'nokogiri'
|
29
|
-
s.add_development_dependency 'hpricot' unless RUBY_PLATFORM == 'java'
|
30
|
-
s.add_development_dependency 'coveralls' if RUBY_ENGINE == 'ruby'
|
31
32
|
end
|