Skip to content

Commit

Permalink
config: refactor remove_tag_after_replacement? config option.
Browse files Browse the repository at this point in the history
  • Loading branch information
evazion committed Jun 2, 2020
1 parent 47e6821 commit 276f23b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/models/post_replacement.rb
Expand Up @@ -29,7 +29,12 @@ def search(params = {})
end

def suggested_tags_for_removal
tags = post.tag_array.select { |tag| Danbooru.config.remove_tag_after_replacement?(tag) }
tags = post.tag_array.select do |tag|
Danbooru.config.post_replacement_tag_removals.any? do |pattern|
tag.match?(/\A#{pattern}\z/i)
end
end

tags = tags.map { |tag| "-#{tag}" }
tags.join(" ")
end
Expand Down
7 changes: 4 additions & 3 deletions config/danbooru_default_config.rb
Expand Up @@ -321,9 +321,10 @@ def tumblr_consumer_key
nil
end

# Should return true if the given tag should be suggested for removal in the post replacement dialog box.
def remove_tag_after_replacement?(tag)
tag =~ /\A(?:replaceme|.*_sample|resized|upscaled|downscaled|md5_mismatch|jpeg_artifacts|corrupted_image|source_request|non-web_source)\z/i
# A list of tags that should be removed when a post is replaced. Regexes allowed.
def post_replacement_tag_removals
%w[replaceme .*_sample resized upscaled downscaled md5_mismatch
jpeg_artifacts corrupted_image source_request non-web_source]
end

# Posts with these tags will be highlighted in the modqueue.
Expand Down

0 comments on commit 276f23b

Please sign in to comment.