inkcite 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/assets/init/helpers.tsv +7 -0
  4. data/assets/social/facebook.png +0 -0
  5. data/assets/social/pintrest.png +0 -0
  6. data/assets/social/twitter.png +0 -0
  7. data/inkcite.gemspec +5 -4
  8. data/lib/inkcite.rb +17 -6
  9. data/lib/inkcite/animation.rb +135 -0
  10. data/lib/inkcite/cli/base.rb +5 -14
  11. data/lib/inkcite/cli/build.rb +3 -3
  12. data/lib/inkcite/cli/init.rb +3 -3
  13. data/lib/inkcite/cli/preview.rb +25 -1
  14. data/lib/inkcite/cli/server.rb +1 -1
  15. data/lib/inkcite/cli/validate.rb +2 -11
  16. data/lib/inkcite/email.rb +1 -1
  17. data/lib/inkcite/mailer.rb +5 -0
  18. data/lib/inkcite/minifier.rb +58 -11
  19. data/lib/inkcite/renderer.rb +10 -2
  20. data/lib/inkcite/renderer/base.rb +45 -3
  21. data/lib/inkcite/renderer/button.rb +16 -12
  22. data/lib/inkcite/renderer/container_base.rb +14 -4
  23. data/lib/inkcite/renderer/element.rb +13 -3
  24. data/lib/inkcite/renderer/image.rb +46 -19
  25. data/lib/inkcite/renderer/image_base.rb +3 -3
  26. data/lib/inkcite/renderer/in_browser.rb +1 -1
  27. data/lib/inkcite/renderer/link.rb +91 -59
  28. data/lib/inkcite/renderer/lorem.rb +9 -1
  29. data/lib/inkcite/renderer/mobile_image.rb +3 -11
  30. data/lib/inkcite/renderer/mobile_only.rb +48 -0
  31. data/lib/inkcite/renderer/outlook_background.rb +61 -13
  32. data/lib/inkcite/renderer/property.rb +1 -1
  33. data/lib/inkcite/renderer/responsive.rb +10 -8
  34. data/lib/inkcite/renderer/snow.rb +20 -10
  35. data/lib/inkcite/renderer/social.rb +128 -0
  36. data/lib/inkcite/renderer/table.rb +13 -1
  37. data/lib/inkcite/renderer/table_base.rb +3 -3
  38. data/lib/inkcite/renderer/td.rb +32 -7
  39. data/lib/inkcite/renderer/video_preview.rb +257 -0
  40. data/lib/inkcite/uploader.rb +3 -3
  41. data/lib/inkcite/util.rb +19 -5
  42. data/lib/inkcite/version.rb +1 -1
  43. data/lib/inkcite/view.rb +29 -18
  44. data/lib/inkcite/view/context.rb +30 -0
  45. data/test/animation_spec.rb +38 -0
  46. data/test/email_spec.rb +0 -4
  47. data/test/minifier_spec.rb +243 -4
  48. data/test/parser_spec.rb +0 -4
  49. data/test/project/helpers.tsv +3 -0
  50. data/test/renderer/button_spec.rb +15 -13
  51. data/test/renderer/div_spec.rb +13 -4
  52. data/test/renderer/element_spec.rb +1 -5
  53. data/test/renderer/footnote_spec.rb +0 -4
  54. data/test/renderer/image_spec.rb +27 -11
  55. data/test/renderer/link_spec.rb +14 -4
  56. data/test/renderer/lorem_spec.rb +0 -4
  57. data/test/renderer/mobile_image_spec.rb +3 -11
  58. data/test/renderer/mobile_only_spec.rb +21 -0
  59. data/test/renderer/mobile_style_spec.rb +1 -5
  60. data/test/renderer/outlook_background_spec.rb +61 -0
  61. data/test/renderer/redacted_spec.rb +0 -4
  62. data/test/renderer/social_spec.rb +53 -0
  63. data/test/renderer/span_spec.rb +0 -4
  64. data/test/renderer/table_spec.rb +8 -4
  65. data/test/renderer/td_spec.rb +0 -4
  66. data/test/renderer/video_preview_spec.rb +19 -0
  67. data/test/renderer_spec.rb +0 -4
  68. data/test/test_helper.rb +7 -0
  69. data/test/view_spec.rb +12 -4
  70. metadata +89 -56
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Parser do
6
2
 
7
3
  it 'can resolve name=value parameters' do
@@ -36,9 +36,12 @@ small-font-size 11
36
36
  big <div style="font-size: 18px; font-weight: bold; color: $color=#444444$"> </div>
37
37
 
38
38
  // Bullet-proof buttons
39
+ button-bgcolor #0099cc
39
40
  button-border-radius 5
