Add cosplay related tags for other wikis
- Queries on *_(cosplay) tags will now also display the base tag. - Also fixes an issue with list_of_* related wikis. -- The request errors out if the list_of_* wiki doesn't actually exist.
This commit is contained in:
@@ -46,10 +46,29 @@ class RelatedTagQuery
|
||||
end
|
||||
|
||||
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)
|
||||
other_wikis = other_wikis.map { |name| WikiPage.titled(name).first }
|
||||
def copyright_other_wiki_pages
|
||||
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
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user