bootstrap-email 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/bootstrap-email +2 -0
- data/lib/bootstrap-email/bootstrap_email_cli.rb +7 -5
- data/lib/bootstrap-email/compiler.rb +2 -0
- data/lib/bootstrap-email/config.rb +7 -5
- data/lib/bootstrap-email/converters/add_missing_meta_tags.rb +13 -8
- data/lib/bootstrap-email/converters/alert.rb +2 -0
- data/lib/bootstrap-email/converters/align.rb +8 -6
- data/lib/bootstrap-email/converters/badge.rb +2 -0
- data/lib/bootstrap-email/converters/base.rb +3 -0
- data/lib/bootstrap-email/converters/beautify_html.rb +3 -1
- data/lib/bootstrap-email/converters/block.rb +2 -0
- data/lib/bootstrap-email/converters/body.rb +2 -0
- data/lib/bootstrap-email/converters/button.rb +2 -0
- data/lib/bootstrap-email/converters/card.rb +2 -0
- data/lib/bootstrap-email/converters/color.rb +2 -0
- data/lib/bootstrap-email/converters/container.rb +2 -0
- data/lib/bootstrap-email/converters/ensure_doctype.rb +2 -0
- data/lib/bootstrap-email/converters/force_encoding.rb +2 -0
- data/lib/bootstrap-email/converters/grid.rb +3 -3
- data/lib/bootstrap-email/converters/head_style.rb +4 -3
- data/lib/bootstrap-email/converters/hr.rb +2 -0
- data/lib/bootstrap-email/converters/margin.rb +4 -6
- data/lib/bootstrap-email/converters/padding.rb +3 -1
- data/lib/bootstrap-email/converters/paragraph.rb +2 -0
- data/lib/bootstrap-email/converters/preview_text.rb +2 -0
- data/lib/bootstrap-email/converters/spacer.rb +2 -0
- data/lib/bootstrap-email/converters/spacing.rb +2 -0
- data/lib/bootstrap-email/converters/stack.rb +2 -0
- data/lib/bootstrap-email/converters/support_url_tokens.rb +7 -5
- data/lib/bootstrap-email/converters/table.rb +2 -0
- data/lib/bootstrap-email/converters/version_comment.rb +2 -0
- data/lib/bootstrap-email/erb.rb +2 -0
- data/lib/bootstrap-email/rails/action_mailer.rb +5 -3
- data/lib/bootstrap-email/rails/engine.rb +2 -0
- data/lib/bootstrap-email/sass_cache.rb +4 -6
- data/lib/bootstrap-email/setup.rb +3 -1
- data/lib/bootstrap-email/version.rb +2 -0
- data/lib/bootstrap-email.rb +3 -3
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49b2f67b9148d550ac5694fc59d9d279e942a51dbcb5505cb32bfa0c5a84dade
|
4
|
+
data.tar.gz: 4f470a2edd130fdb054fa6dc9a32f70ab03e2bbb479afd2bfe354d33e32735ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd6942d8716f6f6876bf71821ecb53f4a192edff297087815638ce1eb7855efb26efe1f43852730f8b8f864a7d5a8e2301819d2ac078129e309db3bdf14c6f75
|
7
|
+
data.tar.gz: 7419c2b2fa545037cf327689dfe9def42065edcc6c1b566ee2bcf7e9a3299c580aa2c3b3512172905b52597d0353cc554bb28457e3558c7fd5330ed2b1ec3e4a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.5
|
data/bin/bootstrap-email
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../bootstrap-email'
|
2
4
|
require 'optparse'
|
3
5
|
|
@@ -57,9 +59,9 @@ if input
|
|
57
59
|
elsif ARGV.any?
|
58
60
|
# Executed via command line or shell script
|
59
61
|
input = ARGV.shift
|
60
|
-
elsif
|
62
|
+
elsif !$stdin.tty?
|
61
63
|
# Called in piped command
|
62
|
-
input =
|
64
|
+
input = $stdin.read
|
63
65
|
options[:type] = :string
|
64
66
|
else
|
65
67
|
# Running just the blank command to compile all files in directory containing .html
|
@@ -74,16 +76,16 @@ if input
|
|
74
76
|
next unless File.file?(path)
|
75
77
|
|
76
78
|
puts "Compiling file #{path}"
|
77
|
-
compiled = BootstrapEmail::Compiler.new(path, type: :file, options: {config_path: options[:config]}).perform_full_compile
|
79
|
+
compiled = BootstrapEmail::Compiler.new(path, type: :file, options: { config_path: options[:config] }).perform_full_compile
|
78
80
|
destination = options[:destination].chomp('/*')
|
79
81
|
FileUtils.mkdir_p("#{Dir.pwd}/#{destination}")
|
80
82
|
File.write(File.expand_path("#{destination}/#{path.split('/').last}", Dir.pwd), compiled)
|
81
83
|
end
|
82
84
|
when :file
|
83
85
|
path = File.expand_path(input, Dir.pwd)
|
84
|
-
puts BootstrapEmail::Compiler.new(path, type: :file, options: {config_path: options[:config], sass_log_enabled: false}).perform_full_compile
|
86
|
+
puts BootstrapEmail::Compiler.new(path, type: :file, options: { config_path: options[:config], sass_log_enabled: false }).perform_full_compile
|
85
87
|
when :string
|
86
|
-
puts BootstrapEmail::Compiler.new(input, options: {config_path: options[:config], sass_log_enabled: false}).perform_full_compile
|
88
|
+
puts BootstrapEmail::Compiler.new(input, options: { config_path: options[:config], sass_log_enabled: false }).perform_full_compile
|
87
89
|
end
|
88
90
|
else
|
89
91
|
puts opts
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
class Config
|
3
|
-
attr_writer :sass_email_location # path to main sass file
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
attr_writer :sass_email_location, # path to main sass file
|
6
|
+
:sass_head_location, # path to head sass file
|
7
|
+
:sass_load_paths, # array of directories for loading sass imports
|
8
|
+
:sass_cache_location, # path to tmp folder for sass cache
|
9
|
+
:sass_log_enabled # turn on or off sass log when caching new sass
|
8
10
|
|
9
11
|
def load_options(options)
|
10
12
|
file = File.expand_path('bootstrap-email.config.rb', Dir.pwd)
|
@@ -1,19 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
module Converter
|
3
5
|
class AddMissingMetaTags < Base
|
4
6
|
META_TAGS = [
|
5
|
-
{query: 'meta[http-equiv="Content-Type"]'
|
6
|
-
|
7
|
-
{query: 'meta[
|
8
|
-
|
9
|
-
{query: 'meta[name="
|
7
|
+
{ query: 'meta[http-equiv="Content-Type"]',
|
8
|
+
code: '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' },
|
9
|
+
{ query: 'meta[http-equiv="x-ua-compatible"]',
|
10
|
+
code: '<meta http-equiv="x-ua-compatible" content="ie=edge">' },
|
11
|
+
{ query: 'meta[name="x-apple-disable-message-reformatting"]',
|
12
|
+
code: '<meta name="x-apple-disable-message-reformatting">' },
|
13
|
+
{ query: 'meta[name="viewport"]',
|
14
|
+
code: '<meta name="viewport" content="width=device-width, initial-scale=1">' },
|
15
|
+
{ query: 'meta[name="format-detection"]',
|
16
|
+
code: '<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">' }
|
10
17
|
].reverse.freeze
|
11
18
|
|
12
19
|
def build
|
13
20
|
META_TAGS.each do |tag_hash|
|
14
|
-
unless doc.at_css(tag_hash[:query])
|
15
|
-
doc.at_css('head').prepend_child(tag_hash[:code])
|
16
|
-
end
|
21
|
+
doc.at_css('head').prepend_child(tag_hash[:code]) unless doc.at_css(tag_hash[:query])
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
module Converter
|
3
5
|
class Align < Base
|
4
6
|
def build
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
%w[left center right].each do |type|
|
8
|
+
full_type = "ax-#{type}"
|
9
|
+
each_node(".#{full_type}") do |node|
|
10
|
+
align_helper(node, full_type, type)
|
11
|
+
end
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
def align_helper(node, full_type, type)
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
module Converter
|
3
5
|
class BeautifyHTML < Base
|
4
6
|
def self.replace(html)
|
5
7
|
# Pretty print format the HTML string and add a trailing newline
|
6
|
-
html.replace(HtmlBeautifier.beautify(html)
|
8
|
+
html.replace("#{HtmlBeautifier.beautify(html)}\n")
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
module Converter
|
3
5
|
class Grid < Base
|
4
6
|
def build
|
5
7
|
each_node('.row') do |node|
|
6
|
-
if node.at("./*[contains(@class, 'col-lg-')]")
|
7
|
-
add_class(node, 'row-responsive')
|
8
|
-
end
|
8
|
+
add_class(node, 'row-responsive') if node.at("./*[contains(@class, 'col-lg-')]")
|
9
9
|
node.replace(template('div', classes: node['class'], contents: template('table-to-tr', contents: node.inner_html)))
|
10
10
|
end
|
11
11
|
each_node('*[class*=col]') do |node|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
module Converter
|
3
5
|
class HeadStyle < Base
|
@@ -8,12 +10,11 @@ module BootstrapEmail
|
|
8
10
|
private
|
9
11
|
|
10
12
|
def bootstrap_email_head
|
11
|
-
|
13
|
+
<<-HTML
|
12
14
|
<style type="text/css">
|
13
15
|
#{purged_css_from_head}
|
14
16
|
</style>
|
15
|
-
|
16
|
-
html_string
|
17
|
+
HTML
|
17
18
|
end
|
18
19
|
|
19
20
|
def purged_css_from_head
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
module Converter
|
3
5
|
class Margin < Base
|
@@ -7,13 +9,9 @@ module BootstrapEmail
|
|
7
9
|
bottom_class = node['class'][/m[by]{1}-(lg-)?(\d+)/]
|
8
10
|
node['class'] = node['class'].gsub(/(m[tby]{1}-(lg-)?\d+)/, '').strip
|
9
11
|
html = ''
|
10
|
-
if top_class
|
11
|
-
html += template('div', classes: "s-#{top_class.gsub(/m[ty]{1}-/, '')}", contents: nil)
|
12
|
-
end
|
12
|
+
html += template('div', classes: "s-#{top_class.gsub(/m[ty]{1}-/, '')}", contents: nil) if top_class
|
13
13
|
html += node.to_html
|
14
|
-
if bottom_class
|
15
|
-
html += template('div', classes: "s-#{bottom_class.gsub(/m[by]{1}-/, '')}", contents: nil)
|
16
|
-
end
|
14
|
+
html += template('div', classes: "s-#{bottom_class.gsub(/m[by]{1}-/, '')}", contents: nil) if bottom_class
|
17
15
|
node.replace(html)
|
18
16
|
end
|
19
17
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
module Converter
|
3
5
|
class Padding < Base
|
4
6
|
def build
|
5
7
|
each_node("*[class^=p-], *[class^=pt-], *[class^=pr-], *[class^=pb-], *[class^=pl-], *[class^=px-], *[class^=py-], *[class*=' p-'], *[class*=' pt-'], *[class*=' pr-'], *[class*=' pb-'], *[class*=' pl-'], *[class*=' px-'], *[class*=' py-']") do |node|
|
6
|
-
next if [
|
8
|
+
next if %w[table td a].include?(node.name)
|
7
9
|
|
8
10
|
padding_regex = /(p[trblxy]?-(lg-)?\d+)/
|
9
11
|
classes = node['class'].gsub(padding_regex).to_a.join(' ')
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
module Converter
|
3
5
|
class SupportUrlTokens < Base
|
@@ -5,11 +7,11 @@ module BootstrapEmail
|
|
5
7
|
CLOSE_BRACKETS = CGI.escape('}}').freeze
|
6
8
|
|
7
9
|
def self.replace(html)
|
8
|
-
regex = /((href|src)=(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
regex = /((href|src)=("|').*?)((#{Regexp.quote(OPEN_BRACKETS)}).*?(#{Regexp.quote(CLOSE_BRACKETS)}))(.*?("|'))/
|
11
|
+
return unless regex.match?(html)
|
12
|
+
|
13
|
+
html.gsub!(regex) do |_match|
|
14
|
+
"#{Regexp.last_match(1)}#{CGI.unescape(Regexp.last_match(4))}#{Regexp.last_match(7)}"
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/bootstrap-email/erb.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
ActiveSupport.on_load(:action_mailer, { yield: true }) do |action_mailer|
|
2
4
|
action_mailer.class_eval do # To support Rails less than 6
|
3
5
|
# sit in the middle and compile the html
|
4
6
|
def bootstrap_mail(*args, &block)
|
@@ -10,7 +12,7 @@ ActiveSupport.on_load(:action_mailer, {yield: true}) do |action_mailer|
|
|
10
12
|
end
|
11
13
|
mail_message
|
12
14
|
end
|
13
|
-
|
14
|
-
|
15
|
+
alias_method :bootstrap_email, :bootstrap_mail
|
16
|
+
alias_method :make_bootstrap_mail, :bootstrap_mail
|
15
17
|
end
|
16
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
class SassCache
|
3
5
|
SASS_DIR = File.expand_path('../../core', __dir__)
|
@@ -22,9 +24,7 @@ module BootstrapEmail
|
|
22
24
|
|
23
25
|
def compile
|
24
26
|
cache_path = "#{cache_dir}/#{checksum}/#{type}.css"
|
25
|
-
unless cached?(cache_path)
|
26
|
-
compile_and_cache_scss(cache_path)
|
27
|
-
end
|
27
|
+
compile_and_cache_scss(cache_path) unless cached?(cache_path)
|
28
28
|
File.read(cache_path)
|
29
29
|
end
|
30
30
|
|
@@ -56,9 +56,7 @@ module BootstrapEmail
|
|
56
56
|
css = SassC::Engine.new(file, style: style).render
|
57
57
|
FileUtils.mkdir_p("#{cache_dir}/#{checksum}") unless File.directory?("#{cache_dir}/#{checksum}")
|
58
58
|
File.write(cache_path, css)
|
59
|
-
if BootstrapEmail.config.sass_log_enabled?
|
60
|
-
puts "New css file cached for #{type}"
|
61
|
-
end
|
59
|
+
puts "New css file cached for #{type}" if BootstrapEmail.config.sass_log_enabled?
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapEmail
|
2
4
|
class << self
|
3
5
|
def config
|
@@ -11,7 +13,7 @@ module BootstrapEmail
|
|
11
13
|
@config
|
12
14
|
end
|
13
15
|
|
14
|
-
def configure
|
16
|
+
def configure
|
15
17
|
@config ||= BootstrapEmail::Config.new
|
16
18
|
yield @config
|
17
19
|
end
|
data/lib/bootstrap-email.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'nokogiri'
|
2
4
|
require 'erb'
|
3
5
|
require 'ostruct'
|
@@ -12,9 +14,7 @@ begin
|
|
12
14
|
require 'rails'
|
13
15
|
rescue LoadError; end
|
14
16
|
|
15
|
-
if defined?(Rails)
|
16
|
-
require 'action_mailer'
|
17
|
-
end
|
17
|
+
require 'action_mailer' if defined?(Rails)
|
18
18
|
|
19
19
|
require_relative 'bootstrap-email/config'
|
20
20
|
require_relative 'bootstrap-email/setup'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Yamartino
|
@@ -11,61 +11,61 @@ cert_chain: []
|
|
11
11
|
date: 2022-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: htmlbeautifier
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: premailer
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.7'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.7'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: sassc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1
|
61
|
+
version: '2.1'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1
|
68
|
+
version: '2.1'
|
69
69
|
description:
|
70
70
|
email: stu@stuyam.com
|
71
71
|
executables:
|
@@ -155,7 +155,8 @@ files:
|
|
155
155
|
homepage: https://bootstrapemail.com
|
156
156
|
licenses:
|
157
157
|
- MIT
|
158
|
-
metadata:
|
158
|
+
metadata:
|
159
|
+
rubygems_mfa_required: 'true'
|
159
160
|
post_install_message:
|
160
161
|
rdoc_options: []
|
161
162
|
require_paths:
|