auto_html-whistlerbrk 2.0.0.pre

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 (65) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +123 -0
  3. data/Rakefile +9 -0
  4. data/lib/auto_html.rb +17 -0
  5. data/lib/auto_html/auto_html_for.rb +64 -0
  6. data/lib/auto_html/base.rb +21 -0
  7. data/lib/auto_html/builder.rb +22 -0
  8. data/lib/auto_html/capistrano.rb +17 -0
  9. data/lib/auto_html/filter.rb +22 -0
  10. data/lib/auto_html/filters/dailymotion.rb +6 -0
  11. data/lib/auto_html/filters/flickr.rb +20 -0
  12. data/lib/auto_html/filters/gist.rb +8 -0
  13. data/lib/auto_html/filters/google_map.rb +19 -0
  14. data/lib/auto_html/filters/hashtag.rb +7 -0
  15. data/lib/auto_html/filters/html_escape.rb +9 -0
  16. data/lib/auto_html/filters/image.rb +16 -0
  17. data/lib/auto_html/filters/instagram.rb +10 -0
  18. data/lib/auto_html/filters/link.rb +16 -0
  19. data/lib/auto_html/filters/liveleak.rb +19 -0
  20. data/lib/auto_html/filters/metacafe.rb +13 -0
  21. data/lib/auto_html/filters/redcarpet.rb +4 -0
  22. data/lib/auto_html/filters/sanitize.rb +5 -0
  23. data/lib/auto_html/filters/simple_format.rb +12 -0
  24. data/lib/auto_html/filters/soundcloud.rb +19 -0
  25. data/lib/auto_html/filters/ted.rb +13 -0
  26. data/lib/auto_html/filters/twitter.rb +19 -0
  27. data/lib/auto_html/filters/vimeo.rb +15 -0
  28. data/lib/auto_html/filters/worldstar.rb +8 -0
  29. data/lib/auto_html/filters/youtube.rb +19 -0
  30. data/lib/auto_html/filters/youtube_image.rb +17 -0
  31. data/lib/auto_html/filters/youtube_js_api.rb +6 -0
  32. data/lib/auto_html/railtie.rb +10 -0
  33. data/lib/auto_html/rake_tasks.rb +27 -0
  34. data/lib/auto_html/task.rb +9 -0
  35. data/test/fixture_setup.rb +13 -0
  36. data/test/fixtures/database.yml +5 -0
  37. data/test/fixtures/schema.rb +20 -0
  38. data/test/functional/auto_html_for_options_test.rb +26 -0
  39. data/test/functional/auto_html_for_test.rb +56 -0
  40. data/test/functional/filter_test.rb +27 -0
  41. data/test/test_helper.rb +16 -0
  42. data/test/unit/auto_html_test.rb +37 -0
  43. data/test/unit/filters/dailymotion_test.rb +34 -0
  44. data/test/unit/filters/gist_test.rb +15 -0
  45. data/test/unit/filters/google_map_test.rb +24 -0
  46. data/test/unit/filters/hashtag_test.rb +25 -0
  47. data/test/unit/filters/html_escape_test.rb +15 -0
  48. data/test/unit/filters/image_test.rb +77 -0
  49. data/test/unit/filters/instagram_test.rb +35 -0
  50. data/test/unit/filters/link_test.rb +55 -0
  51. data/test/unit/filters/liveleak_test.rb +17 -0
  52. data/test/unit/filters/metacafe_test.rb +29 -0
  53. data/test/unit/filters/redcarpet_test.rb +38 -0
  54. data/test/unit/filters/sanitize_test.rb +36 -0
  55. data/test/unit/filters/simple_format_test.rb +15 -0
  56. data/test/unit/filters/soundcloud_test.rb +52 -0
  57. data/test/unit/filters/ted_test.rb +18 -0
  58. data/test/unit/filters/twitter_test.rb +45 -0
  59. data/test/unit/filters/vimeo_test.rb +64 -0
  60. data/test/unit/filters/worldstar_test.rb +27 -0
  61. data/test/unit/filters/youtube_image_test.rb +59 -0
  62. data/test/unit/filters/youtube_js_api_test.rb +30 -0
  63. data/test/unit/filters/youtube_test.rb +73 -0
  64. data/test/unit/unit_test_helper.rb +3 -0
  65. metadata +134 -0
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class TedTest < Minitest::Test
4
+ def test_transform_url_with_www
5
+ output = auto_html('http://www.ted.com/talks/amy_cuddy_your_body_language_shapes_who_you_are.html') { ted }
6
+ assert_equal '<iframe width="640" height="360" frameborder="0" scrolling="no" src="http://embed.ted.com/talks/amy_cuddy_your_body_language_shapes_who_you_are.html"></iframe>', output
7
+ end
8
+
9
+ def test_transform_url_without_www
10
+ output = auto_html('http://ted.com/talks/amy_cuddy_your_body_language_shapes_who_you_are.html') { ted }
11
+ assert_equal '<iframe width="640" height="360" frameborder="0" scrolling="no" src="http://embed.ted.com/talks/amy_cuddy_your_body_language_shapes_who_you_are.html"></iframe>', output
12
+ end
13
+
14
+ def test_transform_url_with_options
15
+ result = auto_html('http://www.ted.com/talks/amy_cuddy_your_body_language_shapes_who_you_are.html') { ted(:width => '50%', :height => '100', :scrolling => 'yes', :frameborder => 1, :allow_full_screen => true) }
16
+ assert_equal '<iframe width="50%" height="100" frameborder="1" scrolling="yes" src="http://embed.ted.com/talks/amy_cuddy_your_body_language_shapes_who_you_are.html" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>', result
17
+ end
18
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+ require 'fakeweb'
3
+
4
+ class TwitterTest < Minitest::Test
5
+
6
+ def setup
7
+ response = %Q(
8
+ {
9
+ "author_name": "Dan Martell",
10
+ "author_url": "https://twitter.com/danmartell",
11
+ "cache_age": "3153600000",
12
+ "height": null,
13
+ "html": "things",
14
+ "provider_name": "Twitter",
15
+ "provider_url": "https://twitter.com",
16
+ "type": "rich",
17
+ "url": "https://twitter.com/danmartell/statuses/279651488517738496",
18
+ "version": "1.0",
19
+ "width": 550
20
+ })
21
+
22
+ FakeWeb.register_uri(:get, %r|https://api\.twitter\.com/1/statuses/oembed\.json|, :body => response)
23
+ end
24
+
25
+ def test_transform
26
+ transformed_html = "things"
27
+ result = auto_html('https://twitter.com/danmartell/statuses/279651488517738496') { twitter }
28
+ assert_equal transformed_html, result
29
+ end
30
+
31
+ def test_transform_with_dangling_slash
32
+ transformed_html = "things"
33
+ result = auto_html('https://twitter.com/danmartell/statuses/279651488517738496/') { twitter }
34
+ assert_equal transformed_html, result
35
+ end
36
+
37
+ def test_dont_transform_a_regular_link_to_twitter
38
+ transformed_html = %Q(<blockquote class="twitter-tweet"><p>Stop saying you can&#39;t! Start asking &quot;What would need to be true for me to accomplish this&quot; - it&#39;ll change your life. <a href="https://twitter.com/search?q=%23focus&amp;src=hash">#focus</a> <a href="https://twitter.com/search?q=%23solutions&amp;src=hash">#solutions</a></p>&mdash; Dan Martell (@danmartell) <a href="https://twitter.com/danmartell/statuses/279651488517738496">December 14, 2012</a></blockquote>
39
+ <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>)
40
+ result = auto_html(transformed_html) { twitter }
41
+
42
+ assert_equal transformed_html, result
43
+ end
44
+
45
+ end
@@ -0,0 +1,64 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class VimeoTest < Minitest::Test
4
+
5
+ DIV_START = '<div class="video-container vimeo">'
6
+
7
+ def test_transform_url_with_www
8
+ result = auto_html('http://www.vimeo.com/3300155') { vimeo }
9
+ assert_equal %Q|#{DIV_START}<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe></div>|, result
10
+ end
11
+
12
+ def test_transform_url_without_www
13
+ result = auto_html('http://vimeo.com/3300155') { vimeo }
14
+ assert_equal %Q|#{DIV_START}<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe></div>|, result
15
+ end
16
+
17
+ def test_transform_url_with_params
18
+ result = auto_html('http://vimeo.com/3300155?pg=embed&sec=') { vimeo }
19
+ assert_equal %Q|#{DIV_START}<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe></div>|, result
20
+ end
21
+
22
+ def test_transform_url_with_anchor
23
+ result = auto_html('http://vimeo.com/3300155#skirt') { vimeo }
24
+ assert_equal %Q|#{DIV_START}<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe></div>|, result
25
+ end
26
+
27
+ def test_transform_with_options
28
+ result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250) }
29
+ assert_equal %Q|#{DIV_START}<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="300" height="250" frameborder="0"></iframe></div>|, result
30
+ end
31
+
32
+ def test_transform_with_title
33
+ result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_title => true) }
34
+ assert_equal %Q|#{DIV_START}<iframe src="//player.vimeo.com/video/3300155?byline=0&portrait=0" width="300" height="250" frameborder="0"></iframe></div>|, result
35
+ end
36
+
37
+ def test_transform_with_byline
38
+ result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_byline => true) }
39
+ assert_equal %Q|#{DIV_START}<iframe src="//player.vimeo.com/video/3300155?title=0&portrait=0" width="300" height="250" frameborder="0"></iframe></div>|, result
40
+ end
41
+
42
+ def test_transform_with_portrait
43
+ result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_portrait => true) }
44
+ assert_equal %Q|#{DIV_START}<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0" width="300" height="250" frameborder="0"></iframe></div>|, result
45
+ end
46
+
47
+ def test_transform_url_with_https
48
+ result = auto_html('https://vimeo.com/3300155') { vimeo }
49
+ assert_equal %Q|#{DIV_START}<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe></div>|, result
50
+ end
51
+
52
+ def test_prevent_html_transform
53
+ str = '<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>'
54
+
55
+ result = auto_html(str) { vimeo }
56
+
57
+ assert_equal(
58
+ str, result,
59
+ "Should not re-transform HTML with Vimeo links inside of it"
60
+ )
61
+ end
62
+
63
+
64
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class WorldstarTest < Minitest::Test
4
+
5
+ DIV_START = '<div class="video-container worldstar">'
6
+
7
+ def test_transform
8
+ result = auto_html('http://www.worldstarhiphop.com/videos/video.php?v=wshhc29WLkx550Hv9o31') { worldstar }
9
+ assert_equal %Q|#{DIV_START}<object width="448" height="374"><param name="movie" value="http://www.worldstarhiphop.com/videos/e/16711680/wshhc29WLkx550Hv9o31"><param name="allowFullScreen" value="true"></param><embed src="http://www.worldstarhiphop.com/videos/e/16711680/wshhc29WLkx550Hv9o31" type="application/x-shockwave-flash" allowFullscreen="true" width="448" height="374"></embed></object></div>|, result
10
+ end
11
+
12
+ def test_transform_with_options
13
+ result = auto_html('http://www.worldstarhiphop.com/videos/video.php?v=wshhc29WLkx550Hv9o31') { worldstar(:width => 400, :height => 250)}
14
+ assert_equal %Q|#{DIV_START}<object width="400" height="250"><param name="movie" value="http://www.worldstarhiphop.com/videos/e/16711680/wshhc29WLkx550Hv9o31"><param name="allowFullScreen" value="true"></param><embed src="http://www.worldstarhiphop.com/videos/e/16711680/wshhc29WLkx550Hv9o31" type="application/x-shockwave-flash" allowFullscreen="true" width="400" height="250"></embed></object></div>|, result
15
+ end
16
+
17
+ def test_prevent_html_transform
18
+ str = '<object width="400" height="250"><param name="movie" value="http://www.worldstarhiphop.com/videos/e/16711680/wshhc29WLkx550Hv9o31"><param name="allowFullScreen" value="true"></param><embed src="http://www.worldstarhiphop.com/videos/e/16711680/wshhc29WLkx550Hv9o31" type="application/x-shockwave-flash" allowFullscreen="true" width="400" height="250"></embed></object>'
19
+
20
+ result = auto_html(str) { vimeo }
21
+
22
+ assert_equal(
23
+ str, result,
24
+ "Should not re-transform HTML with WorldStar links inside of it"
25
+ )
26
+ end
27
+ end
@@ -0,0 +1,59 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class YouTubeImageTest < Minitest::Test
4
+
5
+ def test_transform
6
+ result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o') { youtube_image }
7
+ assert_equal '<div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=BwNrmYRiX_o" target="_blank"><img src="//img.youtube.com/vi/BwNrmYRiX_o/mqdefault.jpg" width="320" height="315" border="0"></a></div>', result
8
+ end
9
+
10
+ def test_transform2
11
+ result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o&eurl=http%3A%2F%2Fvukajlija.com%2Fvideo%2Fklipovi%3Fstrana%3D6&feature=player_embedded') { youtube_image }
12
+ assert_equal '<div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=BwNrmYRiX_o" target="_blank"><img src="//img.youtube.com/vi/BwNrmYRiX_o/mqdefault.jpg" width="320" height="315" border="0"></a></div>', result
13
+ end
14
+
15
+ def test_transform3
16
+ result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o&feature=related') { youtube_image }
17
+ assert_equal '<div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=BwNrmYRiX_o" target="_blank"><img src="//img.youtube.com/vi/BwNrmYRiX_o/mqdefault.jpg" width="320" height="315" border="0"></a></div>', result
18
+ end
19
+
20
+ def test_transform3
21
+ result = auto_html('foo http://www.youtube.com/watch?v=fT1ahr81HLw bar') { youtube_image }
22
+ assert_equal 'foo <div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=fT1ahr81HLw" target="_blank"><img src="//img.youtube.com/vi/fT1ahr81HLw/mqdefault.jpg" width="320" height="315" border="0"></a></div> bar', result
23
+ end
24
+
25
+ def test_transform4
26
+ result = auto_html('foo http://www.youtube.com/watch?v=fT1ahr81HLw<br>bar') { youtube_image }
27
+ assert_equal 'foo <div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=fT1ahr81HLw" target="_blank"><img src="//img.youtube.com/vi/fT1ahr81HLw/mqdefault.jpg" width="320" height="315" border="0"></a></div><br>bar', result
28
+ end
29
+
30
+ def test_transform_url_without_www
31
+ result = auto_html('http://youtube.com/watch?v=BwNrmYRiX_o') { youtube_image }
32
+ assert_equal '<div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=BwNrmYRiX_o" target="_blank"><img src="//img.youtube.com/vi/BwNrmYRiX_o/mqdefault.jpg" width="320" height="315" border="0"></a></div>', result
33
+ end
34
+
35
+ def test_transform_with_options
36
+ result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o') { youtube_image(:width => 300, :height => 255, :style => 'high', :target => 'self', :border => 1) }
37
+ assert_equal '<div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=BwNrmYRiX_o" target="_self"><img src="//img.youtube.com/vi/BwNrmYRiX_o/hqdefault.jpg" width="300" height="255" border="1"></a></div>', result
38
+ end
39
+
40
+ def test_transform_with_short_url
41
+ result = auto_html('http://www.youtu.be/BwNrmYRiX_o') { youtube_image }
42
+ assert_equal '<div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=BwNrmYRiX_o" target="_blank"><img src="//img.youtube.com/vi/BwNrmYRiX_o/mqdefault.jpg" width="320" height="315" border="0"></a></div>', result
43
+ end
44
+
45
+ def test_transform_https
46
+ result = auto_html("https://www.youtube.com/watch?v=t7NdBIA4zJg") { youtube_image }
47
+ assert_equal '<div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=t7NdBIA4zJg" target="_blank"><img src="//img.youtube.com/vi/t7NdBIA4zJg/mqdefault.jpg" width="320" height="315" border="0"></a></div>', result
48
+ end
49
+
50
+ def test_short_with_params
51
+ result = auto_html("http://youtu.be/t7NdBIA4zJg?t=1s&hd=1") { youtube_image }
52
+ assert_equal '<div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=t7NdBIA4zJg" target="_blank"><img src="//img.youtube.com/vi/t7NdBIA4zJg/mqdefault.jpg" width="320" height="315" border="0"></a></div>', result
53
+ end
54
+
55
+ def test_transform_without_protocol
56
+ result = auto_html("www.youtube.com/watch?v=t7NdBIA4zJg") { youtube_image }
57
+ assert_equal '<div class="thumbnail youtube"><a href="https://www.youtube.com/watch?v=t7NdBIA4zJg" target="_blank"><img src="//img.youtube.com/vi/t7NdBIA4zJg/mqdefault.jpg" width="320" height="315" border="0"></a></div>', result
58
+ end
59
+ end
@@ -0,0 +1,30 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class YouTubeJsApiTest < Minitest::Test
4
+
5
+ def test_transform
6
+ result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o') { youtube_js_api }
7
+ assert_equal '<object width="390" height="250"><param name="movie" value="//www.youtube.com/v/BwNrmYRiX_o?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="//www.youtube.com/v/BwNrmYRiX_o?enablejsapi=1&playerapiid=ytplayer" type="application/x-shockwave-flash" wmode="transparent" width="390" height="250" allowscriptaccess="always"></embed></object>', result
8
+ end
9
+
10
+ def test_transform2
11
+ result = auto_html('http://www.youtube.com/watch?v=3-ewi9saKg8&eurl=http%3A%2F%2Fvukajlija.com%2Fvideo%2Fklipovi%3Fstrana%3D6&feature=player_embedded') { youtube_js_api }
12
+ assert_equal '<object width="390" height="250"><param name="movie" value="//www.youtube.com/v/3-ewi9saKg8?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="//www.youtube.com/v/3-ewi9saKg8?enablejsapi=1&playerapiid=ytplayer" type="application/x-shockwave-flash" wmode="transparent" width="390" height="250" allowscriptaccess="always"></embed></object>', result
13
+ end
14
+
15
+ def test_transform3
16
+ result = auto_html('http://www.youtube.com/watch?v=Mw8KJ29qph0&feature=related') { youtube_js_api }
17
+ assert_equal '<object width="390" height="250"><param name="movie" value="//www.youtube.com/v/Mw8KJ29qph0?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="//www.youtube.com/v/Mw8KJ29qph0?enablejsapi=1&playerapiid=ytplayer" type="application/x-shockwave-flash" wmode="transparent" width="390" height="250" allowscriptaccess="always"></embed></object>', result
18
+ end
19
+
20
+ def test_transform_url_without_www
21
+ result = auto_html('http://youtube.com/watch?v=BwNrmYRiX_o') { youtube_js_api }
22
+ assert_equal '<object width="390" height="250"><param name="movie" value="//www.youtube.com/v/BwNrmYRiX_o?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="//www.youtube.com/v/BwNrmYRiX_o?enablejsapi=1&playerapiid=ytplayer" type="application/x-shockwave-flash" wmode="transparent" width="390" height="250" allowscriptaccess="always"></embed></object>', result
23
+ end
24
+
25
+ def test_transform_with_options
26
+ result = auto_html('http://www.youtube.com/watch?v=ZA1NoOOoaNw') { youtube_js_api(:width => 300, :height => 250) }
27
+ assert_equal '<object width="300" height="250"><param name="movie" value="//www.youtube.com/v/ZA1NoOOoaNw?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="//www.youtube.com/v/ZA1NoOOoaNw?enablejsapi=1&playerapiid=ytplayer" type="application/x-shockwave-flash" wmode="transparent" width="300" height="250" allowscriptaccess="always"></embed></object>', result
28
+ end
29
+
30
+ end
@@ -0,0 +1,73 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class YouTubeTest < Minitest::Test
4
+
5
+ DIV_START = '<div class="video-container youtube">'
6
+
7
+ def test_transform
8
+ result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o') { youtube }
9
+ assert_equal %Q|#{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></div>|, result
10
+ end
11
+
12
+ def test_transform2
13
+ result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o&eurl=http%3A%2F%2Fvukajlija.com%2Fvideo%2Fklipovi%3Fstrana%3D6&feature=player_embedded') { youtube }
14
+ assert_equal %Q|#{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></div>|, result
15
+ end
16
+
17
+ def test_transform3
18
+ result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o&feature=related') { youtube }
19
+ assert_equal %Q|#{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></div>|, result
20
+ end
21
+
22
+ def test_transform3
23
+ result = auto_html('foo http://www.youtube.com/watch?v=fT1ahr81HLw bar') { youtube }
24
+ assert_equal %Q|foo #{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen></iframe></div> bar|, result
25
+ end
26
+
27
+ def test_transform4
28
+ result = auto_html('foo http://www.youtube.com/watch?v=fT1ahr81HLw<br>bar') { youtube }
29
+ assert_equal %Q|foo #{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen></iframe></div><br>bar|, result
30
+ end
31
+
32
+ def test_transform_url_without_www
33
+ result = auto_html('http://youtube.com/watch?v=BwNrmYRiX_o') { youtube }
34
+ assert_equal %Q|#{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></div>|, result
35
+ end
36
+
37
+ def test_transform_with_options
38
+ result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o') { youtube(:width => 300, :height => 255, :frameborder => 1, :wmode => 'window') }
39
+ assert_equal %Q|#{DIV_START}<iframe width="300" height="255" src="//www.youtube.com/embed/BwNrmYRiX_o?wmode=window" frameborder="1" allowfullscreen></iframe></div>|, result
40
+ end
41
+
42
+ def test_transform_with_short_url
43
+ result = auto_html('http://www.youtu.be/BwNrmYRiX_o') { youtube }
44
+ assert_equal %Q|#{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></div>|, result
45
+ end
46
+
47
+ def test_transform_https
48
+ result = auto_html("https://www.youtube.com/watch?v=t7NdBIA4zJg") { youtube }
49
+ assert_equal %Q|#{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe></div>|, result
50
+ end
51
+
52
+ def test_short_with_params
53
+ result = auto_html("http://youtu.be/t7NdBIA4zJg?t=1s&hd=1") { youtube }
54
+ assert_equal %Q|#{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe></div>|, result
55
+ end
56
+
57
+ def test_transform_without_protocol
58
+ result = auto_html("www.youtube.com/watch?v=t7NdBIA4zJg") { youtube }
59
+ assert_equal %Q|#{DIV_START}<iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe></div>|, result
60
+ end
61
+
62
+ def test_prevent_html_transform
63
+ str = '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe></div>'
64
+
65
+ result = auto_html(str) { youtube }
66
+
67
+ assert_equal(
68
+ str, result,
69
+ "Should not re-transform HTML with YouTube links inside of it"
70
+ )
71
+ end
72
+
73
+ end
@@ -0,0 +1,3 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ include AutoHtml
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auto_html-whistlerbrk
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0.pre
5
+ platform: ruby
6
+ authors:
7
+ - Dejan Simic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rinku
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: redcarpet
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.1'
41
+ description: Automatically transforms URIs (via domain) and includes the destination
42
+ resource (Vimeo, YouTube movie, image, ...) in your document
43
+ email: desimic@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - README.md
49
+ - Rakefile
50
+ - lib/auto_html.rb
51
+ - lib/auto_html/auto_html_for.rb
52
+ - lib/auto_html/base.rb
53
+ - lib/auto_html/builder.rb
54
+ - lib/auto_html/capistrano.rb
55
+ - lib/auto_html/filter.rb
56
+ - lib/auto_html/filters/dailymotion.rb
57
+ - lib/auto_html/filters/flickr.rb
58
+ - lib/auto_html/filters/gist.rb
59
+ - lib/auto_html/filters/google_map.rb
60
+ - lib/auto_html/filters/hashtag.rb
61
+ - lib/auto_html/filters/html_escape.rb
62
+ - lib/auto_html/filters/image.rb
63
+ - lib/auto_html/filters/instagram.rb
64
+ - lib/auto_html/filters/link.rb
65
+ - lib/auto_html/filters/liveleak.rb
66
+ - lib/auto_html/filters/metacafe.rb
67
+ - lib/auto_html/filters/redcarpet.rb
68
+ - lib/auto_html/filters/sanitize.rb
69
+ - lib/auto_html/filters/simple_format.rb
70
+ - lib/auto_html/filters/soundcloud.rb
71
+ - lib/auto_html/filters/ted.rb
72
+ - lib/auto_html/filters/twitter.rb
73
+ - lib/auto_html/filters/vimeo.rb
74
+ - lib/auto_html/filters/worldstar.rb
75
+ - lib/auto_html/filters/youtube.rb
76
+ - lib/auto_html/filters/youtube_image.rb
77
+ - lib/auto_html/filters/youtube_js_api.rb
78
+ - lib/auto_html/railtie.rb
79
+ - lib/auto_html/rake_tasks.rb
80
+ - lib/auto_html/task.rb
81
+ - test/fixture_setup.rb
82
+ - test/fixtures/database.yml
83
+ - test/fixtures/schema.rb
84
+ - test/functional/auto_html_for_options_test.rb
85
+ - test/functional/auto_html_for_test.rb
86
+ - test/functional/filter_test.rb
87
+ - test/test_helper.rb
88
+ - test/unit/auto_html_test.rb
89
+ - test/unit/filters/dailymotion_test.rb
90
+ - test/unit/filters/gist_test.rb
91
+ - test/unit/filters/google_map_test.rb
92
+ - test/unit/filters/hashtag_test.rb
93
+ - test/unit/filters/html_escape_test.rb
94
+ - test/unit/filters/image_test.rb
95
+ - test/unit/filters/instagram_test.rb
96
+ - test/unit/filters/link_test.rb
97
+ - test/unit/filters/liveleak_test.rb
98
+ - test/unit/filters/metacafe_test.rb
99
+ - test/unit/filters/redcarpet_test.rb
100
+ - test/unit/filters/sanitize_test.rb
101
+ - test/unit/filters/simple_format_test.rb
102
+ - test/unit/filters/soundcloud_test.rb
103
+ - test/unit/filters/ted_test.rb
104
+ - test/unit/filters/twitter_test.rb
105
+ - test/unit/filters/vimeo_test.rb
106
+ - test/unit/filters/worldstar_test.rb
107
+ - test/unit/filters/youtube_image_test.rb
108
+ - test/unit/filters/youtube_js_api_test.rb
109
+ - test/unit/filters/youtube_test.rb
110
+ - test/unit/unit_test_helper.rb
111
+ homepage: http://github.com/dejan/auto_html
112
+ licenses: []
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">"
126
+ - !ruby/object:Gem::Version
127
+ version: 1.3.1
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.4.5
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Transform URIs to appropriate markup
134
+ test_files: []