From 9621ec7dac399f6a1313d3af7570442b88b2a187 Mon Sep 17 00:00:00 2001 From: Toks Date: Mon, 16 Jun 2014 14:20:28 -0400 Subject: [PATCH] Support translating Pixiv "x users iri" tags --- app/logical/sources/site.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/logical/sources/site.rb b/app/logical/sources/site.rb index 24d94fe02..824a77025 100644 --- a/app/logical/sources/site.rb +++ b/app/logical/sources/site.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + module Sources class Site attr_reader :url, :strategy @@ -19,7 +21,16 @@ module Sources end def translated_tags - WikiPage.other_names_match(tags.map(&:first)).map{|wiki_page| [wiki_page.title, wiki_page.category_name]} + untranslated_tags = tags + untranslated_tags = untranslated_tags.map(&:first) + untranslated_tags = untranslated_tags.map do |tag| + if tag =~ /\A(\S+?)_?\d+users入り\Z/ + $1 + else + tag + end + end + WikiPage.other_names_match(untranslated_tags).map{|wiki_page| [wiki_page.title, wiki_page.category_name]} end def to_json