41
+ button-color #99ffff
40
42
  button-float center
41
43
  button-padding 8
44
+ button-text-shadow #003d52
42
45
  button-width 175
43
46
 
44
47
  // Dimensions
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::Button do
6
2
 
7
3
  before do
@@ -10,36 +6,42 @@ describe Inkcite::Renderer::Button do
10
6
 
11
7
  it 'inherits default settings from the context' do
12
8
  Inkcite::Renderer.render('{button id="learn-more" href="http://inkceptional.com"}Learn More{/button}', @view).
13
- must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#99ffff;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
9
+ must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#0099cc;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
14
10
  end
15
11
 
16
12
  it 'can have a custom background color' do
17
13
  Inkcite::Renderer.render('{button id="learn-more" href="http://inkceptional.com" bgcolor=#090}Learn More{/button}', @view).
18
- must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#009900 border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"padding:8px;text-shadow:0 -1px 0 #003d00\"><a href=\"http://inkceptional.com\" style=\"color:#99ff99;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
14
+ must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#009900 border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#0099cc;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
19
15
  end
20
16
 
21
- it 'can have a custom bevel that is dynamically colored based on the background color' do
22
- Inkcite::Renderer.render('{button id="learn-more" href="http://inkceptional.com" bevel=3}Learn More{/button}', @view).
23
- must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-bottom:3px solid #003d52;border-collapse:separate;border-radius:5px\" width=175><tr>\n<td align=center style=\"padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#99ffff;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
17
+ it 'can have a custom bevel' do
18
+ Inkcite::Renderer.render('{button id="learn-more" href="http://inkceptional.com" bevel=3 bevel-color=#ff0000}Learn More{/button}', @view).
19
+ must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-bottom:3px solid #ff0000;border-collapse:separate;border-radius:5px\" width=175><tr>\n<td align=center style=\"padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#0099cc;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
24
20
  end
25
21
 
26
22
  it 'can have a custom font size' do
27
23
  Inkcite::Renderer.render('{button id="learn-more" href="http://inkceptional.com" font-size=27}Learn More{/button}', @view).
28
- must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"font-size:27px;padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#99ffff;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
24
+ must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"font-size:27px;padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#0099cc;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
29
25
  end
30
26
 
31
27
  it 'has px line-height by default, if specified' do
32
28
  Inkcite::Renderer.render('{button id="learn-more" href="http://inkceptional.com" font-size=27 line-height=56}Learn More{/button}', @view).
33
- must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"font-size:27px;line-height:56px;padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#99ffff;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
29
+ must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"font-size:27px;line-height:56px;padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#0099cc;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
34
30
  end
35
31
 
36
32
  it 'accepts line-height specified in em units' do
37
33
  Inkcite::Renderer.render('{button id="learn-more" href="http://inkceptional.com" font-size=27 line-height=2em}Learn More{/button}', @view).
38
- must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"font-size:27px;line-height:2em;padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#99ffff;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
34
+ must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"font-size:27px;line-height:2em;padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#0099cc;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
39
35
  end
40
36
 
41
37
  it 'accepts normal line-height' do
42
38
  Inkcite::Renderer.render('{button id="learn-more" href="http://inkceptional.com" font-size=27 line-height=normal}Learn More{/button}', @view).
43
- must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"font-size:27px;line-height:normal;padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#99ffff;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
39
+ must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"font-size:27px;line-height:normal;padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#0099cc;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
40
+ end
41
+
42
+ it 'supports letter spacing' do
43
+ Inkcite::Renderer.render('{button id="learn-more" href="http://inkceptional.com" letter-spacing=2px}Learn More{/button}', @view).
44
+ must_equal("<a href=\"http://inkceptional.com\" style=\"text-decoration:none\" target=_blank><table align=center bgcolor=#0099cc border=0 cellpadding=8 cellspacing=0 class=\"fill\" style=\"border-radius:5px\" width=175><tr>\n<td align=center style=\"padding:8px;text-shadow:0 -1px 0 #003d52\"><a href=\"http://inkceptional.com\" style=\"color:#0099cc;letter-spacing:2px;text-decoration:none\" target=_blank>Learn More</a></td>\n</tr></table></a>")
44
45
  end
46
+
45
47
  end
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::Div do
6
2
 
7
3
  before do
@@ -89,6 +85,11 @@ describe Inkcite::Renderer::Div do
89
85
  @view.media_query.find_by_klass('m1').to_css.must_equal('div[class~="m1"] { line-height:20px !important }')
90
86
  end
91
87
 
