dtext: don't link non-artist tags to artist entries.
* Don't link non-artist tags to artist pages, even when the tag has an
artist entry. These artist entries are usually old deleted entries
that happen to have the same name as a gentag, or leftover entries
that need to be deleted.
* URL escape the artist name in /artists/show_or_new?name={name}
This commit is contained in:
@@ -37,8 +37,8 @@ class DText
|
|||||||
tag = tags.find { |tag| tag.name == name }
|
tag = tags.find { |tag| tag.name == name }
|
||||||
artist = artists.find { |artist| artist.name == name }
|
artist = artists.find { |artist| artist.name == name }
|
||||||
|
|
||||||
if (tag.present? && tag.category == Tag.categories.artist) || artist.present?
|
if tag.present? && tag.category == Tag.categories.artist
|
||||||
node["href"] = "/artists/show_or_new?name=#{name}"
|
node["href"] = "/artists/show_or_new?name=#{CGI.escape(name)}"
|
||||||
|
|
||||||
if artist.blank?
|
if artist.blank?
|
||||||
node["class"] += " dtext-artist-does-not-exist"
|
node["class"] += " dtext-artist-does-not-exist"
|
||||||
|
|||||||
@@ -80,6 +80,23 @@ class DTextTest < ActiveSupport::TestCase
|
|||||||
assert_match(/implication ##{@ti.id}/, DText.format_text("[ti:#{@ti.id}]"))
|
assert_match(/implication ##{@ti.id}/, DText.format_text("[ti:#{@ti.id}]"))
|
||||||
assert_match(/alias ##{@ta.id}/, DText.format_text("[ta:#{@ta.id}]"))
|
assert_match(/alias ##{@ta.id}/, DText.format_text("[ta:#{@ta.id}]"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "link artist tags to the artist page instead of the wiki page" do
|
||||||
|
tag = create(:tag, name: "m&m", category: Tag.categories.artist)
|
||||||
|
artist = create(:artist, name: "m&m")
|
||||||
|
|
||||||
|
assert_equal(
|
||||||
|
'<p><a class="dtext-link dtext-wiki-link tag-type-1" href="/artists/show_or_new?name=m%26m">m&m</a></p>',
|
||||||
|
DText.format_text("[[m&m]]")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not link general tags to artist pages" do
|
||||||
|
tag = create(:tag, name: "cat")
|
||||||
|
artist = create(:artist, name: "cat", is_active: false)
|
||||||
|
|
||||||
|
assert_match(%r!/wiki_pages/cat!, DText.format_text("[[cat]]"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#parse_wiki_titles" do
|
context "#parse_wiki_titles" do
|
||||||
|
|||||||
Reference in New Issue
Block a user