Merge pull request #2679 from r888888888/quoted_source
Allow quoted source: metatag, allow source: metatag when editing posts
This commit is contained in:
@@ -674,7 +674,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def filter_metatags(tags)
|
||||
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent|-parent):/i}
|
||||
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent|-parent|source):/i}
|
||||
@post_metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|newpool|fav|-fav|child|-favgroup|favgroup):/i}
|
||||
apply_pre_metatags
|
||||
return tags
|
||||
@@ -757,6 +757,15 @@ class Post < ActiveRecord::Base
|
||||
remove_parent_loops
|
||||
end
|
||||
|
||||
when /^source:none$/i
|
||||
self.source = nil
|
||||
|
||||
when /^source:"(.*)"$/i
|
||||
self.source = $1
|
||||
|
||||
when /^source:(.*)$/i
|
||||
self.source = $1
|
||||
|
||||
when /^rating:([qse])/i
|
||||
unless is_rating_locked?
|
||||
self.rating = $1.downcase
|
||||
|
||||
@@ -231,11 +231,15 @@ class Tag < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def scan_query(query)
|
||||
normalize(query).scan(/\S+/).uniq
|
||||
tagstr = normalize(query)
|
||||
list = tagstr.scan(/-?source:".*?"/) || []
|
||||
list + tagstr.gsub(/-?source:".*?"/, "").scan(/\S+/).uniq
|
||||
end
|
||||
|
||||
def scan_tags(tags)
|
||||
normalize(tags).gsub(/[%,]/, "").scan(/\S+/).uniq
|
||||
tagstr = normalize(tags)
|
||||
list = tagstr.scan(/source:".*?"/) || []
|
||||
list + tagstr.gsub(/source:".*?"/, "").gsub(/[%,]/, "").scan(/\S+/).uniq
|
||||
end
|
||||
|
||||
def parse_cast(object, type)
|
||||
@@ -547,10 +551,12 @@ class Tag < ActiveRecord::Base
|
||||
q[:filesize] = parse_helper_fudged($2, :filesize)
|
||||
|
||||
when "source"
|
||||
q[:source] = ($2.to_escaped_for_sql_like + "%").gsub(/%+/, '%')
|
||||
src = $2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
q[:source] = (src.to_escaped_for_sql_like + "%").gsub(/%+/, '%')
|
||||
|
||||
when "-source"
|
||||
q[:source_neg] = ($2.to_escaped_for_sql_like + "%").gsub(/%+/, '%')
|
||||
src = $2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
q[:source_neg] = (src.to_escaped_for_sql_like + "%").gsub(/%+/, '%')
|
||||
|
||||
when "date"
|
||||
q[:date] = parse_helper($2, :date)
|
||||
|
||||
Reference in New Issue
Block a user