88
+ it 'can have a custom font color on mobile' do
89
+ Inkcite::Renderer.render('{div color=#049 mobile-color=#f90}{/div}', @view).must_equal('<div class="m1" style="color:#004499"></div>')
90
+ @view.media_query.find_by_klass('m1').declarations.must_match('color:#ff9900 !important')
91
+ end
92
+
92
93
  it 'can inherit a custom font size on mobile from the context' do
93
94
  Inkcite::Renderer.render('{div font=responsive}{/div}', @view).must_equal('<div class="m1" style="font-size:20px"></div>')
94
95
  @view.media_query.find_by_klass('m1').declarations.must_match('font-size:40px')
@@ -98,4 +99,12 @@ describe Inkcite::Renderer::Div do
98
99
  Inkcite::Renderer.render('{div align=right}{/div}', @view).must_equal('<div style="text-align:right"></div>')
99
100
  end
100
101
 
102
+ it 'supports automatic background gradient' do
103
+ Inkcite::Renderer.render('{div bgcolor=#f00 bggradient=#00f}{/div}', @view).must_equal('<div style="background-color:#ff0000;background-image:radial-gradient(circle at center, #ff0000, #0000ff)"></div>')
104
+ end
105
+
106
+ it 'supports custom background gradient' do
107
+ Inkcite::Renderer.render('{div bggradient="radial-gradient(circle at center, #5b5f66, #1d1f21)"}{/div}', @view).must_equal('<div style="background-image:radial-gradient(circle at center, #5b5f66, #1d1f21)"></div>')
108
+ end
109
+
101
110
  end
@@ -1,11 +1,7 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::Element do
6
2
 
7
3
  it 'has configurable attributes' do
8
- e = Inkcite::Renderer::Element.new('a', :href => '"http://inkceptional.com"', :target => '"_blank"').to_s.must_equal('<a href="http://inkceptional.com" target="_blank">')
4
+ Inkcite::Renderer::Element.new('a', :href => '"http://inkceptional.com"', :target => '"_blank"').to_s.must_equal('<a href="http://inkceptional.com" target="_blank">')
9
5
  end
10
6
 
11
7
  it 'has configurable styles which are rendered alphabetically' do
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::Footnote do
6
2
 
7
3
  before do
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::Image do
6
2
 
7
3
  before do
@@ -20,12 +16,12 @@ describe Inkcite::Renderer::Image do
20
16
 
21
17
  it 'substitutes a placeholder for a missing image of sufficient size' do
22
18
  @view.config[Inkcite::Email::IMAGE_PLACEHOLDERS] = true
23
- Inkcite::Renderer.render('{img src=missing.jpg height=50 width=100}', @view).must_equal('<img border=0 height=50 src="//placeholdit.imgix.net/~text?fm=jpg&h=50&txt=missing.jpg%0A%28100%C3%9750%29&txtsize=18&txttrack=0&w=100" style="display:block" width=100>')
19
+ Inkcite::Renderer.render('{img src=missing.jpg height=50 width=100}', @view).must_equal('<img border=0 height=50 src="http://placeholdit.imgix.net/~text?fm=jpg&h=50&txt=missing.jpg%0A%28100%C3%9750%29&txtsize=18&txttrack=0&w=100" style="display:block" width=100>')
24
20
  end
25
21
 
26
22
  it 'has configurable placeholder text' do
27
23
  @view.config[Inkcite::Email::IMAGE_PLACEHOLDERS] = true
28
- Inkcite::Renderer.render('{img src=missing.jpg height=50 width=100 fpo="F P O"}', @view).must_equal('<img border=0 height=50 src="//placeholdit.imgix.net/~text?fm=jpg&h=50&txt=F+P+O%0A%28100%C3%9750%29&txtsize=18&txttrack=0&w=100" style="display:block" width=100>')
24
+ Inkcite::Renderer.render('{img src=missing.jpg height=50 width=100 fpo="F P O"}', @view).must_equal('<img border=0 height=50 src="http://placeholdit.imgix.net/~text?fm=jpg&h=50&txt=F+P+O%0A%28100%C3%9750%29&txtsize=18&txttrack=0&w=100" style="display:block" width=100>')
29
25
  end
30
26
 
31
27
  it 'does not substitute placeholders for small images' do
@@ -49,17 +45,24 @@ describe Inkcite::Renderer::Image do
49
45
  Inkcite::Renderer.render('{img src=inkcite.jpg height=73 width=73 display=inline}', @view).must_equal('<img align=absmiddle border=0 height=73 src="images/inkcite.jpg" style="display:inline;vertical-align:middle" width=73>')
50
46
  end
51
47
 
