Skip to content

Commit

Permalink
Merge pull request #95 from Dhaulagiri/master
Browse files Browse the repository at this point in the history
Add basic Instagram filter & test
  • Loading branch information
dejan committed Mar 15, 2014
2 parents ad1bf80 + 99331ab commit 4c4bc1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/auto_html/filters/instagram.rb
@@ -0,0 +1,10 @@
require 'uri'
require 'net/http'

AutoHtml.add_filter(:instagram) do |text|
text << '/' unless text.end_with?('/')
regex = %r{https?:\/\/(www.)?instagr(am\.com|\.am)/p/.+}
text.gsub(regex) do
%{<iframe src="#{text}embed" height="714" width="616" frameborder="0" scrolling="no"></iframe>}
end
end
8 changes: 8 additions & 0 deletions test/unit/filters/instagram_test.rb
@@ -0,0 +1,8 @@
require File.expand_path('../../unit_test_helper', __FILE__)

class InstagramTest < Test::Unit::TestCase
def test_instagram_embed
result = auto_html('http://instagram.com/p/WsQTLAGvx7/') { instagram }
assert_equal '<iframe src="http://instagram.com/p/WsQTLAGvx7/embed" height="714" width="616" frameborder="0" scrolling="no"></iframe>', result
end
end

0 comments on commit 4c4bc1f

Please sign in to comment.