Move case sensitive metatags to before downcase
This commit is contained in:
@@ -683,6 +683,7 @@ 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 = apply_casesensitive_metatags(normalized_tags)
|
||||||
normalized_tags = normalized_tags.map {|tag| tag.downcase}
|
normalized_tags = normalized_tags.map {|tag| tag.downcase}
|
||||||
normalized_tags = filter_metatags(normalized_tags)
|
normalized_tags = filter_metatags(normalized_tags)
|
||||||
normalized_tags = remove_negated_tags(normalized_tags)
|
normalized_tags = remove_negated_tags(normalized_tags)
|
||||||
@@ -763,10 +764,34 @@ class Post < ApplicationRecord
|
|||||||
return tags
|
return tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apply_casesensitive_metatags(tags)
|
||||||
|
casesensitive_metatags, tags = tags.partition {|x| x =~ /\A(?:source|newpool):/i}
|
||||||
|
if casesensitive_metatags.length > 0
|
||||||
|
case casesensitive_metatags[-1]
|
||||||
|
when /^source:none$/i
|
||||||
|
self.source = ""
|
||||||
|
|
||||||
|
when /^source:"(.*)"$/i
|
||||||
|
self.source = $1
|
||||||
|
|
||||||
|
when /^source:(.*)$/i
|
||||||
|
self.source = $1
|
||||||
|
|
||||||
|
when /^newpool:(.+)$/i
|
||||||
|
pool = Pool.find_by_name($1)
|
||||||
|
if pool.nil?
|
||||||
|
pool = Pool.create(:name => $1, :description => "This pool was automatically generated")
|
||||||
|
end
|
||||||
|
add_pool!(pool) if pool
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return tags
|
||||||
|
end
|
||||||
|
|
||||||
def filter_metatags(tags)
|
def filter_metatags(tags)
|
||||||
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent|-parent|source|-?locked):/i}
|
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent|-parent|-?locked):/i}
|
||||||
tags = apply_categorization_metatags(tags)
|
tags = apply_categorization_metatags(tags)
|
||||||
@post_metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|newpool|fav|-fav|child|-favgroup|favgroup|upvote|downvote):/i}
|
@post_metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|fav|-fav|child|-favgroup|favgroup|upvote|downvote):/i}
|
||||||
apply_pre_metatags
|
apply_pre_metatags
|
||||||
return tags
|
return tags
|
||||||
end
|
end
|
||||||
@@ -803,13 +828,6 @@ class Post < ApplicationRecord
|
|||||||
pool = Pool.find_by_name($1)
|
pool = Pool.find_by_name($1)
|
||||||
add_pool!(pool) if pool
|
add_pool!(pool) if pool
|
||||||
|
|
||||||
when /^newpool:(.+)$/i
|
|
||||||
pool = Pool.find_by_name($1)
|
|
||||||
if pool.nil?
|
|
||||||
pool = Pool.create(:name => $1, :description => "This pool was automatically generated")
|
|
||||||
end
|
|
||||||
add_pool!(pool) if pool
|
|
||||||
|
|
||||||
when /^fav:(.+)$/i
|
when /^fav:(.+)$/i
|
||||||
add_favorite!(CurrentUser.user)
|
add_favorite!(CurrentUser.user)
|
||||||
|
|
||||||
@@ -863,17 +881,8 @@ class Post < ApplicationRecord
|
|||||||
remove_parent_loops
|
remove_parent_loops
|
||||||
end
|
end
|
||||||
|
|
||||||
when /^source:none$/i
|
|
||||||
self.source = ""
|
|
||||||
|
|
||||||
when /^source:"(.*)"$/i
|
|
||||||
self.source = $1
|
|
||||||
|
|
||||||
when /^source:(.*)$/i
|
|
||||||
self.source = $1
|
|
||||||
|
|
||||||
when /^rating:([qse])/i
|
when /^rating:([qse])/i
|
||||||
self.rating = $1.downcase
|
self.rating = $1
|
||||||
|
|
||||||
when /^(-?)locked:notes?$/i
|
when /^(-?)locked:notes?$/i
|
||||||
assign_attributes({ is_note_locked: $1 != "-" }, as: CurrentUser.role)
|
assign_attributes({ is_note_locked: $1 != "-" }, as: CurrentUser.role)
|
||||||
|
|||||||
Reference in New Issue
Block a user