This commit is contained in:
r888888888
2014-06-20 17:36:11 -07:00
parent 836bd16c47
commit 2aa9288d52
2 changed files with 5 additions and 1 deletions

View File

@@ -103,7 +103,7 @@ class DText
def self.parse_id_links(str)
str = str.gsub(/\bpost #(\d+)/i, %{<a href="/posts/\\1">post #\\1</a>})
str = str.gsub(/\bforum #(\d+)/i, %{<a href="/forum_posts/\\1">forum #\\1</a>})
str = str.gsub(/\btopic #(\d+)/i, %{<a href="/forum_topics/\\1">topic #\\1</a>})
str = str.gsub(/\btopic #(\d+)(?:\/p(\d+))?/i, %{<a href="/forum_topics/\\1?page=\\2">topic #\\1</a>})
str = str.gsub(/\bcomment #(\d+)/i, %{<a href="/comments/\\1">comment #\\1</a>})
str = str.gsub(/\bpool #(\d+)/i, %{<a href="/pools/\\1">pool #\\1</a>})
str = str.gsub(/\buser #(\d+)/i, %{<a href="/users/\\1">user #\\1</a>})

View File

@@ -168,4 +168,8 @@ class DTextTest < ActiveSupport::TestCase
def test_table_with_newlines
assert_equal("<table class=\"striped\"><thead>\n<tr>\n<th>header</th></tr></thead><tbody><tr><td><a href=\"/posts/100\">post #100</a></td></tr></tbody></table>", p("[table]\n[thead]\n[tr]\n[th]header[/th][/tr][/thead][tbody][tr][td]post #100[/td][/tr][/tbody][/table]"))
end
def test_forum_links
assert_equal('<p><a href="/forum_topics/1234?page=4">topic #1234</a></p>', p("topic #1234/p4"))
end
end