52
- it 'defaults to "small" font styling when alt text is present' do
53
- Inkcite::Renderer.render('{img src=inkcite.jpg height=73 width=73 alt="Inkcite Avatar"}', @view).must_equal('<img alt="Inkcite Avatar" border=0 height=73 src="images/inkcite.jpg" style="color:#cccccc;display:block;font-size:11px" width=73>')
48
+ it 'has no font styling unless specified' do
49
+ Inkcite::Renderer.render('{img src=inkcite.jpg height=73 width=73 alt="Inkcite Avatar"}', @view).must_equal('<img alt="Inkcite Avatar" border=0 height=73 src="images/inkcite.jpg" style="display:block" width=73>')
54
50
  end
55
51
 
56
52
  it 'supports blank alt text' do
57
53
  Inkcite::Renderer.render('{img src=inkcite.jpg height=73 width=73 alt=""}', @view).must_equal('<img alt="" border=0 height=73 src="images/inkcite.jpg" style="display:block" width=73>')
54
+ end
58
55
 
56
+ it 'supports configurable font attributes' do
57
+ Inkcite::Renderer.render('{img src=inkcite.jpg height=73 width=73 font="small" alt="Inkcite Avatar"}', @view).must_equal('<img alt="Inkcite Avatar" border=0 height=73 src="images/inkcite.jpg" style="color:#cccccc;display:block;font-size:11px" width=73>')
59
58
  end
60
59
 
61
60
  it 'has configurable font size' do
62
- Inkcite::Renderer.render('{img src=inkcite.jpg height=73 width=73 font-size=18 alt="Inkcite Avatar"}', @view).must_equal('<img alt="Inkcite Avatar" border=0 height=73 src="images/inkcite.jpg" style="color:#cccccc;display:block;font-size:18px" width=73>')
61
+ Inkcite::Renderer.render('{img src=inkcite.jpg height=73 width=73 font-size=18 alt="Inkcite Avatar"}', @view).must_equal('<img alt="Inkcite Avatar" border=0 height=73 src="images/inkcite.jpg" style="display:block;font-size:18px" width=73>')
62
+ end
63
+
64
+ it 'supports font-size override' do
65
+ Inkcite::Renderer.render('{img src=inkcite.jpg height=73 width=73 font="small" font-size=18 alt="Inkcite Avatar"}', @view).must_equal('<img alt="Inkcite Avatar" border=0 height=73 src="images/inkcite.jpg" style="color:#cccccc;display:block;font-size:18px" width=73>')
63
66
  end
64
67
 
65
68
  it 'ignores font attributes when alt text is not present' do
@@ -88,11 +91,24 @@ describe Inkcite::Renderer::Image do
88
91
  end
89
92
 
90
93
  it 'supports multi-line alt text' do
91
- Inkcite::Renderer.render(%Q({img src=inkcite.jpg height=150 width=100 font=none alt="Multiple\nLine\nAlt\nText"}), @view).must_equal(%Q(<img alt="Multiple\nLine\nAlt\nText" border=0 height=150 src="images/inkcite.jpg" style="display:block;white-space:pre" width=100>))
94
+ Inkcite::Renderer.render(%Q({img src=inkcite.jpg height=150 width=100 font=none alt="Multiple\nLine\nAlt\nText"}), @view).must_equal(%Q(<img alt="Multiple \nLine \nAlt \nText" border=0 height=150 src="images/inkcite.jpg" style="display:block;white-space:pre" width=100>))
95
+ end
96
+
97
+ it 'supports virtual (\n) multi-line alt text' do
98
+ Inkcite::Renderer.render(%q({img src=inkcite.jpg height=150 width=100 font=none alt="Multiple\nLine\nAlt\nText"}), @view).must_equal(%Q(<img alt="Multiple \nLine \nAlt \nText" border=0 height=150 src="images/inkcite.jpg" style="display:block;white-space:pre" width=100>))
92
99
  end
93
100
 
94
101
  it 'supports multi-line alt text in production, too' do
