fx_awesome_mails 0.5.4 → 0.5.8
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69502109d0dfdc232e7a275be5c63898821f38161cf52ef9920d7d32f7e2eab4
|
|
4
|
+
data.tar.gz: e51f020211f9d25a61b5a13dff94f2d427a7fb225cff0d92dde0403e1f6cdbd9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3b168d06977bab1952007ba7049b849ce5de7786ed300355b7a6cb9389534e55c05ef660eb66b2ac799d13da1e325de9521f834ef835668763fc133f4745670
|
|
7
|
+
data.tar.gz: 0dd3e613ad591dd73565f4db39189d4a9512f3f4db488acb379a4e3fa7d41e09a645a1a063d9801705b1c3b026c9b232b2c3d3d8d87f02a3614508463dad0148
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module FXAwesomeMails
|
|
2
|
+
module Refinements
|
|
3
|
+
refine String do
|
|
4
|
+
def to_css_hash
|
|
5
|
+
Hash[split(';').map { _1.split(':').map(&:strip) }]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def merge_css_options(second, key)
|
|
9
|
+
return self&.strip if second.blank?
|
|
10
|
+
return second&.strip if self.blank?
|
|
11
|
+
|
|
12
|
+
case key
|
|
13
|
+
when :style
|
|
14
|
+
return self.strip.to_css_hash.deep_merge_v2(second.strip.to_css_hash).map {|k,v| [k,v].join(':') }.join(';')
|
|
15
|
+
when :class
|
|
16
|
+
self.strip.split(' ').union(second.strip.split(' ')).join(' ')
|
|
17
|
+
else
|
|
18
|
+
return ""
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
refine Hash do
|
|
24
|
+
def deep_merge_v2(second)
|
|
25
|
+
merger = proc { |_, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
|
|
26
|
+
merge(second.to_h, &merger)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def merge_email_options(second)
|
|
30
|
+
merger = proc { |k, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : [:style, :class].include?(k) ? v1.merge_css_options(v2, k) : v2}
|
|
31
|
+
merge(second.to_h, &merger)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
require 'fx_awesome_mails/
|
|
1
|
+
require 'fx_awesome_mails/refinements'
|
|
2
2
|
module FXAwesomeMails
|
|
3
3
|
module EmailHelpers
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
String.include FXAwesomeMails::CoreExtensions::String::Merging
|
|
5
|
+
using FXAwesomeMails::Refinements
|
|
7
6
|
|
|
8
7
|
def preheader(text)
|
|
9
8
|
"<div style='display: none; max-height: 0px; overflow: hidden;'>
|
|
@@ -130,12 +129,12 @@ module FXAwesomeMails
|
|
|
130
129
|
delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
|
|
131
130
|
|
|
132
131
|
def horizontal(height = '20', **options)
|
|
133
|
-
options = {valign: 'top', class: '',style: ""}.merge_email_options(options)
|
|
132
|
+
options = {valign: 'top', class: '',style: "text-align:left;font-size:1px;line-height:1px"}.merge_email_options(options)
|
|
134
133
|
content_tag('th', ' '.html_safe, height: height, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} horizontal-gutter", bgcolor: "#{options[:style].to_s.to_css_hash["background-color"]}")
|
|
135
134
|
end
|
|
136
135
|
|
|
137
136
|
def vertical(width = '20', **options)
|
|
138
|
-
options = {valign: 'top', class: '',style: ""}.merge_email_options(options)
|
|
137
|
+
options = {valign: 'top', class: '',style: "text-align:left;font-size:1px;line-height:1px"}.merge_email_options(options)
|
|
139
138
|
content_tag('th', ' '.html_safe, width: width, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} vertical-gutter", bgcolor: "#{options[:style].to_s.to_css_hash["background-color"]}")
|
|
140
139
|
end
|
|
141
140
|
end
|
|
@@ -164,7 +163,7 @@ module FXAwesomeMails
|
|
|
164
163
|
|
|
165
164
|
def email_image_tag(source: nil, **options, &block)
|
|
166
165
|
options = {alt: '', link_url: nil, width: 130, height: 50, valign: 'top', align: 'left', class: '', style: "background-color: #FFFFFF;outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; display: block; border: none" }.merge_email_options(options)
|
|
167
|
-
html = "<th valign='#{options[:
|
|
166
|
+
html = "<th valign='#{options[:valign]}' style='text-align:left' class='#{options[:class]} mobile-display-table-footer-group image-container' bgcolor='#{options[:style].to_s.to_css_hash["background-color"]}' align='#{options[:align]}'>"
|
|
168
167
|
html << link_to_if_true(options[:link_url].present?, options[:link_url], target: '_blank') do
|
|
169
168
|
image_tag(source, style: options[:style], width: "#{options[:width]}", height: "#{options[:height]}", alt: "#{options[:alt]}")
|
|
170
169
|
end
|
|
@@ -184,7 +183,7 @@ module FXAwesomeMails
|
|
|
184
183
|
|
|
185
184
|
def self.vertical_grid(_capture_helper, **options, &block)
|
|
186
185
|
options = { valign: 'top', style: "text-align: left" }.merge_email_options(options)
|
|
187
|
-
_capture_helper.content_tag('th', valign: "#{options[:valign]}", style: "#{options[:style]}", class: "
|
|
186
|
+
_capture_helper.content_tag('th', valign: "#{options[:valign]}", style: "#{options[:style]}", class: "vertical-grid #{options[:class]}") do
|
|
188
187
|
"<table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
|
|
189
188
|
<tbody>
|
|
190
189
|
#{_capture_helper.capture(VerticalGrid.new(_capture_helper), &block)}
|
|
@@ -229,7 +228,8 @@ module FXAwesomeMails
|
|
|
229
228
|
delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
|
|
230
229
|
|
|
231
230
|
def self.horizontal_grid(_capture_helper, **options, &block)
|
|
232
|
-
|
|
231
|
+
options = { valign: 'top', style: "text-align: left" }.merge_email_options(options)
|
|
232
|
+
"<th valign='#{options[:valign]}' style='#{options[:style]}' class='#{options[:class]} horizontal-grid'>
|
|
233
233
|
<table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
|
|
234
234
|
<tbody>
|
|
235
235
|
<tr>
|
|
@@ -244,11 +244,8 @@ module FXAwesomeMails
|
|
|
244
244
|
"#{Gutter.new(parent).vertical(...)}".html_safe
|
|
245
245
|
end
|
|
246
246
|
|
|
247
|
-
def text(
|
|
248
|
-
|
|
249
|
-
content_tag('th', valign: "#{options[:valign]}", style: "#{options[:style]}", class: "text-container #{options[:class]}") do
|
|
250
|
-
block_given? ? capture(&block) : text
|
|
251
|
-
end
|
|
247
|
+
def text(...)
|
|
248
|
+
"#{Text.new(parent).text(...)}".html_safe
|
|
252
249
|
end
|
|
253
250
|
|
|
254
251
|
def image(...)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fx_awesome_mails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Felix Gebhard
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-11-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -40,8 +40,8 @@ files:
|
|
|
40
40
|
- README.md
|
|
41
41
|
- Rakefile
|
|
42
42
|
- lib/fx_awesome_mails.rb
|
|
43
|
-
- lib/fx_awesome_mails/core_extensions.rb
|
|
44
43
|
- lib/fx_awesome_mails/railtie.rb
|
|
44
|
+
- lib/fx_awesome_mails/refinements.rb
|
|
45
45
|
- lib/fx_awesome_mails/version.rb
|
|
46
46
|
- lib/fx_awesome_mails/view_helpers.rb
|
|
47
47
|
- lib/tasks/fx_awesome_mails_tasks.rake
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
module FXAwesomeMails
|
|
2
|
-
module CoreExtensions
|
|
3
|
-
module Hash
|
|
4
|
-
module Merging
|
|
5
|
-
def deep_merge_v2(second)
|
|
6
|
-
merger = proc { |_, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
|
|
7
|
-
merge(second.to_h, &merger)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def merge_email_options(second)
|
|
11
|
-
merger = proc { |k, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : [:style, :class].include?(k) ? v1.merge_css_options(v2, k) : v2}
|
|
12
|
-
merge(second.to_h, &merger)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
module String
|
|
18
|
-
module Merging
|
|
19
|
-
def merge_css_options(second, key)
|
|
20
|
-
return self&.strip if second.blank?
|
|
21
|
-
return second&.strip if self.blank?
|
|
22
|
-
|
|
23
|
-
case key
|
|
24
|
-
when :style
|
|
25
|
-
return self.strip.to_css_hash.deep_merge_v2(second.strip.to_css_hash).map {|k,v| [k,v].join(':') }.join(';')
|
|
26
|
-
when :class
|
|
27
|
-
self.strip.split(' ').union(second.strip.split(' ')).join(' ')
|
|
28
|
-
else
|
|
29
|
-
return ""
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def to_css_hash
|
|
34
|
-
Hash[self.split(';').map { _1.split(':').map(&:strip) }]
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|