make all links open in new tab. fix #1984
This commit is contained in:
parent
ae1fedc73b
commit
84ff366fef
2 changed files with 19 additions and 1 deletions
|
|
@ -8,7 +8,7 @@ module Diaspora
|
||||||
include ActionView::Helpers::TagHelper
|
include ActionView::Helpers::TagHelper
|
||||||
|
|
||||||
def autolink(link, type)
|
def autolink(link, type)
|
||||||
auto_link(link, :link => :urls )
|
auto_link(link, :link => :urls, :html => { :target => "_blank" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
18
spec/lib/diaspora/markdownify_spec.rb
Normal file
18
spec/lib/diaspora/markdownify_spec.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Diaspora::Markdownify::HTML do
|
||||||
|
describe '#autolink' do
|
||||||
|
before do
|
||||||
|
@html = Diaspora::Markdownify::HTML.new
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should make all of the links open in a new tab' do
|
||||||
|
markdownified = @html.autolink("http://joindiaspora.com", nil)
|
||||||
|
doc = Nokogiri.parse(markdownified)
|
||||||
|
|
||||||
|
link = doc.css("a")
|
||||||
|
|
||||||
|
link.attr("target").value.should == "_blank"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue