fixed pixiv tests, added metatag support when tagging fixes #23: Unable to add to pool using "pool:XXX" syntax

This commit is contained in:
albert
2011-09-13 19:08:39 -04:00
parent 13995cfd39
commit c818f2c114
3 changed files with 104 additions and 10 deletions

View File

@@ -414,7 +414,32 @@ class Post < ActiveRecord::Base
end
def filter_metatags(tags)
tags.reject {|tag| tag =~ /\A(?:pool|rating|fav):/}
metatags, tags = tags.partition {|x| x =~ /\A(?:pool|rating|fav):/}
apply_metatags(metatags)
return tags
end
def apply_metatags(tags)
tags.each do |tag|
case tag
when /^pool:(\d+)$/
pool = Pool.find_by_id($1.to_i)
add_pool!(pool) if pool
when /^pool:(.+)$/
pool = Pool.find_by_name($1)
if pool.nil?
pool = Pool.create(:name => $1, :description => "This pool was automatically generated")
end
add_pool!(pool)
when /^rating:([qse])/i
self.rating = $1.downcase
when /^fav:(.+)$/
add_favorite!(CurrentUser.user)
end
end
end
def has_tag?(tag)