95
- Inkcite::Renderer.render(%Q({img src=inkcite.jpg height=150 width=100 font=none alt="Multiple\nLine\nAlt\nText"}), Inkcite::Email.new('test/project/').view(:production, :email)).must_equal(%Q(<img alt="Multiple\nLine\nAlt\nText" border=0 height=150 src="http://production.imagehost.com/emails/myemail/inkcite.jpg" style="display:block;white-space:pre" width=100>))
102
+ Inkcite::Renderer.render(%Q({img src=inkcite.jpg height=150 width=100 font=none alt="Multiple\nLine\nAlt\nText"}), Inkcite::Email.new('test/project/').view(:production, :email)).must_equal(%Q(<img alt="Multiple \nLine \nAlt \nText" border=0 height=150 src="http://production.imagehost.com/emails/myemail/inkcite.jpg" style="display:block;white-space:pre" width=100>))
103
+ Inkcite::Renderer.render(%q({img src=inkcite.jpg height=150 width=100 font=none alt="Multiple\nLine\nAlt\nText"}), Inkcite::Email.new('test/project/').view(:production, :email)).must_equal(%Q(<img alt="Multiple \nLine \nAlt \nText" border=0 height=150 src="http://production.imagehost.com/emails/myemail/inkcite.jpg" style="display:block;white-space:pre" width=100>))
104
+ end
105
+
106
+ it 'removes HTML from alt text' do
107
+ Inkcite::Renderer.render(%q({img src=inkcite.jpg height=150 width=100 alt="HTML <i>is not</i> allowed in alt text"}), @view).must_equal(%q(<img alt="HTML is not allowed in alt text" border=0 height=150 src="images/inkcite.jpg" style="display:block" width=100>))
108
+ end
109
+
110
+ it 'can show a different image in Outlook' do
111
+ Inkcite::Renderer.render(%q({img src=animated.gif outlook-src=static.jpg height=150 width=100 alt="Don't repeat yourself"}), @view).must_equal(%q(<!--[if mso]><img alt="Don't repeat yourself" border=0 height=150 src="images/static.jpg" style="display:block" width=100><![endif]--><!--[if !mso]><!-- --><img alt="Don't repeat yourself" border=0 height=150 src="images/animated.gif" style="display:block" width=100><!--<![endif]-->))
96
112
  end
97
113
 
98
114
  end
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::Link do
6
2
 
7
3
  before do
@@ -89,4 +85,18 @@ describe Inkcite::Renderer::Link do
89
85
  Inkcite::Renderer.render('{a id="order-now" href="http://inkceptional.com" mobile="button"}Order Now{/a}', @view).must_equal('<div><a class="button" href="http://inkceptional.com" style="color:#0099cc;text-decoration:none" target=_blank>Order Now</a></div>')
90
86
  end
91
87
 
