Better handling of external link style assignment.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@792 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
48fb20f540
commit
47e7ceacd7
|
@ -784,7 +784,9 @@ class RedCloth < String
|
||||||
atts << " title=\"#{ title }\"" if title
|
atts << " title=\"#{ title }\"" if title
|
||||||
atts = shelve( atts ) if atts
|
atts = shelve( atts ) if atts
|
||||||
|
|
||||||
"#{ pre }<a#{ atts }>#{ text }</a>#{ post }"
|
external = (url =~ /^http:\/\//) ? ' class="external"' : ''
|
||||||
|
|
||||||
|
"#{ pre }<a#{ atts }#{ external }>#{ text }</a>#{ post }"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ module Redmine
|
||||||
# and URL's prefixed with ! !> !< != (textile images)
|
# and URL's prefixed with ! !> !< != (textile images)
|
||||||
all
|
all
|
||||||
else
|
else
|
||||||
%(#{leading}<a href="#{proto=="www."?"http://www.":proto}#{url}">#{proto + url}</a>#{post})
|
%(#{leading}<a class="external" href="#{proto=="www."?"http://www.":proto}#{url}">#{proto + url}</a>#{post})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -278,18 +278,13 @@ div.wiki table, div.wiki td, div.wiki th {
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.wiki a {
|
div.wiki .external {
|
||||||
background-position: 0% 60%;
|
background-position: 0% 60%;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
padding-left: 12px;
|
padding-left: 12px;
|
||||||
background-image: url(../images/external.png);
|
background-image: url(../images/external.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.wiki a.wiki-page, div.wiki a.issue, div.wiki a.changeset, div.wiki a.email, div.wiki div.toc a {
|
|
||||||
padding-left: 0;
|
|
||||||
background-image: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.wiki a.new {
|
div.wiki a.new {
|
||||||
color: #b73535;
|
color: #b73535;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,12 @@ class ApplicationHelperTest < HelperTestCase
|
||||||
|
|
||||||
def test_auto_links
|
def test_auto_links
|
||||||
to_test = {
|
to_test = {
|
||||||
'http://foo.bar' => '<a href="http://foo.bar">http://foo.bar</a>',
|
'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>',
|
||||||
'http://foo.bar.' => '<a href="http://foo.bar">http://foo.bar</a>.',
|
'http://foo.bar.' => '<a class="external" href="http://foo.bar">http://foo.bar</a>.',
|
||||||
'http://foo.bar/foo.bar#foo.bar.' => '<a href="http://foo.bar/foo.bar#foo.bar">http://foo.bar/foo.bar#foo.bar</a>.',
|
'http://foo.bar/foo.bar#foo.bar.' => '<a class="external" href="http://foo.bar/foo.bar#foo.bar">http://foo.bar/foo.bar#foo.bar</a>.',
|
||||||
'www.foo.bar' => '<a href="http://www.foo.bar">www.foo.bar</a>',
|
'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>',
|
||||||
'http://foo.bar/page?p=1&t=z&s=' => '<a href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>',
|
'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>',
|
||||||
'http://foo.bar/page#125' => '<a href="http://foo.bar/page#125">http://foo.bar/page#125</a>'
|
'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>'
|
||||||
}
|
}
|
||||||
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
||||||
end
|
end
|
||||||
|
@ -49,8 +49,9 @@ class ApplicationHelperTest < HelperTestCase
|
||||||
'!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />',
|
'!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />',
|
||||||
'floating !>http://foo.bar/image.jpg!' => 'floating <div style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></div>',
|
'floating !>http://foo.bar/image.jpg!' => 'floating <div style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></div>',
|
||||||
# textile links
|
# textile links
|
||||||
'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar">link</a>',
|
'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>',
|
||||||
'"link (Link title)":http://foo.bar' => '<a href="http://foo.bar" title="Link title">link</a>'
|
'This is an intern "link":/foo/bar' => 'This is an intern <a href="/foo/bar">link</a>',
|
||||||
|
'"link (Link title)":http://foo.bar' => '<a href="http://foo.bar" title="Link title" class="external">link</a>'
|
||||||
}
|
}
|
||||||
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue