activemail 2.0.0 → 2.1.1

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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +62 -1
  3. data/README.md +44 -17
  4. data/UPGRADING.md +66 -0
  5. data/app/assets/stylesheets/activemail/_dark.scss +17 -8
  6. data/app/assets/stylesheets/activemail/_grid.scss +38 -14
  7. data/app/assets/stylesheets/activemail/_settings.scss +1 -0
  8. data/app/views/layouts/activemail/_document_head.html.erb +18 -0
  9. data/app/views/layouts/activemail/mailer.html.inky-erb +1 -17
  10. data/lib/activemail/components/button_renderer.rb +8 -4
  11. data/lib/activemail/components/center.rb +8 -1
  12. data/lib/activemail/components/columns.rb +32 -8
  13. data/lib/activemail/components/container.rb +2 -2
  14. data/lib/activemail/inliner/premailer/document.rb +100 -0
  15. data/lib/activemail/inliner/premailer.rb +3 -2
  16. data/lib/activemail/quality/builtin_message_rules.rb +58 -0
  17. data/lib/activemail/quality/builtin_rules.rb +41 -30
  18. data/lib/activemail/quality/configuration.rb +31 -16
  19. data/lib/activemail/quality/guard.rb +34 -14
  20. data/lib/activemail/quality/minitest.rb +24 -11
  21. data/lib/activemail/quality/output_filter.rb +24 -0
  22. data/lib/activemail/quality/render_all.rb +4 -4
  23. data/lib/activemail/quality/rspec.rb +11 -6
  24. data/lib/activemail/quality/rule_exemptions.rb +49 -0
  25. data/lib/activemail/tokens/defaults.rb +2 -1
  26. data/lib/activemail/version.rb +1 -1
  27. data/lib/generators/activemail/templates/mailer_layout.html.inky-erb +3 -17
  28. data/lib/generators/activemail/templates/mailer_layout.html.inky-haml +3 -9
  29. data/lib/generators/activemail/templates/mailer_layout.html.inky-slim +3 -8
  30. metadata +6 -1
@@ -0,0 +1,49 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require 'sorbet-runtime'
5
+
6
+ require_relative 'guard'
7
+
8
+ module ActiveMail
9
+ module Quality
10
+ # Rules a preview is exempt from, keyed by preview name (every email of it) or by
11
+ # preview key ("preview_name#email"); values are rule names, built-in or custom.
12
+ module RuleExemptions
13
+ extend T::Sig
14
+
15
+ sig { returns(T::Hash[String, T::Array[Symbol]]) }
16
+ def rule_exemptions
17
+ exemptions.dup.freeze
18
+ end
19
+
20
+ sig { params(value: T.untyped).void }
21
+ def rule_exemptions=(value)
22
+ Kernel.raise TypeError, "rule_exemptions must be a Hash, got #{value.class}" unless value.is_a?(Hash)
23
+
24
+ exemptions = value.to_h { |key, rules| [key.to_s.freeze, Kernel.Array(rules).map(&:to_sym).freeze] }
25
+ @exemptions = T.let(exemptions, T.nilable(T::Hash[String, T::Array[Symbol]]))
26
+ end
27
+
28
+ sig { params(key: String).returns(T::Array[Symbol]) }
29
+ def exempt_rules_for(key)
30
+ by_key = exemptions.fetch(key, Guard::NO_SKIP)
31
+ by_name = exemptions.fetch(key.split('#', 2).first.to_s, Guard::NO_SKIP)
32
+ by_key.empty? ? by_name : by_key | by_name
33
+ end
34
+
35
+ # Called before any preview renders: a bad name would otherwise surface as a render failure, or a skip.
36
+ sig { params(guard: Guard).void }
37
+ def check_exemptions!(guard)
38
+ exemptions.each_value { |rules| guard.check_skippable!(rules) }
39
+ end
40
+
41
+ private
42
+
43
+ sig { returns(T::Hash[String, T::Array[Symbol]]) }
44
+ def exemptions
45
+ @exemptions ||= T.let({}, T.nilable(T::Hash[String, T::Array[Symbol]]))
46
+ end
47
+ end
48
+ end
49
+ end
@@ -36,7 +36,8 @@ module ActiveMail
36
36
  sm: '8px',
37
37
  md: '16px',
38
38
  lg: '24px',
39
- xl: '40px'
39
+ xl: '40px',
40
+ container_gutter: '16px'
40
41
  }.freeze,
41
42
  TokenMap
42
43
  )
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module ActiveMail
5
- VERSION = '2.0.0'
5
+ VERSION = '2.1.1'
6
6
  end
