add user option for disabling tagged filenames
This commit is contained in:
@@ -249,6 +249,10 @@ class AnonymousUser
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disable_tagged_filenames?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
%w(member banned gold builder platinum janitor moderator admin).each do |name|
|
%w(member banned gold builder platinum janitor moderator admin).each do |name|
|
||||||
define_method("is_#{name}?") do
|
define_method("is_#{name}?") do
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -99,27 +99,25 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def file_url
|
def file_url
|
||||||
if Danbooru.config.enable_seo_post_urls
|
"/data/#{seo_tag_string}#{file_path_prefix}#{md5}.#{file_ext}"
|
||||||
# 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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def large_file_url
|
def large_file_url
|
||||||
if has_large?
|
if has_large?
|
||||||
if Danbooru.config.enable_seo_post_urls
|
"/data/sample/#{seo_tag_string}#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}"
|
||||||
# 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
|
|
||||||
else
|
else
|
||||||
file_url
|
file_url
|
||||||
end
|
end
|
||||||
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
|
def seo_tags
|
||||||
@seo_tags ||= humanized_essential_tag_string.gsub(/[^a-z0-9]+/, "-").gsub(/(?:^-+)|(?:-+$)/, "").gsub(/-{2,}/, "-")
|
@seo_tags ||= humanized_essential_tag_string.gsub(/[^a-z0-9]+/, "-").gsub(/(?:^-+)|(?:-+$)/, "").gsub(/-{2,}/, "-")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,13 +34,14 @@ class User < ActiveRecord::Base
|
|||||||
can_upload_free
|
can_upload_free
|
||||||
disable_categorized_saved_searches
|
disable_categorized_saved_searches
|
||||||
is_super_voter
|
is_super_voter
|
||||||
|
disable_tagged_filenames
|
||||||
)
|
)
|
||||||
|
|
||||||
include Danbooru::HasBitFlags
|
include Danbooru::HasBitFlags
|
||||||
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
|
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
|
||||||
|
|
||||||
attr_accessor :password, :old_password
|
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
|
attr_accessible :level, :as => :admin
|
||||||
validates_length_of :name, :within => 2..100, :on => :create
|
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"
|
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
||||||
|
|||||||
@@ -72,6 +72,8 @@
|
|||||||
|
|
||||||
<%= f.input :enable_privacy_mode, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
|
<%= 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 %>
|
||||||
|
|
||||||
<div class="input text optional field_with_hint">
|
<div class="input text optional field_with_hint">
|
||||||
<label class="text optional" for="user_favorite_tags">Frequent tags</label>
|
<label class="text optional" for="user_favorite_tags">Frequent tags</label>
|
||||||
<textarea id="user_favorite_tags" class="text optional" rows="5" name="user[favorite_tags]" cols="40"><%= raw @user.favorite_tags %></textarea>
|
<textarea id="user_favorite_tags" class="text optional" rows="5" name="user[favorite_tags]" cols="40"><%= raw @user.favorite_tags %></textarea>
|
||||||
|
|||||||
Reference in New Issue
Block a user