Merge pull request #3434 from BrokenEagle/feat-copyright-other-wikis

Add character list wikis to copyright related tag response
This commit is contained in:
Albert Yi
2017-12-19 11:37:46 -08:00
committed by GitHub
2 changed files with 19 additions and 1 deletions

View File

@@ -26,12 +26,26 @@ class RelatedTagQuery
results
end
def other_wiki_category_tags
if Tag.category_for(query) != Tag.categories.copyright
return []
end
listtags = (wiki_page.try(:tags) || []).select {|name| name =~ /^list_of_/i }
results = listtags.map do |name|
listlinks = WikiPage.titled(name).first.try(:tags) || []
if listlinks.length > 0
{"title" => name, "wiki_page_tags" => map_with_category_data(listlinks)}
end
end
results.reject {|list| list.nil?}
end
def tags_for_html
map_with_category_data(tags)
end
def to_json
{:query => query, :category => category, :tags => map_with_category_data(tags), :wiki_page_tags => map_with_category_data(wiki_page_tags)}.to_json
{:query => query, :category => category, :tags => map_with_category_data(tags), :wiki_page_tags => map_with_category_data(wiki_page_tags), :other_wikis => other_wiki_category_tags}.to_json
end
protected