fixes #3307
This commit is contained in:
@@ -684,13 +684,12 @@ class Post < ApplicationRecord
|
|||||||
def normalize_tags
|
def normalize_tags
|
||||||
normalized_tags = Tag.scan_tags(tag_string)
|
normalized_tags = Tag.scan_tags(tag_string)
|
||||||
normalized_tags = filter_metatags(normalized_tags)
|
normalized_tags = filter_metatags(normalized_tags)
|
||||||
normalized_tags = normalized_tags.map{|tag| tag.downcase}
|
normalized_tags = normalized_tags.map {|tag| tag.downcase}
|
||||||
normalized_tags = remove_negated_tags(normalized_tags)
|
normalized_tags = remove_negated_tags(normalized_tags)
|
||||||
normalized_tags = normalized_tags.map {|x| Tag.find_or_create_by_name(x).name}
|
|
||||||
normalized_tags = %w(tagme) if normalized_tags.empty?
|
normalized_tags = %w(tagme) if normalized_tags.empty?
|
||||||
normalized_tags = TagAlias.to_aliased(normalized_tags)
|
normalized_tags = TagAlias.to_aliased(normalized_tags)
|
||||||
normalized_tags = add_automatic_tags(normalized_tags)
|
normalized_tags = Tag.create_for_list(add_automatic_tags(normalized_tags))
|
||||||
normalized_tags = normalized_tags + TagImplication.automatic_tags_for(normalized_tags)
|
normalized_tags = normalized_tags + Tag.create_for_list(TagImplication.automatic_tags_for(normalized_tags))
|
||||||
normalized_tags = TagImplication.with_descendants(normalized_tags)
|
normalized_tags = TagImplication.with_descendants(normalized_tags)
|
||||||
normalized_tags = normalized_tags.compact
|
normalized_tags = normalized_tags.compact
|
||||||
normalized_tags.sort!
|
normalized_tags.sort!
|
||||||
|
|||||||
@@ -194,6 +194,10 @@ class Tag < ApplicationRecord
|
|||||||
name.to_s.mb_chars.downcase.strip.tr(" ", "_").to_s
|
name.to_s.mb_chars.downcase.strip.tr(" ", "_").to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_for_list(names)
|
||||||
|
names.map {|x| find_or_create_by_name(x).name}
|
||||||
|
end
|
||||||
|
|
||||||
def find_or_create_by_name(name, options = {})
|
def find_or_create_by_name(name, options = {})
|
||||||
name = normalize_name(name)
|
name = normalize_name(name)
|
||||||
category = nil
|
category = nil
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class TagImplication < TagRelationship
|
|||||||
end
|
end
|
||||||
|
|
||||||
def automatic_tags_for(names)
|
def automatic_tags_for(names)
|
||||||
tags = names.grep(/\A(.+)_\(cosplay\)\Z/) { $1 }
|
tags = names.grep(/\A(.+)_\(cosplay\)\Z/) { "char:#{$1}" }
|
||||||
tags << "cosplay" if tags.present?
|
tags << "cosplay" if tags.present?
|
||||||
tags.uniq
|
tags.uniq
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user