From 47e7ceacd72d9d9e022c118d069d6934563e1f74 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 1 Oct 2007 17:45:40 +0000 Subject: Better handling of external link style assignment. git-svn-id: http://redmine.rubyforge.org/svn/trunk@792 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redcloth.rb | 4 +++- lib/redmine/wiki_formatting.rb | 2 +- public/stylesheets/application.css | 7 +------ test/unit/helpers/application_helper_test.rb | 17 +++++++++-------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/redcloth.rb b/lib/redcloth.rb index e1a995da2..c4b504871 100644 --- a/lib/redcloth.rb +++ b/lib/redcloth.rb @@ -784,7 +784,9 @@ class RedCloth < String atts << " title=\"#{ title }\"" if title atts = shelve( atts ) if atts - "#{ pre }#{ text }#{ post }" + external = (url =~ /^http:\/\//) ? ' class="external"' : '' + + "#{ pre }#{ text }#{ post }" end end diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 6f2aea0ae..da04dd932 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -99,7 +99,7 @@ module Redmine # and URL's prefixed with ! !> !< != (textile images) all else - %(#{leading}#{proto + url}#{post}) + %(#{leading}#{proto + url}#{post}) end end end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index d31e3a320..a1e1cca22 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -278,18 +278,13 @@ div.wiki table, div.wiki td, div.wiki th { padding: 4px; } -div.wiki a { +div.wiki .external { background-position: 0% 60%; background-repeat: no-repeat; padding-left: 12px; 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 { color: #b73535; } diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 24935bbb7..1da25b6fe 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -28,12 +28,12 @@ class ApplicationHelperTest < HelperTestCase def test_auto_links to_test = { - 'http://foo.bar' => 'http://foo.bar', - 'http://foo.bar.' => 'http://foo.bar.', - 'http://foo.bar/foo.bar#foo.bar.' => 'http://foo.bar/foo.bar#foo.bar.', - 'www.foo.bar' => 'www.foo.bar', - 'http://foo.bar/page?p=1&t=z&s=' => 'http://foo.bar/page?p=1&t=z&s=', - 'http://foo.bar/page#125' => 'http://foo.bar/page#125' + 'http://foo.bar' => 'http://foo.bar', + 'http://foo.bar.' => 'http://foo.bar.', + 'http://foo.bar/foo.bar#foo.bar.' => 'http://foo.bar/foo.bar#foo.bar.', + 'www.foo.bar' => 'www.foo.bar', + 'http://foo.bar/page?p=1&t=z&s=' => 'http://foo.bar/page?p=1&t=z&s=', + 'http://foo.bar/page#125' => 'http://foo.bar/page#125' } to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } end @@ -49,8 +49,9 @@ class ApplicationHelperTest < HelperTestCase '!http://foo.bar/image.jpg!' => '', 'floating !>http://foo.bar/image.jpg!' => 'floating
', # textile links - 'This is a "link":http://foo.bar' => 'This is a link', - '"link (Link title)":http://foo.bar' => 'link' + 'This is a "link":http://foo.bar' => 'This is a link', + 'This is an intern "link":/foo/bar' => 'This is an intern link', + '"link (Link title)":http://foo.bar' => 'link' } to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } end -- cgit v1.2.3