auto_html 1.6.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +65 -94
- data/Rakefile +8 -7
- data/lib/auto_html/emoji.rb +24 -0
- data/lib/auto_html/html_escape.rb +12 -0
- data/lib/auto_html/image.rb +23 -0
- data/lib/auto_html/link.rb +33 -0
- data/lib/auto_html/markdown.rb +17 -0
- data/lib/auto_html/pipeline.rb +18 -0
- data/lib/auto_html/simple_format.rb +23 -0
- data/lib/auto_html/tag_helper.rb +38 -0
- data/lib/auto_html.rb +11 -15
- data/spec/auto_html/emoji_spec.rb +9 -0
- data/spec/auto_html/html_escape_spec.rb +10 -0
- data/spec/auto_html/image_spec.rb +41 -0
- data/spec/auto_html/link_spec.rb +53 -0
- data/spec/auto_html/markdown_spec.rb +9 -0
- data/spec/auto_html/pipeline_spec.rb +26 -0
- data/spec/auto_html/simple_format_spec.rb +18 -0
- data/spec/auto_html/tag_helper_spec.rb +30 -0
- data/spec/spec_helper.rb +13 -0
- metadata +114 -92
- data/lib/auto_html/auto_html_for.rb +0 -64
- data/lib/auto_html/base.rb +0 -18
- data/lib/auto_html/builder.rb +0 -21
- data/lib/auto_html/capistrano.rb +0 -17
- data/lib/auto_html/filter.rb +0 -22
- data/lib/auto_html/filters/dailymotion.rb +0 -6
- data/lib/auto_html/filters/flickr.rb +0 -20
- data/lib/auto_html/filters/gist.rb +0 -8
- data/lib/auto_html/filters/google_map.rb +0 -19
- data/lib/auto_html/filters/google_video.rb +0 -6
- data/lib/auto_html/filters/hashtag.rb +0 -7
- data/lib/auto_html/filters/html_escape.rb +0 -9
- data/lib/auto_html/filters/image.rb +0 -16
- data/lib/auto_html/filters/instagram.rb +0 -10
- data/lib/auto_html/filters/link.rb +0 -16
- data/lib/auto_html/filters/liveleak.rb +0 -19
- data/lib/auto_html/filters/metacafe.rb +0 -13
- data/lib/auto_html/filters/redcarpet.rb +0 -4
- data/lib/auto_html/filters/sanitize.rb +0 -5
- data/lib/auto_html/filters/simple_format.rb +0 -12
- data/lib/auto_html/filters/soundcloud.rb +0 -21
- data/lib/auto_html/filters/ted.rb +0 -13
- data/lib/auto_html/filters/twitter.rb +0 -19
- data/lib/auto_html/filters/vimeo.rb +0 -15
- data/lib/auto_html/filters/worldstar.rb +0 -8
- data/lib/auto_html/filters/youtube.rb +0 -19
- data/lib/auto_html/filters/youtube_js_api.rb +0 -6
- data/lib/auto_html/railtie.rb +0 -10
- data/lib/auto_html/rake_tasks.rb +0 -27
- data/lib/auto_html/task.rb +0 -9
- data/test/fixture_setup.rb +0 -13
- data/test/fixtures/database.yml +0 -5
- data/test/fixtures/schema.rb +0 -20
- data/test/functional/auto_html_for_options_test.rb +0 -26
- data/test/functional/auto_html_for_test.rb +0 -56
- data/test/functional/filter_test.rb +0 -27
- data/test/test_helper.rb +0 -9
- data/test/unit/auto_html_test.rb +0 -37
- data/test/unit/filters/dailymotion_test.rb +0 -20
- data/test/unit/filters/gist_test.rb +0 -15
- data/test/unit/filters/google_map_test.rb +0 -24
- data/test/unit/filters/hashtag_test.rb +0 -25
- data/test/unit/filters/html_escape_test.rb +0 -15
- data/test/unit/filters/image_test.rb +0 -65
- data/test/unit/filters/instagram_test.rb +0 -8
- data/test/unit/filters/link_test.rb +0 -55
- data/test/unit/filters/liveleak_test.rb +0 -15
- data/test/unit/filters/metacafe_test.rb +0 -29
- data/test/unit/filters/redcarpet_test.rb +0 -38
- data/test/unit/filters/sanitize_test.rb +0 -36
- data/test/unit/filters/simple_format_test.rb +0 -15
- data/test/unit/filters/soundcloud_test.rb +0 -29
- data/test/unit/filters/ted_test.rb +0 -18
- data/test/unit/filters/twitter_test.rb +0 -45
- data/test/unit/filters/vimeo_test.rb +0 -50
- data/test/unit/filters/worldstar_test.rb +0 -14
- data/test/unit/filters/youtube_js_api_test.rb +0 -30
- data/test/unit/filters/youtube_test.rb +0 -59
- data/test/unit/unit_test_helper.rb +0 -3
@@ -1,38 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
|
3
|
-
class RedcarpetTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_transform_strong
|
6
|
-
result = auto_html("This is **my** text.") { redcarpet }
|
7
|
-
assert_equal '<p>This is <strong>my</strong> text.</p>'+"\n", result
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_transform_title
|
11
|
-
result = auto_html("## This is a title ##") { redcarpet }
|
12
|
-
assert_equal '<h2>This is a title</h2>'+"\n", result
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_transform_link
|
16
|
-
result = auto_html('[This is a link](http://example.org/)') { redcarpet }
|
17
|
-
assert_equal '<p><a href="http://example.org/">This is a link</a></p>'+"\n", result
|
18
|
-
end
|
19
|
-
|
20
|
-
class LinksInNewWindow < ::Redcarpet::Render::HTML
|
21
|
-
def link(link, title, content)
|
22
|
-
"<a href=\"#{link}\" target=\"_blank\">#{content}</a>"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_transform_link_target_blank
|
27
|
-
result = auto_html('[This is a link](http://example.org/)') { redcarpet(:renderer => LinksInNewWindow) }
|
28
|
-
assert_equal '<p><a href="http://example.org/" target="_blank">This is a link</a></p>'+"\n", result
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_options
|
32
|
-
result = auto_html('http://example.org/') { redcarpet }
|
33
|
-
assert_equal '<p>http://example.org/</p>'+"\n", result
|
34
|
-
|
35
|
-
result = auto_html('http://example.org/') { redcarpet(:markdown_options => { :autolink => true }) }
|
36
|
-
assert_equal '<p><a href="http://example.org/">http://example.org/</a></p>'+"\n", result
|
37
|
-
end
|
38
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
|
3
|
-
class SanitizeTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_trasform
|
6
|
-
result = auto_html("<script>alert(0)</script>") { sanitize }
|
7
|
-
assert_equal "", result
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_trasform2
|
11
|
-
result = auto_html("<div>test</div>") { sanitize }
|
12
|
-
assert_equal "<div>test</div>", result
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_trasform3
|
16
|
-
result = auto_html("<div>test</div>") { sanitize :tags => %w(div) }
|
17
|
-
assert_equal "<div>test</div>", result
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_trasform4
|
21
|
-
result = auto_html("<div>test</div>") { sanitize :tags => %w(p) }
|
22
|
-
assert_equal "test", result
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_trasform5
|
26
|
-
result = auto_html("<a rel='nofollow'>test</div>") { sanitize :tags => %w(a), :attributes => %w(href)}
|
27
|
-
assert_equal "<a>test", result
|
28
|
-
#
|
29
|
-
# from Rails doc:
|
30
|
-
#
|
31
|
-
# Please note that sanitizing user-provided text does not
|
32
|
-
# guarantee that the resulting markup is valid.
|
33
|
-
#
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
|
3
|
-
class SimpleFormatTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_transform
|
6
|
-
result = auto_html('Hey check out my blog => http://rors.org') { simple_format }
|
7
|
-
assert_equal '<p>Hey check out my blog => http://rors.org</p>', result
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_trasform2
|
11
|
-
result = auto_html('Hey check out my code => http://github.com/dejan') { simple_format }
|
12
|
-
assert_equal '<p>Hey check out my code => http://github.com/dejan</p>', result
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
require 'fakeweb'
|
3
|
-
|
4
|
-
class SoundcloudTest < Test::Unit::TestCase
|
5
|
-
def test_transform_url_with_www
|
6
|
-
result = auto_html('http://www.soundcloud.com/forss/flickermood') { soundcloud }
|
7
|
-
assert_equal '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http://www.soundcloud.com/forss/flickermood&show_artwork=false&show_comments=false&auto_play=false&color=915f33&theme_color=00FF00"></iframe>', result
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_transform_url_without_www
|
11
|
-
result = auto_html('http://soundcloud.com/forss/flickermood') { soundcloud }
|
12
|
-
assert_equal '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http://soundcloud.com/forss/flickermood&show_artwork=false&show_comments=false&auto_play=false&color=915f33&theme_color=00FF00"></iframe>', result
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_transform_url_without_protocol
|
16
|
-
result = auto_html('soundcloud.com/forss/flickermood') { soundcloud }
|
17
|
-
assert_equal '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http://soundcloud.com/forss/flickermood&show_artwork=false&show_comments=false&auto_play=false&color=915f33&theme_color=00FF00"></iframe>', result
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_transform_url_with_ssl
|
21
|
-
result = auto_html('https://soundcloud.com/forss/flickermood') { soundcloud }
|
22
|
-
assert_equal '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=https://soundcloud.com/forss/flickermood&show_artwork=false&show_comments=false&auto_play=false&color=915f33&theme_color=00FF00"></iframe>', result
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_transform_url_with_options
|
26
|
-
result = auto_html('http://www.soundcloud.com/forss/flickermood') { soundcloud(:width => '50%', :height => '100', :auto_play => true, :show_comments => true) }
|
27
|
-
assert_equal '<iframe width="50%" height="100" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http://www.soundcloud.com/forss/flickermood&show_artwork=false&show_comments=true&auto_play=true&color=915f33&theme_color=00FF00"></iframe>', result
|
28
|
-
end
|
29
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
|
3
|
-
class TedTest < Test::Unit::TestCase
|
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
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
require 'fakeweb'
|
3
|
-
|
4
|
-
class TwitterTest < Test::Unit::TestCase
|
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't! Start asking "What would need to be true for me to accomplish this" - it'll change your life. <a href="https://twitter.com/search?q=%23focus&src=hash">#focus</a> <a href="https://twitter.com/search?q=%23solutions&src=hash">#solutions</a></p>— 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
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
|
3
|
-
class VimeoTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_transform_url_with_www
|
6
|
-
result = auto_html('http://www.vimeo.com/3300155') { vimeo }
|
7
|
-
assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_transform_url_without_www
|
11
|
-
result = auto_html('http://vimeo.com/3300155') { vimeo }
|
12
|
-
assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_transform_url_with_params
|
16
|
-
result = auto_html('http://vimeo.com/3300155?pg=embed&sec=') { vimeo }
|
17
|
-
assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_transform_url_with_anchor
|
21
|
-
result = auto_html('http://vimeo.com/3300155#skirt') { vimeo }
|
22
|
-
assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_transform_with_options
|
26
|
-
result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250) }
|
27
|
-
assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="300" height="250" frameborder="0"></iframe>', result
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_transform_with_title
|
31
|
-
result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_title => true) }
|
32
|
-
assert_equal '<iframe src="//player.vimeo.com/video/3300155?byline=0&portrait=0" width="300" height="250" frameborder="0"></iframe>', result
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_transform_with_byline
|
36
|
-
result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_byline => true) }
|
37
|
-
assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&portrait=0" width="300" height="250" frameborder="0"></iframe>', result
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_transform_with_portrait
|
41
|
-
result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_portrait => true) }
|
42
|
-
assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0" width="300" height="250" frameborder="0"></iframe>', result
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_transform_url_with_https
|
46
|
-
result = auto_html('https://vimeo.com/3300155') { vimeo }
|
47
|
-
assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
|
3
|
-
class WorldstarTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_transform
|
6
|
-
result = auto_html('http://www.worldstarhiphop.com/videos/video.php?v=wshhc29WLkx550Hv9o31') { worldstar }
|
7
|
-
assert_equal '<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>', result
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_transform_with_options
|
11
|
-
result = auto_html('http://www.worldstarhiphop.com/videos/video.php?v=wshhc29WLkx550Hv9o31') { worldstar(:width => 400, :height => 250)}
|
12
|
-
assert_equal '<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>', result
|
13
|
-
end
|
14
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
|
3
|
-
class YouTubeJsApiTest < Test::Unit::TestCase
|
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
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require File.expand_path('../../unit_test_helper', __FILE__)
|
2
|
-
|
3
|
-
class YouTubeTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_transform
|
6
|
-
result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o') { youtube }
|
7
|
-
assert_equal '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></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 }
|
12
|
-
assert_equal '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></div>', result
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_transform3
|
16
|
-
result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o&feature=related') { youtube }
|
17
|
-
assert_equal '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></div>', result
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_transform3
|
21
|
-
result = auto_html('foo http://www.youtube.com/watch?v=fT1ahr81HLw bar') { youtube }
|
22
|
-
assert_equal 'foo <div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen></iframe></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 }
|
27
|
-
assert_equal 'foo <div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen></iframe></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 }
|
32
|
-
assert_equal '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></div>', result
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_transform_with_options
|
36
|
-
result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o') { youtube(:width => 300, :height => 255, :frameborder => 1, :wmode => 'window') }
|
37
|
-
assert_equal '<div class="video youtube"><iframe width="300" height="255" src="//www.youtube.com/embed/BwNrmYRiX_o?wmode=window" frameborder="1" allowfullscreen></iframe></div>', result
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_transform_with_short_url
|
41
|
-
result = auto_html('http://www.youtu.be/BwNrmYRiX_o') { youtube }
|
42
|
-
assert_equal '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe></div>', result
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_transform_https
|
46
|
-
result = auto_html("https://www.youtube.com/watch?v=t7NdBIA4zJg") { youtube }
|
47
|
-
assert_equal '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe></div>', result
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_short_with_params
|
51
|
-
result = auto_html("http://youtu.be/t7NdBIA4zJg?t=1s&hd=1") { youtube }
|
52
|
-
assert_equal '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe></div>', result
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_transform_without_protocol
|
56
|
-
result = auto_html("www.youtube.com/watch?v=t7NdBIA4zJg") { youtube }
|
57
|
-
assert_equal '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe></div>', result
|
58
|
-
end
|
59
|
-
end
|