88
+ it 'detects invalid URLs' do
89
+ Inkcite::Renderer.render(%Q({a id="oops" href="http://ink\nceptional.com"}), @view)
90
+ @view.errors.must_include(%Q(Link href appears to be invalid (line 0) [id=oops, href=http://ink\nceptional.com]))
91
+ end
92
+
93
+ it 'accepts invalid URLs if forced' do
94
+ Inkcite::Renderer.render(%Q({a id="oops" href="http://ink\nceptional.com" force}), @view)
95
+ @view.errors.must_be_nil
96
+ end
97
+
98
+ it 'supports the block attribute' do
99
+ Inkcite::Renderer.render(%Q({a id="order-now" href="http://inkceptional.com" block}), @view).must_equal(%Q(<a href="http://inkceptional.com" style="color:#0099cc;display:block;text-decoration:none" target=_blank>))
100
+ end
101
+
92
102
  end
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::Lorem do
6
2
 
7
3
  before do
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::MobileImage do
6
2
 
7
3
  before do
@@ -9,19 +5,15 @@ describe Inkcite::Renderer::MobileImage do
9
5
  end
10
6
 
11
7
  it 'styles a span to show an image only on mobile' do
12
- Inkcite::Renderer.render('{mobile-img src=inkcite-mobile.jpg height=100 width=300}{/mobile-img}', @view).must_equal('<span class="i01 img"></span>')
8
+ Inkcite::Renderer.render('{mobile-img src=inkcite-mobile.jpg height=100 width=300}', @view).must_equal('<span class="i01 img"></span>')
13
9
  @view.media_query.find_by_klass('i01').to_css.must_equal('span[class~="i01"] { background-image:url("images/inkcite-mobile.jpg");height:100px;width:300px }')
14
10
  @view.media_query.find_by_klass('img').to_css.must_equal('span[class~="img"] { display: block; background-position: center; background-size: cover; }')
15
11
  end
16
12
 
17
13
  it 'substitutes a placeholder for a missing image of sufficient size' do
18
14
  @view.config[Inkcite::Email::IMAGE_PLACEHOLDERS] = true
19
- Inkcite::Renderer.render('{mobile-img src=inkcite-mobile.jpg height=100 width=300}{/mobile-img}', @view).must_equal('<span class="i01 img"></span>')
20
- @view.media_query.find_by_klass('i01').to_css.must_equal('span[class~="i01"] { background-image:url("//placeholdit.imgix.net/~text?fm=jpg&h=100&txt=inkcite-mobile.jpg%0A%28300%C3%97100%29&txtsize=18&txttrack=0&w=300");height:100px;width:300px }')
21
- end
22
-
23
- it 'hides any images it wraps' do
24
- Inkcite::Renderer.render('{mobile-img src=inkcite-mobile.jpg height=100 width=300}{img src=inkcite.jpg height=50 width=100}{/mobile-img}', @view).must_equal('<span class="i01 img"><img border=0 class="hide" height=50 src="images/inkcite.jpg" style="display:block" width=100></span>')
15
+ Inkcite::Renderer.render('{mobile-img src=inkcite-mobile.jpg height=100 width=300}', @view).must_equal('<span class="i01 img"></span>')
16
+ @view.media_query.find_by_klass('i01').to_css.must_equal('span[class~="i01"] { background-image:url("http://placeholdit.imgix.net/~text?fm=jpg&h=100&txt=inkcite-mobile.jpg%0A%28300%C3%97100%29&txtsize=18&txttrack=0&w=300");height:100px;width:300px }')
25
17
  end
26
18
 
27
19
  end
@@ -0,0 +1,21 @@
1
+ describe Inkcite::Renderer::MobileOnly do
2
+
3
+ before do
4
+ @view = Inkcite::Email.new('test/project/').view(:development, :email)
5
+ end
6
+
7
+ it 'styles a div to show content only on mobile' do
8
+ Inkcite::Renderer.render('{mobile-only}I will only appear on mobile{/mobile-only}', @view).must_equal('<!--[if !mso 9]><!--><div class="show" style="display:none;max-height:0;overflow:hidden">I will only appear on mobile</div><!--<![endif]-->')
9
+ @view.media_query.find_by_klass('show').declarations.must_match('display: block !important; max-height: none !important;')
10
+ end
11
+
12
+ it 'supports inline as a boolean attribute' do
13
+ Inkcite::Renderer.render('800-555-1212{mobile-only inline}&nbsp;&raquo;{/mobile-only}', @view).must_equal('800-555-1212<!--[if !mso 9]><!--><div class="show-inline" style="display:none;max-height:0;overflow:hidden">&nbsp;&raquo;</div><!--<![endif]-->')
14
+ @view.media_query.find_by_klass('show-inline').declarations.must_match('display: inline !important; max-height: none !important;')
15
+ end
16
+
17
+ it 'does not support fonts or other container attributes' do
18
+ Inkcite::Renderer.render('{mobile-only font=large}Fonts not supported{/mobile-only}', @view).must_equal('<!--[if !mso 9]><!--><div class="show" style="display:none;max-height:0;overflow:hidden">Fonts not supported</div><!--<![endif]-->')
19
+ end
20
+
21
+ end
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::MobileStyle do
6
2
 
7
3
  before do
@@ -26,7 +22,7 @@ describe Inkcite::Renderer::MobileStyle do
26
22
 
27
23
  it 'adds an inactive responsive style to the context' do
28
24
  Inkcite::Renderer.render('{mobile-style name="outlined" style="border: 1px solid #f00"}', @view).must_equal('')
29
- rule = @view.media_query.find_by_klass('outlined').to_css.must_equal('[class~="outlined"] { border: 1px solid #f00 }')
25
+ @view.media_query.find_by_klass('outlined').to_css.must_equal('[class~="outlined"] { border: 1px solid #f00 }')
30
26
  end
31
27
 
32
28
  it 'can be applied to a responsive element' do
@@ -0,0 +1,61 @@
1
+ describe Inkcite::Renderer::OutlookBackground do
2
+
3
+ before do
4
+ @view = Inkcite::Email.new('test/project/').view(:development, :email)
5
+ end
6
+
7
+ it 'warns when an image is missing' do
8
+ Inkcite::Renderer.render('{outlook-bg src=missing.jpg}', @view)
9
+ @view.errors.must_include('Missing image (line 0) [src=missing.jpg]')
10
+ end
11
+
12
+ it 'defaults to filling the available horizontal space' do
13
+ Inkcite::Renderer.render('{outlook-bg src=https://i.imgur.com/YJOX1PC.png}{/outlook-bg}', @view).must_equal('<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="mso-width-percent:1000" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0" style="mso-fit-shape-to-text:true"><div><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->')
14
+ end
15
+
16
+ it 'supports 100% width' do
17
+ Inkcite::Renderer.render('{outlook-bg src=https://i.imgur.com/YJOX1PC.png width=100%}{/outlook-bg}', @view).must_equal('<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="mso-width-percent:1000" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0" style="mso-fit-shape-to-text:true"><div><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->')
18
+ end
19
+
20
+ it 'supports fill width' do
21
+ Inkcite::Renderer.render('{outlook-bg src=https://i.imgur.com/YJOX1PC.png width=fill}{/outlook-bg}', @view).must_equal('<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="mso-width-percent:1000" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0" style="mso-fit-shape-to-text:true"><div><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->')
22
+ end
23
+
24
+ it 'supports an optional width in pixels' do
25
+ Inkcite::Renderer.render('{outlook-bg src=https://i.imgur.com/YJOX1PC.png width=120}{/outlook-bg}', @view).must_equal('<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="width:120px" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0" style="mso-fit-shape-to-text:true"><div><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->')
26
+ end
27
+
28
+ it 'supports an optional height in pixels' do
29
+ Inkcite::Renderer.render('{outlook-bg src=https://i.imgur.com/YJOX1PC.png bgcolor=#7bceeb height=92 width=120}{/outlook-bg}', @view).must_equal('<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="height:92px;width:120px" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill color="#7bceeb" src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0"><div><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->')
30
+ end
31
+
32
+
33
+ it 'supports an optional background color' do
34
+ Inkcite::Renderer.render('{outlook-bg src=https://i.imgur.com/YJOX1PC.png bgcolor=#7bceeb width=120}{/outlook-bg}', @view).must_equal('<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="width:120px" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill color="#7bceeb" src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0" style="mso-fit-shape-to-text:true"><div><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->')
35
+ end
36
+
37
+ it 'is automatically injected by the td helper' do
38
+ Inkcite::Renderer.render('{td background=https://i.imgur.com/YJOX1PC.png bgcolor=#7bceeb width=120 outlook-bg}{/td}', @view).must_equal(%Q(<td bgcolor=#7bceeb style="background:#7bceeb url(https://i.imgur.com/YJOX1PC.png)" width=120>\n<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="width:120px" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill color="#7bceeb" src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0" style="mso-fit-shape-to-text:true"><div><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->\n</td>))
39
+ end
40
+
41
+ it 'defaults to fill when injected by a td helper sans dimensions' do
42
+ Inkcite::Renderer.render('{td background=https://i.imgur.com/YJOX1PC.png bgcolor=#7bceeb outlook-bg}{/td}', @view).must_equal(%Q(<td bgcolor=#7bceeb style="background:#7bceeb url(https://i.imgur.com/YJOX1PC.png)">\n<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="mso-width-percent:1000" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill color="#7bceeb" src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0" style="mso-fit-shape-to-text:true"><div><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->\n</td>))
43
+ end
44
+
45
+ it 'inherits height from the parent td if present' do
46
+ Inkcite::Renderer.render('{td background=https://i.imgur.com/YJOX1PC.png bgcolor=#7bceeb height=92 width=120 outlook-bg}{/td}', @view).must_equal(%Q(<td bgcolor=#7bceeb height=92 style="background:#7bceeb url(https://i.imgur.com/YJOX1PC.png)" width=120>\n<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="height:92px;width:120px" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill color="#7bceeb" src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0"><div><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->\n</td>))
47
+ end
48
+
49
+ it 'is ignored by the td helper if background is missing' do
50
+ Inkcite::Renderer.render('{td bgcolor=#7bceeb outlook-bg}{/td}', @view).must_equal(%Q(<td bgcolor=#7bceeb></td>))
51
+ end
52
+
53
+ it 'supports the font attribute' do
54
+ Inkcite::Renderer.render('{outlook-bg src=https://i.imgur.com/YJOX1PC.png font=large}{/outlook-bg}', @view).must_equal('<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="mso-width-percent:1000" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0" style="mso-fit-shape-to-text:true"><div style="color:#ff0000;font-family:serif;font-size:24px;font-weight:bold;line-height:24px"><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->')
55
+ end
56
+
57
+ it 'supports font-related attributes' do
58
+ Inkcite::Renderer.render('{outlook-bg src=https://i.imgur.com/YJOX1PC.png font-size=18 line-height=27}{/outlook-bg}', @view).must_equal('<!--[if gte mso 9]><v:rect fill="true" stroke="false" style="mso-width-percent:1000" xmlns:v="urn:schemas-microsoft-com:vml"><v:fill src="https://i.imgur.com/YJOX1PC.png" type="tile" /><v:textbox inset="0,0,0,0" style="mso-fit-shape-to-text:true"><div style="font-size:18px;line-height:27px"><![endif]--><!--[if gte mso 9]></div></v:textbox></v:rect><![endif]-->')
59
+ end
60
+
61
+ end
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::Redacted do
6
2
 
7
3
  before do
@@ -0,0 +1,53 @@
1
+ describe Inkcite::Renderer::Social do
2
+
3
+ before do
4
+ @email = Inkcite::Email.new('test/project/')
5
+ @view = @email.view(:development, :email)
6
+ end
7
+
8
+ it 'supports the noicon attribute' do
9
+
10
+ # Need to delete the image if it exists because tests can run
11
+ # in non-linear order
12
+ twitter_icon = @email.image_path('twitter.png')
13
+ File.delete(twitter_icon) if File.exist?(twitter_icon)
14
+ Inkcite::Renderer.render('{twitter noicon href="http://inkcite.readme.io" text="Inkcite #MakeEmailBetter"}', @view).must_equal('<a href="https://twitter.com/share?url=http://inkcite.readme.io&text=Inkcite%20%23MakeEmailBetter" style="color:#0099cc;text-decoration:none" target=_blank>Tweet</a>')
15
+ File.exist?(@view.email.image_path('twitter.png')).must_equal(false)
16
+ end
17
+
18
+ it 'supports sharing on Twitter' do
19
+ Inkcite::Renderer.render('{twitter href="http://inkcite.readme.io" text="Inkcite #MakeEmailBetter"}', @view).must_equal('<a href="https://twitter.com/share?url=http://inkcite.readme.io&text=Inkcite%20%23MakeEmailBetter" style="color:#0099cc;font-size:15px;line-height:15px;text-decoration:none" target=_blank><img align=absmiddle alt="Twitter" border=0 height=15 src="images/twitter.png" style="display:inline;vertical-align:middle" width=19> Tweet</a>')
20
+ end
21
+
22
+ it 'copies the social sharing icons into the project' do
23
+ Inkcite::Renderer.render('{facebook href="http://inkcite.readme.io" text="Inkcite #MakeEmailBetter"}', @view)
24
+ File.exist?(@view.email.image_path('facebook.png')).must_equal(true)
25
+ end
26
+
27
+ it 'supports a configurable icon size' do
28
+ Inkcite::Renderer.render('{twitter size=11 href="http://inkcite.readme.io" text="Inkcite #MakeEmailBetter"}', @view).must_equal('<a href="https://twitter.com/share?url=http://inkcite.readme.io&text=Inkcite%20%23MakeEmailBetter" style="color:#0099cc;font-size:11px;line-height:11px;text-decoration:none" target=_blank><img align=absmiddle alt="Twitter" border=0 height=11 src="images/twitter.png" style="display:inline;vertical-align:middle" width=14> Tweet</a>')
29
+ end
30
+
31
+ it 'supports sharing on Facebook' do
32
+ Inkcite::Renderer.render('{facebook href="http://inkcite.readme.io" text="Inkcite #MakeEmailBetter"}', @view).must_equal('<a href="https://www.facebook.com/sharer/sharer.php?u=http://inkcite.readme.io&t=Inkcite%20%23MakeEmailBetter" style="color:#0099cc;font-size:15px;line-height:15px;text-decoration:none" target=_blank><img align=absmiddle alt="Facebook" border=0 height=15 src="images/facebook.png" style="display:inline;vertical-align:middle" width=15> Share</a>')
33
+ end
34
+
35
+ it 'supports sharing on Pintrest' do
36
+ Inkcite::Renderer.render('{pintrest href="http://inkcite.readme.io" text="Inkcite #MakeEmailBetter" media="http://c1.staticflickr.com/9/8683/16620137238_71e78abd1d_n.jpg"}', @view).must_equal('<a href="https://www.pinterest.com/pin/create/button/?url=http://inkcite.readme.io&media=http://c1.staticflickr.com/9/8683/16620137238_71e78abd1d_n.jpg&description=Inkcite%20%23MakeEmailBetter" style="color:#CB2027;font-size:15px;line-height:15px;text-decoration:none" target=_blank><img align=absmiddle alt="Pintrest" border=0 height=15 src="images/pintrest.png" style="display:inline;vertical-align:middle" width=15> Pin it</a>')
37
+ end
38
+
39
+ it 'supports the nowrap attribute' do
40
+ Inkcite::Renderer.render('{twitter href="http://inkcite.readme.io" text="Inkcite #MakeEmailBetter" nowrap}', @view).must_equal('<a href="https://twitter.com/share?url=http://inkcite.readme.io&text=Inkcite%20%23MakeEmailBetter" style="color:#0099cc;font-size:15px;line-height:15px;text-decoration:none;white-space:nowrap" target=_blank><img align=absmiddle alt="Twitter" border=0 height=15 src="images/twitter.png" style="display:inline;vertical-align:middle" width=19> Tweet</a>')
41
+ end
42
+
43
+ Minitest.after_run do
44
+ email = Inkcite::Email.new('test/project/')
45
+
46
+ %w( facebook.png pintrest.png twitter.png ).each do |img|
47
+ image_path = email.image_path(img)
48
+ File.delete(image_path) if File.exist?(image_path)
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -1,7 +1,3 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'inkcite'
4
-
5
1
  describe Inkcite::Renderer::Span do
6
2
 
7
3
  before do