channel_research_stationery 2.10.1 → 2.10.2

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
  SHA1:
3
- metadata.gz: be8fcc51204385c46925f081845b58c219b823c2
4
- data.tar.gz: 5db73a74956902fdb88e7c5c703d2e029b323ece
3
+ metadata.gz: 150977a0f49b4808ab1cdfe96c888dd38e588db0
4
+ data.tar.gz: 7ec3a658cd2a7886b1387550d89795d7b45a0459
5
5
  SHA512:
6
- metadata.gz: 3f5f9ddaa172edfa781ed39bbb394fc4aa312860c876259994fb203248ac7752f097e3b09f41db64e002b52b13d7e9bf7dcc036c23667415609ebecb87f58a88
7
- data.tar.gz: 902cdec642b2f97fe80e160c7cae6d5880445e58ff6d3ce951314c1837e79ab94d1bb2deab3ccfc46a0074c5d959c0a6df94034a3463a1000001270ffa163e1a
6
+ metadata.gz: 9f3cb0d100f5fa519a881e7ab195b4308b3675c8a2dfc4756714a0860a82bac7064528ad8f620d574ca9009697817b65ddca72df220cd87403702b1954a0ae53
7
+ data.tar.gz: 93fadde69def9e9cd2e5ea25558f682777b2acce53b0f3096f9c62aa5c6c8e963544cc466f345e9d5fd2c85d7d442d22f00b05cad6655cbfc8d6ea0593f07a32
@@ -19,31 +19,36 @@ class ChannelResearchStationery
19
19
  end
20
20
 
21
21
  def to_html
22
- @body_with_inline_css = body_with_inline_css
23
- layout_path = File.join( __dir__, "./generators/templates/layout.html.erb" )
24
- contents = File.open(layout_path, "rb").read
25
- ERB.new(contents).result( binding )
22
+ template_and_content
26
23
  end
27
24
 
28
- def body_with_inline_css
29
- doc_with_placeholder_content.at('body').to_html
30
- end
31
-
32
- def doc_with_placeholder_content
33
- doc = Nokogiri::HTML(template_with_inline_css)
34
- doc.at('div#main_content') << @content
25
+ def template_and_content
26
+ template = Nokogiri::HTML(template_with_inline_css)
27
+ content = Nokogiri::HTML(content_with_inline_css)
28
+ template.at('style').remove
29
+ template.at('div#content') << content.at('body')
35
30
  # Add content-editable bits
36
- doc.xpath('//*[@class="contenteditable"]').each do |node|
31
+ template.xpath('//*[@class="contenteditable"]').each do |node|
37
32
  node['contenteditable'] = 'true'
38
33
  end
39
- return doc
34
+ return template
40
35
  end
41
36
 
42
37
  def template_with_inline_css
43
38
  Premailer.new(template,
44
39
  {
45
40
  warn_level: Premailer::Warnings::SAFE,
46
- css_string: css_string,
41
+ css_string: template_css_string,
42
+ with_html_string: true
43
+ }
44
+ ).to_inline_css
45
+ end
46
+
47
+ def content_with_inline_css
48
+ Premailer.new(@content,
49
+ {
50
+ warn_level: Premailer::Warnings::SAFE,
51
+ css_string: content_css_string,
47
52
  with_html_string: true
48
53
  }
49
54
  ).to_inline_css
@@ -61,8 +66,12 @@ class ChannelResearchStationery
61
66
  engine.render(Object.new, { options: @options })
62
67
  end
63
68
 
64
- def css_string
65
- reset_css + styles_css
69
+ def template_css_string
70
+ reset_css + template_styles_css
71
+ end
72
+
73
+ def content_css_string
74
+ reset_css + content_styles_css + @options[:extra_css]
66
75
  end
67
76
 
68
77
  def reset_css
@@ -71,20 +80,28 @@ class ChannelResearchStationery
71
80
  end
72
81
 
73
82
  def sass_options
74
- @options.select {|k,v| [:background_color,:header_background_color,:width].include?(k)}
83
+ @options.select {|k,v| [:background_color,:header_background_color,:width,:cta_background_color,:cta_color,:bold_color,:link_color].include?(k)}
75
84
  end
76
85
 
77
86
  def sass_variables
