Merge pull request #4297 from BrokenEagle/add-cosplay-related-tags
Add cosplay related tags for other wikis
This commit is contained in:
@@ -46,10 +46,29 @@ class RelatedTagQuery
|
|||||||
end
|
end
|
||||||
|
|
||||||
def other_wiki_pages
|
def other_wiki_pages
|
||||||
return [] unless Tag.category_for(query) == Tag.categories.copyright
|
if Tag.category_for(query) == Tag.categories.copyright
|
||||||
|
copyright_other_wiki_pages
|
||||||
|
elsif Tag.category_for(query) == Tag.categories.general
|
||||||
|
general_other_wiki_pages
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
other_wikis = DText.parse_wiki_titles(wiki_page&.body&.to_s).grep(/\Alist_of_/i)
|
def copyright_other_wiki_pages
|
||||||
other_wikis = other_wikis.map { |name| WikiPage.titled(name).first }
|
list_of_wikis = DText.parse_wiki_titles(wiki_page&.body&.to_s).grep(/\Alist_of_/i)
|
||||||
|
map_tags_to_wikis(list_of_wikis)
|
||||||
|
end
|
||||||
|
|
||||||
|
def general_other_wiki_pages
|
||||||
|
match = query.match(/(.+?)_\(cosplay\)/)
|
||||||
|
return [] unless match
|
||||||
|
map_tags_to_wikis([match[1]])
|
||||||
|
end
|
||||||
|
|
||||||
|
def map_tags_to_wikis(other_tags)
|
||||||
|
other_wikis = other_tags.map { |name| WikiPage.titled(name).first }
|
||||||
|
other_wikis = other_wikis.reject { |wiki| wiki.nil? }
|
||||||
other_wikis = other_wikis.select { |wiki| wiki.tags.present? }
|
other_wikis = other_wikis.select { |wiki| wiki.tags.present? }
|
||||||
other_wikis
|
other_wikis
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user