@@ -1,27 +1,13 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="<%%= I18n.locale %>" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <meta name="x-apple-disable-message-reformatting">
7
- <meta name="color-scheme" content="light dark">
8
- <meta name="supported-color-schemes" content="light dark">
9
- <!--[if mso]>
10
- <noscript>
11
- <xml>
12
- <o:OfficeDocumentSettings>
13
- <o:PixelsPerInch>96</o:PixelsPerInch>
14
- </o:OfficeDocumentSettings>
15
- </xml>
16
- </noscript>
17
- <![endif]-->
18
- <%%= activemail_inline_styles %>
19
- </head>
3
+ <%%= render "layouts/activemail/document_head" %>
20
4
 
21
5
  <body style="margin:0;padding:0;word-spacing:normal;">
22
6
  <div role="article" aria-roledescription="email" lang="<%%= I18n.locale %>" style="width:100%;">
23
7
  <container>
8
+ <%%= render "layouts/activemail/head" %>
24
9
  <%%= yield %>
10
+ <%%= render "layouts/activemail/footer" %>
25
11
  </container>
26
12
  </div>
27
13
  </body>
@@ -1,15 +1,9 @@
1
1
  !!!
2
2
  %html{lang: I18n.locale, xmlns: "http://www.w3.org/1999/xhtml", "xmlns:v" => "urn:schemas-microsoft-com:vml", "xmlns:o" => "urn:schemas-microsoft-com:office:office"}
3
- %head
4
- %meta{charset: "utf-8"}
5
- %meta{name: "viewport", content: "width=device-width, initial-scale=1"}
6
- %meta{name: "x-apple-disable-message-reformatting"}
7
- %meta{name: "color-scheme", content: "light dark"}
8
- %meta{name: "supported-color-schemes", content: "light dark"}
9
- :plain
10
- <!--[if mso]><noscript><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml></noscript><![endif]-->
11
- = activemail_inline_styles
3
+ = render "layouts/activemail/document_head"
12
4
  %body{style: "margin:0;padding:0;word-spacing:normal;"}
13
5
  %div{role: "article", "aria-roledescription" => "email", lang: I18n.locale, style: "width:100%;"}
14
6
  %container
7
+ = render "layouts/activemail/head"
15
8
  = yield
9
+ = render "layouts/activemail/footer"
@@ -1,14 +1,9 @@
1
1
  doctype html
2
2
  html lang=I18n.locale xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
3
- head
4
- meta charset="utf-8"
5
- meta name="viewport" content="width=device-width, initial-scale=1"
6
- meta name="x-apple-disable-message-reformatting"
7
- meta name="color-scheme" content="light dark"
8
- meta name="supported-color-schemes" content="light dark"
9
- | <!--[if mso]><noscript><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml></noscript><![endif]-->
10
- = activemail_inline_styles
3
+ = render "layouts/activemail/document_head"
11
4
  body style="margin:0;padding:0;word-spacing:normal;"
12
5
  div role="article" aria-roledescription="email" lang=I18n.locale style="width:100%;"
13
6
  container
7
+ = render "layouts/activemail/head"
14
8
  = yield
9
+ = render "layouts/activemail/footer"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemail
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Advitam
@@ -90,6 +90,7 @@ files:
90
90
  - app/assets/stylesheets/activemail/_utilities.scss
91
91
  - app/assets/stylesheets/activemail/activemail.scss
92
92
  - app/helpers/active_mail/styles_helper.rb
93
+ - app/views/layouts/activemail/_document_head.html.erb
93
94
  - app/views/layouts/activemail/_footer.html.inky-erb
94
95
  - app/views/layouts/activemail/_head.html.inky-erb
95
96
  - app/views/layouts/activemail/mailer.html.inky-erb
@@ -122,20 +123,24 @@ files:
122
123
  - lib/activemail/inliner/base.rb
123
124
  - lib/activemail/inliner/null.rb
124
125
  - lib/activemail/inliner/premailer.rb
126
+ - lib/activemail/inliner/premailer/document.rb
125
127
  - lib/activemail/inliner/roadie.rb
126
128
  - lib/activemail/libxml.rb
127
129
  - lib/activemail/parse_error_reporter.rb
128
130
  - lib/activemail/pipeline.rb
129
131
  - lib/activemail/quality.rb
132
+ - lib/activemail/quality/builtin_message_rules.rb
130
133
  - lib/activemail/quality/builtin_rules.rb
131
134
  - lib/activemail/quality/configuration.rb
132
135
  - lib/activemail/quality/guard.rb
133
136
  - lib/activemail/quality/minitest.rb
134
137
  - lib/activemail/quality/output_dir.rb
138
+ - lib/activemail/quality/output_filter.rb
135
139
  - lib/activemail/quality/preview_renderer.rb
136
140
  - lib/activemail/quality/render_all.rb
137
141
  - lib/activemail/quality/rspec.rb
138
142
  - lib/activemail/quality/rule.rb
143
+ - lib/activemail/quality/rule_exemptions.rb
139
144
  - lib/activemail/rails/engine.rb
140
145
  - lib/activemail/rails/rendering.rb
141
146
  - lib/activemail/rails/template_handler.rb