78
87
  sass_options.map {|k,v| "$#{k}: #{v};"}.join("\n")
79
88
  end
80
89
 
81
- def styles_css
82
- css_path = File.join( __dir__, "./generators/templates/styles.sass" )
90
+ def template_styles_css
91
+ css_path = File.join( __dir__, "./generators/templates/template_styles.sass" )
92
+ sass_styles = File.open(css_path, "rb").read
93
+ sass = sass_variables + "\n" + sass_styles
94
+ SassC::Engine.new(sass, style: :compressed).render
95
+ end
96
+
97
+ def content_styles_css
98
+ css_path = File.join( __dir__, "./generators/templates/content_styles.sass" )
83
99
  sass_styles = File.open(css_path, "rb").read
84
100
  sass = sass_variables + "\n" + sass_styles
85
101
  SassC::Engine.new(sass, style: :compressed).render
86
102
  end
87
103
 
104
+
88
105
  def default_options
89
106
  {
90
107
  header_background_color: @primary_color,
@@ -97,7 +114,8 @@ class ChannelResearchStationery
97
114
  badge_left: false,
98
115
  badge_right: false,
99
116
  title: false,
100
- subtitle: false
117
+ subtitle: false,
118
+ extra_css: ''
101
119
  }
102
120
  end
103
121
  end
@@ -0,0 +1,18 @@
1
+ * {
2
+ font-size:13px;
3
+ font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif;
4
+ letter-spacing: -1px;
5
+ color: #666666;
6
+ line-height: 19px;
7
+ -webkit-text-size-adjust: none;
8
+ -webkit-font-smoothing: antialiased;
9
+ }
10
+ a {color:$link_color;}
11
+ strong, b {color:$bold_color;}
12
+ img {max-width:100%;}
13
+ p.call_to_action a {color: $cta_color; background-color: $cta_background_color;}
14
+ table {width:100%;}
15
+ table tr {vertical-align: top;}
16
+ table td,th {font-size:13px; padding:5px; color:#666666;}
17
+ table th {text-align: center; font-weight:bold;}
18
+ //<%= @options[:extra_css] %>
@@ -16,7 +16,7 @@
16
16
  %h1= options[:title]
17
17
  - if options[:subtitle]
18
18
  %h2= options[:subtitle]
19
- %div#main_content
19
+ %div#content
20
20
  %tr#footer
21
21
  %td
22
22
  %p TM and copyright &copy;#{DateTime.now.year} Apple Inc. All rights reserved.
@@ -56,15 +56,6 @@ table.email-body-wrap {
56
56
  padding-bottom:36px;
57
57
  color: #666666;
58
58
  }
59
- #main_content {
60
- font-size:13px;
61
- font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif;
62
- letter-spacing: -1px;
63
- color: #666666;
64
- line-height: 19px;
65
- -webkit-text-size-adjust: none;
66
- -webkit-font-smoothing: antialiased;
67
- }
68
59
  }
69
60
  tr#footer td {
70
61
  color: #666666;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: channel_research_stationery
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.1
4
+ version: 2.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Channel Research Team
@@ -73,10 +73,10 @@ extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
75
  - lib/channel_research_stationery.rb
76
- - lib/generators/templates/layout.html.erb
76
+ - lib/generators/templates/content_styles.sass
77
77
  - lib/generators/templates/reset.css
78
- - lib/generators/templates/styles.sass
79
78
  - lib/generators/templates/template.html.haml
79
+ - lib/generators/templates/template_styles.sass
80
80
  homepage: https://www.brandnewbox.com
81
81
  licenses:
82
82
  - MIT
@@ -1,13 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Channel Research Team</title>
4
- <link href='https://wwcci-email-assets.s3.amazonaws.com/bnb/css/myriad-set-pro.css' rel='stylesheet' type='text/css' />
5
- <style>
6
- #main_content a {color:<%= @options[:link_color] %>;}
7
- #main_content strong, #main_content b {color:<%= @options[:bold_color] %>;}
8
- #main_content img {max-width:100%;}
9
- #main_content p.call_to_action a {color: <%= @options[:cta_color] %>;background-color: <%= @options[:cta_background_color] %>;}
10
- </style>
11
- </head>
12
- <%= @body_with_inline_css %>
13
- </html>