bootstrap-email 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/core/bootstrap-head.scss +3 -0
- data/core/layout.html.erb +1 -1
- data/lib/bootstrap-email/compiler.rb +4 -1
- data/lib/bootstrap-email/converters/add_missing_meta_tags.rb +21 -0
- data/lib/bootstrap-email/converters/base.rb +2 -1
- data/lib/bootstrap-email/converters/beautify_html.rb +10 -0
- data/lib/bootstrap-email/converters/force_encoding.rb +1 -1
- data/lib/bootstrap-email/converters/grid.rb +3 -0
- data/lib/bootstrap-email/converters/support_url_tokens.rb +17 -0
- data/lib/bootstrap-email/rails/action_mailer.rb +1 -0
- data/lib/bootstrap-email.rb +1 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3f5b4d09dc80df4d877dfc08c41130028dd2d2ac7b4ea2ab1bbc5a43dbd8adf
|
4
|
+
data.tar.gz: 6ea8c81c6262d1fffb2ac9bb46b7106df7d17ecac8a238e13e104d646cfaa7c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3621e262c91411d799672af6ce5e0aae3d2425effe4014a5744a8c2410a6c476084debe2b24716df50b2416ac328854927f521318a7b82c2c9e81e918b31845f
|
7
|
+
data.tar.gz: 480ea67acfa153d86e447930b03880096e6352a9394f3c07af3bdc812b9d3e8a9c620963ae3cc028641545992a24734b15afdcb0e0a141f23b4a4a9182451824
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.1
|
data/core/bootstrap-head.scss
CHANGED
data/core/layout.html.erb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
5
|
-
<meta name="x-apple-disable-message-reformatting">
|
6
5
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
6
|
+
<meta name="x-apple-disable-message-reformatting">
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
8
8
|
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
|
9
9
|
</head>
|
@@ -85,12 +85,15 @@ module BootstrapEmail
|
|
85
85
|
|
86
86
|
def configure_html!
|
87
87
|
BootstrapEmail::Converter::HeadStyle.build(doc)
|
88
|
+
BootstrapEmail::Converter::AddMissingMetaTags.build(doc)
|
88
89
|
BootstrapEmail::Converter::VersionComment.build(doc)
|
89
90
|
end
|
90
91
|
|
91
92
|
def finalize_document!
|
92
93
|
html = doc.to_html(encoding: 'US-ASCII')
|
93
|
-
|
94
|
+
BootstrapEmail::Converter::SupportUrlTokens.replace(html)
|
95
|
+
BootstrapEmail::Converter::ForceEncoding.replace(html)
|
96
|
+
BootstrapEmail::Converter::BeautifyHTML.replace(html)
|
94
97
|
case type
|
95
98
|
when :rails
|
96
99
|
(@mail.html_part || @mail).body = html
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BootstrapEmail
|
2
|
+
module Converter
|
3
|
+
class AddMissingMetaTags < Base
|
4
|
+
META_TAGS = [
|
5
|
+
{query: 'meta[http-equiv="Content-Type"]' , code: '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'},
|
6
|
+
{query: 'meta[http-equiv="x-ua-compatible"]', code: '<meta http-equiv="x-ua-compatible" content="ie=edge">'},
|
7
|
+
{query: 'meta[name="x-apple-disable-message-reformatting"]', code: '<meta name="x-apple-disable-message-reformatting">'},
|
8
|
+
{query: 'meta[name="viewport"]', code: '<meta name="viewport" content="width=device-width, initial-scale=1">'},
|
9
|
+
{query: 'meta[name="format-detection"]', code: '<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">'}
|
10
|
+
].reverse.freeze
|
11
|
+
|
12
|
+
def build
|
13
|
+
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
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -36,7 +36,8 @@ module BootstrapEmail
|
|
36
36
|
|
37
37
|
def add_class(node, class_name)
|
38
38
|
node['class'] ||= ''
|
39
|
-
|
39
|
+
# remove double spaces and strip white space from ends
|
40
|
+
node['class'] = "#{node['class']} #{class_name}".gsub(/\s+/, ' ').strip
|
40
41
|
end
|
41
42
|
|
42
43
|
def margin?(node)
|
@@ -4,7 +4,7 @@ module BootstrapEmail
|
|
4
4
|
def self.replace(html)
|
5
5
|
# force utf-8 character encoded in iOS Mail: https://github.com/bootstrap-email/bootstrap-email/issues/50
|
6
6
|
# this needs to be done after the document has been outputted to a ascii string so it doesn't get converted
|
7
|
-
html.sub(
|
7
|
+
html.sub!(
|
8
8
|
'<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">',
|
9
9
|
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
|
10
10
|
)
|
@@ -3,6 +3,9 @@ module BootstrapEmail
|
|
3
3
|
class Grid < Base
|
4
4
|
def build
|
5
5
|
each_node('.row') do |node|
|
6
|
+
if node.at("./*[contains(@class, 'col-lg-')]")
|
7
|
+
add_class(node, 'row-responsive')
|
8
|
+
end
|
6
9
|
node.replace(template('div', classes: node['class'], contents: template('table-to-tr', contents: node.inner_html)))
|
7
10
|
end
|
8
11
|
each_node('*[class*=col]') do |node|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BootstrapEmail
|
2
|
+
module Converter
|
3
|
+
class SupportUrlTokens < Base
|
4
|
+
OPEN_BRACKETS = CGI.escape('{{').freeze
|
5
|
+
CLOSE_BRACKETS = CGI.escape('}}').freeze
|
6
|
+
|
7
|
+
def self.replace(html)
|
8
|
+
regex = /((href|src)=(\"|\'))((#{Regexp.quote(OPEN_BRACKETS)}).*?(#{Regexp.quote(CLOSE_BRACKETS)}))(\"|\')/
|
9
|
+
if regex.match?(html)
|
10
|
+
html.gsub!(regex) do |match|
|
11
|
+
"#{$1}#{CGI.unescape($4)}#{$7}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -8,6 +8,7 @@ ActiveSupport.on_load(:action_mailer, {yield: true}) do |action_mailer|
|
|
8
8
|
bootstrap = BootstrapEmail::Compiler.new(mail_message, type: :rails)
|
9
9
|
bootstrap.perform_full_compile
|
10
10
|
end
|
11
|
+
mail_message
|
11
12
|
end
|
12
13
|
alias bootstrap_email bootstrap_mail
|
13
14
|
alias make_bootstrap_mail bootstrap_mail
|
data/lib/bootstrap-email.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Yamartino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: htmlbeautifier
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
55
69
|
description:
|
56
70
|
email: stu@stuyam.com
|
57
71
|
executables:
|
@@ -105,10 +119,12 @@ files:
|
|
105
119
|
- lib/bootstrap-email/bootstrap_email_cli.rb
|
106
120
|
- lib/bootstrap-email/compiler.rb
|
107
121
|
- lib/bootstrap-email/config.rb
|
122
|
+
- lib/bootstrap-email/converters/add_missing_meta_tags.rb
|
108
123
|
- lib/bootstrap-email/converters/alert.rb
|
109
124
|
- lib/bootstrap-email/converters/align.rb
|
110
125
|
- lib/bootstrap-email/converters/badge.rb
|
111
126
|
- lib/bootstrap-email/converters/base.rb
|
127
|
+
- lib/bootstrap-email/converters/beautify_html.rb
|
112
128
|
- lib/bootstrap-email/converters/block.rb
|
113
129
|
- lib/bootstrap-email/converters/body.rb
|
114
130
|
- lib/bootstrap-email/converters/button.rb
|
@@ -126,6 +142,7 @@ files:
|
|
126
142
|
- lib/bootstrap-email/converters/spacer.rb
|
127
143
|
- lib/bootstrap-email/converters/spacing.rb
|
128
144
|
- lib/bootstrap-email/converters/stack.rb
|
145
|
+
- lib/bootstrap-email/converters/support_url_tokens.rb
|
129
146
|
- lib/bootstrap-email/converters/table.rb
|
130
147
|
- lib/bootstrap-email/converters/version_comment.rb
|
131
148
|
- lib/bootstrap-email/erb.rb
|
@@ -156,7 +173,7 @@ requirements: []
|
|
156
173
|
rubygems_version: 3.0.3
|
157
174
|
signing_key:
|
158
175
|
specification_version: 4
|
159
|
-
summary: 'Bootstrap 5 stylesheet, compiler, and inliner for responsive and consistent
|
176
|
+
summary: 'Bootstrap 5+ stylesheet, compiler, and inliner for responsive and consistent
|
160
177
|
emails with the Bootstrap syntax you know and love. Support: command line, ruby,
|
161
178
|
rails'
|
162
179
|
test_files: []
|