diff --git a/app/logical/anonymous_user.rb b/app/logical/anonymous_user.rb index 602da6f22..41b52f015 100644 --- a/app/logical/anonymous_user.rb +++ b/app/logical/anonymous_user.rb @@ -249,6 +249,10 @@ class AnonymousUser false end + def disable_tagged_filenames? + false + end + %w(member banned gold builder platinum janitor moderator admin).each do |name| define_method("is_#{name}?") do false diff --git a/app/models/post.rb b/app/models/post.rb index 45edbbc64..0e02acc33 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 010fb75c3..3c999f26d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -34,13 +34,14 @@ class User < ActiveRecord::Base can_upload_free disable_categorized_saved_searches is_super_voter + disable_tagged_filenames ) include Danbooru::HasBitFlags has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs" attr_accessor :password, :old_password - attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin] + attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin] attr_accessible :level, :as => :admin validates_length_of :name, :within => 2..100, :on => :create validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons" diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 43b674254..87dc16087 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -72,6 +72,8 @@ <%= f.input :enable_privacy_mode, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %> + <%= f.input :disable_tagged_filenames, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %> +