bootstrap-email 1.0.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3a9b2ebe28846362e698e13641ff407acd7419fa1cf578bf52702b616f80c1f
4
- data.tar.gz: d87d15ba04e2f789be9ab51577ff17ff9ae2cd2f9b8fbe6ab0e8ad1515de870c
3
+ metadata.gz: 257e7e4ae0bf137fca9ee3cc03cd1a6bd4a7c1d3d8eef531d2a97bf038dfbfd6
4
+ data.tar.gz: 25cacac6ef208b03fbceec3b1929707580e69c43359ba12f6a054f2c36ddd7e9
5
5
  SHA512:
6
- metadata.gz: a73433c6c50b383c3892b53277c7f97e083ace4edac30563e138c95e878bf86928748246ebc6212e93b606ce1df15dd1c3d9320deb238e42ecff68235c30e3a2
7
- data.tar.gz: eaf6bf4300bde849a713d4842784d8cd906ca2d256db0b548a99dfb5ce02a0da7384bd1aeff961b7a013dc928f5c886579edd4d43851a4b0c302e0d70b32ffe4
6
+ metadata.gz: 3953641981ecdbd8a82f81855d6b04faad06430e700b8f4c297fca85dc794a0d57d1e6360c0c689af78c722ff7b178bea45d076e6c568ec8dc96929e4677e2b1
7
+ data.tar.gz: fd34a8190a057dac9e7b45a54617598698a59a19af25a6e739df52f8f9ea72cf217da46250ca17bba0c0af22bd1fd6d685904e35572e5916001e2c6f3c9c254f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.2
@@ -88,7 +88,7 @@ table:not([class^=s-]) {
88
88
  }
89
89
  }
90
90
  }
91
- .row.row-responsive {
91
+ .row-responsive.row {
92
92
  margin-right: 0 !important;
93
93
  }
94
94
 
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>
@@ -16,7 +16,7 @@
16
16
  padding: $btn-padding-y $btn-padding-x;
17
17
  line-height: $btn-line-height;
18
18
  border: $btn-border-width solid transparent;
19
- display: inline-block;
19
+ display: block;
20
20
  font-weight: $btn-font-weight;
21
21
  white-space: nowrap;
22
22
  }
@@ -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
- html = BootstrapEmail::Converter::ForceEncoding.replace(html)
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
- node['class'] = "#{node['class'].strip} #{class_name}".strip
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)
@@ -0,0 +1,10 @@
1
+ module BootstrapEmail
2
+ module Converter
3
+ class BeautifyHTML < Base
4
+ def self.replace(html)
5
+ # Pretty print format the HTML string and add a trailing newline
6
+ html.replace(HtmlBeautifier.beautify(html) + "\n")
7
+ end
8
+ end
9
+ end
10
+ end
@@ -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
  )
@@ -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
@@ -6,6 +6,7 @@ require 'sassc'
6
6
  require 'digest/sha1'
7
7
  require 'css_parser'
8
8
  require 'fileutils'
9
+ require 'htmlbeautifier'
9
10
 
10
11
  begin
11
12
  require 'rails'
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.0.1
4
+ version: 1.1.2
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-09-17 00:00:00.000000000 Z
11
+ date: 2022-01-07 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: []