add user option for disabling tagged filenames

This commit is contained in:
r888888888
2016-05-26 10:12:03 -07:00
parent ba65ec3e18
commit bdd408952b
4 changed files with 18 additions and 13 deletions

View File

@@ -99,27 +99,25 @@ class Post < ActiveRecord::Base
end
def file_url
if Danbooru.config.enable_seo_post_urls
# the seo tags should be stripped out by nginx
"/data/--#{seo_tags}--#{file_path_prefix}#{md5}.#{file_ext}"
else
"/data/#{file_path_prefix}#{md5}.#{file_ext}"
end
"/data/#{seo_tag_string}#{file_path_prefix}#{md5}.#{file_ext}"
end
def large_file_url
if has_large?
if Danbooru.config.enable_seo_post_urls
# the seo tags should be stripped out by nginx
"/data/sample/--#{seo_tags}--#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}"
else
"/data/sample/#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}"
end
"/data/sample/#{seo_tag_string}#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}"
else
file_url
end
end
def seo_tag_string
if Danbooru.config.enable_seo_post_urls && !CurrentUser.user.disable_tagged_filenames?
"--#{seo_tags}--"
else
nil
end
end
def seo_tags
@seo_tags ||= humanized_essential_tag_string.gsub(/[^a-z0-9]+/, "-").gsub(/(?:^-+)|(?:-+$)/, "").gsub(/-{2,}/, "-")
end