auto_html 1.5.3 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'rexml/document'
4
+
5
+ AutoHtml.add_filter(:flickr).with(:maxwidth => nil, :maxheight => nil, :link_options => {}) do |text, options|
6
+ regex = %r{http://(www\.)?flickr\.com/photos/[^\s<]*}
7
+
8
+ text.gsub(regex) do |match|
9
+ params = { :url => match, :format => "json" }
10
+ [:maxwidth, :maxheight].each { |p| params[p] = options[p] unless options[p].nil? or not options[p] > 0 }
11
+
12
+ uri = URI("http://www.flickr.com/services/oembed")
13
+ uri.query = URI.encode_www_form(params)
14
+
15
+ response = JSON.parse(Net::HTTP.get(uri))
16
+
17
+ link_options = Array(options[:link_options]).reject { |k,v| v.nil? }.map { |k, v| %{#{k}="#{REXML::Text::normalize(v)}"} }.join(' ')
18
+ %{<a href="#{match}"#{ ' ' + link_options unless link_options.empty? }><img src="#{response["url"]}" alt="#{response["title"]}" title="#{response["title"]}" /></a>}
19
+ end
20
+ end
@@ -8,6 +8,6 @@ AutoHtml.add_filter(:google_map).with(:width => 420, :height => 315, :style => "
8
8
  height = options[:height]
9
9
  style = options[:style]
10
10
  link_text = options[:link_text]
11
- %{<iframe width="#{width}" height="#{height}" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co#{domain_country}/maps?f=q&amp;source=s_q&amp;#{map_query}&amp;output=embed"></iframe><br /><small><a href="http://maps.google.co#{domain_country}/maps?f=q&amp;source=embed&amp;#{map_query}" style="#{style}">#{link_text}</a></small>}
11
+ %{<iframe width="#{width}" height="#{height}" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="//maps.google.co#{domain_country}/maps?f=q&amp;source=s_q&amp;#{map_query}&amp;output=embed"></iframe><br /><small><a href="//maps.google.co#{domain_country}/maps?f=q&amp;source=embed&amp;#{map_query}" style="#{style}">#{link_text}</a></small>}
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  require 'redcarpet'
2
2
 
3
- AutoHtml.add_filter(:redcarpet).with(:renderer => Redcarpet::Render::HTML) do |text, options|
4
- Redcarpet::Markdown.new(options[:renderer]).render(text)
3
+ AutoHtml.add_filter(:redcarpet).with(:renderer => Redcarpet::Render::HTML, :markdown_options => {}) do |text, options|
4
+ Redcarpet::Markdown.new(options[:renderer], options[:markdown_options]).render(text)
5
5
  end
@@ -0,0 +1,23 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+
4
+ AutoHtml.add_filter(:soundcloud).with({}) do |text, options|
5
+ # set these options
6
+ # :maxwidth => '', :maxheight => '', :auto_play => false, :show_comments => false
7
+ text.gsub(/(https?:\/\/)?(www.)?soundcloud\.com\/.*/) do |match|
8
+ new_uri = match.to_s
9
+ new_uri = (new_uri =~ /^https?\:\/\/.*/) ? URI(new_uri) : URI("http://#{new_uri}")
10
+ new_uri.normalize!
11
+
12
+ uri = URI("http://soundcloud.com/oembed")
13
+ params = {:format => 'json', :url => new_uri}.merge(options)
14
+ uri.query = params.collect { |k,v| "#{k}=#{CGI::escape(v.to_s)}" }.join('&')
15
+ response = Net::HTTP.get(uri)
16
+ if !response.blank?
17
+ JSON.parse(response)["html"]
18
+ else
19
+ match
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,16 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+
4
+ AutoHtml.add_filter(:twitter).with({}) do |text, options|
5
+ regex = %r{https://twitter\.com(/#!)?/[A-Za-z0-9_]{1,15}/status(es)?/\d+}
6
+
7
+ text.gsub(regex) do |match|
8
+ params = { :url => match }.merge(options)
9
+
10
+ uri = URI("http://api.twitter.com/1/statuses/oembed.json")
11
+ uri.query = URI.encode_www_form(params)
12
+
13
+ response = JSON.parse(Net::HTTP.get(uri))
14
+ response["html"]
15
+ end
16
+ end
@@ -1,7 +1,6 @@
1
1
  AutoHtml.add_filter(:vimeo).with(:width => 440, :height => 248, :show_title => false, :show_byline => false, :show_portrait => false) do |text, options|
2
- text.gsub(/(https?):\/\/(www.)?vimeo\.com\/([A-Za-z0-9._%-]*)((\?|#)\S+)?/) do
3
- protocol = $1
4
- vimeo_id = $3
2
+ text.gsub(/https?:\/\/(www.)?vimeo\.com\/([A-Za-z0-9._%-]*)((\?|#)\S+)?/) do
3
+ vimeo_id = $2
5
4
  width = options[:width]
6
5
  height = options[:height]
7
6
  show_title = "title=0" unless options[:show_title]
@@ -11,6 +10,6 @@ AutoHtml.add_filter(:vimeo).with(:width => 440, :height => 248, :show_title => f
11
10
  query_string_variables = [show_title, show_byline, show_portrait].compact.join("&")
12
11
  query_string = "?" + query_string_variables unless query_string_variables.empty?
13
12
 
14
- %{<iframe src="#{protocol}://player.vimeo.com/video/#{vimeo_id}#{query_string}" width="#{width}" height="#{height}" frameborder="#{frameborder}"></iframe>}
13
+ %{<iframe src="//player.vimeo.com/video/#{vimeo_id}#{query_string}" width="#{width}" height="#{height}" frameborder="#{frameborder}"></iframe>}
15
14
  end
16
15
  end
@@ -1,13 +1,12 @@
1
1
  AutoHtml.add_filter(:youtube).with(:width => 420, :height => 315, :frameborder => 0, :wmode => nil) do |text, options|
2
- regex = /(https?):\/\/(www.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(\&\S+)?(\S)*/
2
+ regex = /https?:\/\/(www.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(\&\S+)?(\S)*/
3
3
  text.gsub(regex) do
4
- protocol = $1
5
- youtube_id = $4
4
+ youtube_id = $3
6
5
  width = options[:width]
7
6
  height = options[:height]
8
7
  frameborder = options[:frameborder]
9
8
  wmode = options[:wmode]
10
- src = "#{protocol}://www.youtube.com/embed/#{youtube_id}"
9
+ src = "//www.youtube.com/embed/#{youtube_id}"
11
10
  src += "?wmode=#{wmode}" if wmode
12
11
  %{<iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe>}
13
12
  end
@@ -1,6 +1,6 @@
1
1
  AutoHtml.add_filter(:youtube_js_api).with(:width => 390, :height => 250) do |text, options|
2
- text.gsub(/http:\/\/(www.)?youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)(\&\S+)?/) do
2
+ text.gsub(/https?:\/\/(www.)?youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)(\&\S+)?/) do
3
3
  youtube_id = $2
4
- %{<object width="#{options[:width]}" height="#{options[:height]}"><param name="movie" value="http://www.youtube.com/v/#{youtube_id}?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/#{youtube_id}?enablejsapi=1&playerapiid=ytplayer" type="application/x-shockwave-flash" wmode="transparent" width="#{options[:width]}" height="#{options[:height]}" allowscriptaccess="always"></embed></object>}
4
+ %{<object width="#{options[:width]}" height="#{options[:height]}"><param name="movie" value="//www.youtube.com/v/#{youtube_id}?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="//www.youtube.com/v/#{youtube_id}?enablejsapi=1&playerapiid=ytplayer" type="application/x-shockwave-flash" wmode="transparent" width="#{options[:width]}" height="#{options[:height]}" allowscriptaccess="always"></embed></object>}
5
5
  end
6
6
  end
@@ -7,24 +7,21 @@ require 'auto_html/task'
7
7
  namespace :auto_html do
8
8
  desc "Rebuild auto_html columns"
9
9
  task :rebuild => :environment do
10
- klass = AutoHtml::Task.obtain_class.constantize
10
+
11
+ klass = AutoHtml::Task.obtain_class.constantize
12
+ suffix = AutoHtmlFor.auto_html_for_options[:htmlized_attribute_suffix]
13
+ column_names = klass.respond_to?(:column_names) ? klass.column_names : klass.fields.keys
14
+ observed_attributes = column_names.select { |c| c=~/#{suffix}$/ }.map { |c| c.gsub(/#{suffix}$/, '')}
15
+
11
16
  i = 0
12
- auto_html_fields = []
13
17
  klass.find_each do |item|
14
- unless auto_html_fields.any?
15
- auto_html_methods = item.methods.select { |m| m=~/^auto_html_prepare_/ }
16
- auto_html_methods.each do |method|
17
- auto_html_fields << method
18
- end
18
+ observed_attributes.each do |field|
19
+ item.send("#{field}=", item.send(field))
19
20
  end
20
-
21
- auto_html_fields.each do |field|
22
- item.send(field)
23
- end
24
-
25
21
  item.save
26
22
  i += 1
27
23
  end
24
+
28
25
  puts "Done! Processed #{i} items."
29
26
  end
30
27
  end
@@ -4,11 +4,11 @@ class GoogleMapTest < Test::Unit::TestCase
4
4
 
5
5
  def test_transform
6
6
  result = auto_html('http://maps.google.co.kr/maps?q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A') { google_map }
7
- assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.kr/maps?f=q&amp;source=s_q&amp;q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A&amp;output=embed"></iframe><br /><small><a href="http://maps.google.co.kr/maps?f=q&amp;source=embed&amp;q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A" style="color:#000;text-align:left">View Larger Map</a></small>', result
7
+ assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="//maps.google.co.kr/maps?f=q&amp;source=s_q&amp;q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A&amp;output=embed"></iframe><br /><small><a href="//maps.google.co.kr/maps?f=q&amp;source=embed&amp;q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A" style="color:#000;text-align:left">View Larger Map</a></small>', result
8
8
  end
9
9
 
10
10
  def test_transform_2
11
11
  result = auto_html('http://maps.google.com/maps?hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl') { google_map }
12
- assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl" style="color:#000;text-align:left">View Larger Map</a></small>', result
12
+ assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="//maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl&amp;output=embed"></iframe><br /><small><a href="//maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl" style="color:#000;text-align:left">View Larger Map</a></small>', result
13
13
  end
14
14
  end
@@ -28,4 +28,11 @@ class RedcarpetTest < Test::Unit::TestCase
28
28
  assert_equal '<p><a href="http://example.org/" target="_blank">This is a link</a></p>'+"\n", result
29
29
  end
30
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
31
38
  end
@@ -0,0 +1,38 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+ require 'fakeweb'
3
+
4
+ class SoundcloudTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ response = '{"version":1.0,"type":"rich","provider_name":"SoundCloud","provider_url":"http://soundcloud.com","height":166,"width":"100%","title":"Flickermood by Forss","description":"From the Soulhack album,\u0026nbsp;recently featured in this ad \u003Ca href=\"https://www.dswshoes.com/tv_commercial.jsp?m=october2007\"\u003Ehttps://www.dswshoes.com/tv_commercial.jsp?m=october2007\u003C/a\u003E ","thumbnail_url":"http://i1.sndcdn.com/artworks-000000001720-91c40a-t500x500.jpg?330b92d","html":"\u003Ciframe width=\"100%\" height=\"166\" scrolling=\"no\" frameborder=\"no\" src=\"http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F293\u0026show_artwork=true\"\u003E\u003C/iframe\u003E","author_name":"Forss","author_url":"http://soundcloud.com/forss"}'
8
+ FakeWeb.register_uri(:get, %r|http://soundcloud\.com/oembed|, :body => response)
9
+ end
10
+
11
+ def test_transform_url_with_www
12
+ result = auto_html('http://www.soundcloud.com/forss/flickermood') { soundcloud }
13
+ assert_equal '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F293&show_artwork=true"></iframe>', result
14
+ end
15
+
16
+ def test_transform_url_without_www
17
+ result = auto_html('http://soundcloud.com/forss/flickermood') { soundcloud }
18
+ assert_equal '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F293&show_artwork=true"></iframe>', result
19
+ end
20
+
21
+ def test_transform_url_without_protocol
22
+ result = auto_html('soundcloud.com/forss/flickermood') { soundcloud }
23
+ assert_equal '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F293&show_artwork=true"></iframe>', result
24
+ end
25
+
26
+ def test_transform_url_with_ssl
27
+ result = auto_html('https://soundcloud.com/forss/flickermood') { soundcloud }
28
+ assert_equal '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F293&show_artwork=true"></iframe>', result
29
+ end
30
+
31
+ def test_transform_url_with_options
32
+ response = '{"version":1.0,"type":"rich","provider_name":"SoundCloud","provider_url":"http://soundcloud.com","height":100,"width":100,"title":"Flickermood by Forss","description":"From the Soulhack album,\u0026nbsp;recently featured in this ad \u003Ca href=\"https://www.dswshoes.com/tv_commercial.jsp?m=october2007\"\u003Ehttps://www.dswshoes.com/tv_commercial.jsp?m=october2007\u003C/a\u003E ","thumbnail_url":"http://i1.sndcdn.com/artworks-000000001720-91c40a-t500x500.jpg?330b92d","html":"\u003Ciframe width=\"100\" height=\"100\" scrolling=\"no\" frameborder=\"no\" src=\"http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F293\u0026show_artwork=true\u0026show_comments=false\u0026maxwidth=100\u0026maxheight=100\u0026auto_play=false\"\u003E\u003C/iframe\u003E","author_name":"Forss","author_url":"http://soundcloud.com/forss"}'
33
+ FakeWeb.register_uri(:get, %r|http://soundcloud\.com/oembed|, :body => response)
34
+
35
+ result = auto_html('http://www.soundcloud.com/forss/flickermood') { soundcloud(:maxwidth => '100', :maxheight => '100', :auto_play => false, :show_comments => false) }
36
+ assert_equal '<iframe width="100" height="100" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F293&show_artwork=true&show_comments=false&maxwidth=100&maxheight=100&auto_play=false"></iframe>', result
37
+ end
38
+ end
@@ -4,47 +4,47 @@ class VimeoTest < Test::Unit::TestCase
4
4
 
5
5
  def test_transform_url_with_www
6
6
  result = auto_html('http://www.vimeo.com/3300155') { vimeo }
7
- assert_equal '<iframe src="http://player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
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
8
  end
9
9
 
10
10
  def test_transform_url_without_www
11
11
  result = auto_html('http://vimeo.com/3300155') { vimeo }
12
- assert_equal '<iframe src="http://player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
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
13
  end
14
14
 
15
15
  def test_transform_url_with_params
16
16
  result = auto_html('http://vimeo.com/3300155?pg=embed&sec=') { vimeo }
17
- assert_equal '<iframe src="http://player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
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
18
  end
19
19
 
20
20
  def test_transform_url_with_anchor
21
21
  result = auto_html('http://vimeo.com/3300155#skirt') { vimeo }
22
- assert_equal '<iframe src="http://player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
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
23
  end
24
24
 
25
25
  def test_transform_with_options
26
26
  result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250) }
27
- assert_equal '<iframe src="http://player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="300" height="250" frameborder="0"></iframe>', result
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
28
  end
29
29
 
30
30
  def test_transform_with_title
31
31
  result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_title => true) }
32
- assert_equal '<iframe src="http://player.vimeo.com/video/3300155?byline=0&portrait=0" width="300" height="250" frameborder="0"></iframe>', result
32
+ assert_equal '<iframe src="//player.vimeo.com/video/3300155?byline=0&portrait=0" width="300" height="250" frameborder="0"></iframe>', result
33
33
  end
34
34
 
35
35
  def test_transform_with_byline
36
36
  result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_byline => true) }
37
- assert_equal '<iframe src="http://player.vimeo.com/video/3300155?title=0&portrait=0" width="300" height="250" frameborder="0"></iframe>', result
37
+ assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&portrait=0" width="300" height="250" frameborder="0"></iframe>', result
38
38
  end
39
39
 
40
40
  def test_transform_with_portrait
41
41
  result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_portrait => true) }
42
- assert_equal '<iframe src="http://player.vimeo.com/video/3300155?title=0&byline=0" width="300" height="250" frameborder="0"></iframe>', result
42
+ assert_equal '<iframe src="//player.vimeo.com/video/3300155?title=0&byline=0" width="300" height="250" frameborder="0"></iframe>', result
43
43
  end
44
44
 
45
45
  def test_transform_url_with_https
46
46
  result = auto_html('https://vimeo.com/3300155') { vimeo }
47
- assert_equal '<iframe src="https://player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
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
48
  end
49
49
 
50
50
  end
@@ -4,27 +4,27 @@ class YouTubeJsApiTest < Test::Unit::TestCase
4
4
 
5
5
  def test_transform
6
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="http://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="http://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
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
8
  end
9
9
 
10
10
  def test_transform2
11
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="http://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="http://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
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
13
  end
14
14
 
15
15
  def test_transform3
16
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="http://www.youtube.com/v/Mw8KJ29qph0?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="http://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
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
18
  end
19
19
 
20
20
  def test_transform_url_without_www
21
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="http://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="http://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
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
23
  end
24
24
 
25
25
  def test_transform_with_options
26
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="http://www.youtube.com/v/ZA1NoOOoaNw?enablejsapi=1&playerapiid=ytplayer"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="http://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
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
28
  end
29
29
 
30
30
  end
@@ -4,46 +4,46 @@ class YouTubeTest < Test::Unit::TestCase
4
4
 
5
5
  def test_transform
6
6
  result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o') { youtube }
7
- assert_equal '<iframe width="420" height="315" src="http://www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
7
+ assert_equal '<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
8
8
  end
9
9
 
10
10
  def test_transform2
11
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 '<iframe width="420" height="315" src="http://www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
12
+ assert_equal '<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
13
13
  end
14
14
 
15
15
  def test_transform3
16
16
  result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o&feature=related') { youtube }
17
- assert_equal '<iframe width="420" height="315" src="http://www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
17
+ assert_equal '<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
18
18
  end
19
19
 
20
20
  def test_transform3
21
21
  result = auto_html('foo http://www.youtube.com/watch?v=fT1ahr81HLw bar') { youtube }
22
- assert_equal 'foo <iframe width="420" height="315" src="http://www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen></iframe> bar', result
22
+ assert_equal 'foo <iframe width="420" height="315" src="//www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen></iframe> bar', result
23
23
  end
24
24
 
25
25
  def test_transform_url_without_www
26
26
  result = auto_html('http://youtube.com/watch?v=BwNrmYRiX_o') { youtube }
27
- assert_equal '<iframe width="420" height="315" src="http://www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
27
+ assert_equal '<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
28
28
  end
29
29
 
30
30
  def test_transform_with_options
31
31
  result = auto_html('http://www.youtube.com/watch?v=BwNrmYRiX_o') { youtube(:width => 300, :height => 255, :frameborder => 1, :wmode => 'window') }
32
- assert_equal '<iframe width="300" height="255" src="http://www.youtube.com/embed/BwNrmYRiX_o?wmode=window" frameborder="1" allowfullscreen></iframe>', result
32
+ assert_equal '<iframe width="300" height="255" src="//www.youtube.com/embed/BwNrmYRiX_o?wmode=window" frameborder="1" allowfullscreen></iframe>', result
33
33
  end
34
34
 
35
35
  def test_transform_with_short_url
36
36
  result = auto_html('http://www.youtu.be/BwNrmYRiX_o') { youtube }
37
- assert_equal '<iframe width="420" height="315" src="http://www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
37
+ assert_equal '<iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
38
38
  end
39
39
 
40
40
  def test_transform_https
41
41
  result = auto_html("https://www.youtube.com/watch?v=t7NdBIA4zJg") { youtube }
42
- assert_equal '<iframe width="420" height="315" src="https://www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe>', result
42
+ assert_equal '<iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe>', result
43
43
  end
44
44
 
45
45
  def test_short_with_params
46
46
  result = auto_html("http://youtu.be/t7NdBIA4zJg?t=1s&hd=1") { youtube }
47
- assert_equal '<iframe width="420" height="315" src="http://www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe>', result
47
+ assert_equal '<iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen></iframe>', result
48
48
  end
49
49
  end
metadata CHANGED
@@ -1,55 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: auto_html
3
- version: !ruby/object:Gem::Version
4
- version: 1.5.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 6
9
+ - 0
10
+ version: 1.6.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Dejan Simic
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-05-08 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-07-29 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: rinku
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 1.5.0
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
- requirements:
25
+ requirements:
27
26
  - - ~>
28
- - !ruby/object:Gem::Version
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 1
31
+ - 5
32
+ - 0
29
33
  version: 1.5.0
30
- - !ruby/object:Gem::Dependency
31
- name: redcarpet
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 2.0.0
38
34
  type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: redcarpet
39
38
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
39
+ requirement: &id002 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
41
+ requirements:
43
42
  - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 2.0.0
46
- description: Automatically transforms URIs (via domain) and includes the destination
47
- resource (Vimeo, YouTube movie, image, ...) in your document
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 2
47
+ - 0
48
+ version: "2.0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ description: Automatically transforms URIs (via domain) and includes the destination resource (Vimeo, YouTube movie, image, ...) in your document
48
52
  email: desimic@gmail.com
49
53
  executables: []
54
+
50
55
  extensions: []
56
+
51
57
  extra_rdoc_files: []
52
- files:
58
+
59
+ files:
53
60
  - Rakefile
54
61
  - lib/auto_html/auto_html_for.rb
55
62
  - lib/auto_html/base.rb
@@ -57,6 +64,7 @@ files:
57
64
  - lib/auto_html/capistrano.rb
58
65
  - lib/auto_html/filter.rb
59
66
  - lib/auto_html/filters/dailymotion.rb
67
+ - lib/auto_html/filters/flickr.rb
60
68
  - lib/auto_html/filters/gist.rb
61
69
  - lib/auto_html/filters/google_map.rb
62
70
  - lib/auto_html/filters/google_video.rb
@@ -67,6 +75,8 @@ files:
67
75
  - lib/auto_html/filters/redcarpet.rb
68
76
  - lib/auto_html/filters/sanitize.rb
69
77
  - lib/auto_html/filters/simple_format.rb
78
+ - lib/auto_html/filters/soundcloud.rb
79
+ - lib/auto_html/filters/twitter.rb
70
80
  - lib/auto_html/filters/vimeo.rb
71
81
  - lib/auto_html/filters/youtube.rb
72
82
  - lib/auto_html/filters/youtube_js_api.rb
@@ -93,6 +103,7 @@ files:
93
103
  - test/unit/filters/redcarpet_test.rb
94
104
  - test/unit/filters/sanitize_test.rb
95
105
  - test/unit/filters/simple_format_test.rb
106
+ - test/unit/filters/soundcloud_test.rb
96
107
  - test/unit/filters/vimeo_test.rb
97
108
  - test/unit/filters/youtube_js_api_test.rb
98
109
  - test/unit/filters/youtube_test.rb
@@ -100,26 +111,36 @@ files:
100
111
  - README.md
101
112
  homepage: http://github.com/dejan/auto_html
102
113
  licenses: []
114
+
103
115
  post_install_message:
104
116
  rdoc_options: []
105
- require_paths:
117
+
118
+ require_paths:
106
119
  - lib
107
- required_ruby_version: !ruby/object:Gem::Requirement
120
+ required_ruby_version: !ruby/object:Gem::Requirement
108
121
  none: false
109
- requirements:
110
- - - ! '>='
111
- - !ruby/object:Gem::Version
112
- version: '0'
113
- required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
130
  none: false
115
- requirements:
116
- - - ! '>='
117
- - !ruby/object:Gem::Version
118
- version: '0'
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
119
138
  requirements: []
139
+
120
140
  rubyforge_project:
121
141
  rubygems_version: 1.8.24
122
142
  signing_key:
123
143
  specification_version: 3
124
144
  summary: Transform URIs to appropriate markup
125
145
  test_files: []
146
+