eBooru/config/danbooru_default_config.rb

305 lines
6.3 KiB
Ruby
Raw Normal View History

require 'socket'
2010-02-06 16:48:40 -05:00
module Danbooru
class Configuration
# The version of this Danbooru.
def version
2014-03-17 16:27:57 -04:00
"2.45.0"
2010-02-06 16:48:40 -05:00
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# The name of this Danbooru.
def app_name
"Danbooru"
end
2013-03-19 08:10:10 -04:00
# The hostname of the server.
def hostname
Socket.gethostname
end
2013-03-19 08:10:10 -04:00
2010-02-20 18:08:22 -05:00
# Contact email address of the admin.
def contact_email
2011-08-07 15:44:54 -04:00
"webmaster@#{server_host}"
2010-02-20 18:08:22 -05:00
end
2013-03-19 08:10:10 -04:00
2011-12-02 16:46:37 -05:00
def upgrade_account_email
contact_email
end
2013-03-19 08:10:10 -04:00
2010-02-08 01:40:39 -05:00
# Stripped of any special characters.
def safe_app_name
app_name.gsub(/[^a-zA-Z0-9_-]/, "_")
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# The default name to use for anyone who isn't logged in.
def default_guest_name
"Anonymous"
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# This is a salt used to make dictionary attacks on account passwords harder.
def password_salt
"choujin-steiner"
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# Set to true to allow new account signups.
def enable_signups?
true
end
2013-03-19 08:10:10 -04:00
# Set to true to give all new users gold access.
def start_as_gold?
2010-02-06 16:48:40 -05:00
false
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# Set to true to give all new users contributor access.
def start_as_contributor?
false
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# What method to use to store images.
# local_flat: Store every image in one directory.
# local_hierarchy: Store every image in a hierarchical directory, based on the post's MD5 hash. On some file systems this may be faster.
def image_store
:local_flat
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# Thumbnail size
def small_image_width
150
end
2013-03-19 08:10:10 -04:00
2010-02-08 01:40:39 -05:00
# Large resize image width. Set to nil to disable.
2010-02-06 16:48:40 -05:00
def large_image_width
2013-01-06 14:54:01 -05:00
850
2010-02-06 16:48:40 -05:00
end
2013-03-19 08:10:10 -04:00
def large_image_prefix
"sample-"
end
2013-03-19 08:10:10 -04:00
2010-02-06 23:11:26 -05:00
# When calculating statistics based on the posts table, gather this many posts to sample from.
def post_sample_size
300
end
2013-03-19 08:10:10 -04:00
2013-01-06 14:05:54 -05:00
# Where the ad banners are stored in the file system
def advertisement_path
nil
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# List of memcached servers
def memcached_servers
%w(localhost:11211)
2010-02-06 16:48:40 -05:00
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# After a post receives this many comments, new comments will no longer bump the post in comment/index.
def comment_threshold
40
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# Members cannot post more than X comments in an hour.
def member_comment_limit
2
end
# Determines who can see ads.
def can_see_ads?(user)
!user.is_gold?
2010-02-06 16:48:40 -05:00
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# Users cannot search for more than X regular tags at a time.
def base_tag_query_limit
2010-02-06 16:48:40 -05:00
6
end
2013-03-19 08:10:10 -04:00
def tag_query_limit
if CurrentUser.user.present?
CurrentUser.user.tag_query_limit
else
base_tag_query_limit * 2
end
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# Max number of posts to cache
def tag_subscription_post_limit
200
end
2013-03-19 08:10:10 -04:00
2011-06-24 18:22:54 -04:00
# After this many pages, the paginator will switch to sequential mode.
def max_numbered_pages
2013-02-23 15:58:21 -05:00
1_000
2011-06-24 18:22:54 -04:00
end
2013-03-19 08:10:10 -04:00
2010-02-06 16:48:40 -05:00
# Max number of tag subscriptions per user
def max_tag_subscriptions
5
end
2013-03-19 08:10:10 -04:00
2010-02-08 01:40:39 -05:00
# Maximum size of an upload.
def max_file_size
2013-03-05 16:56:10 -05:00
25.megabytes
2010-02-08 01:40:39 -05:00
end
2013-03-19 08:10:10 -04:00
2011-12-14 11:19:58 -05:00
def member_comment_time_threshold
1.week.ago
end
2013-03-19 08:10:10 -04:00
2010-02-06 23:11:26 -05:00
# The name of the server the app is hosted on.
2010-02-06 16:48:40 -05:00
def server_host
Socket.gethostname
end
2013-03-19 08:10:10 -04:00
2010-10-08 18:42:26 -04:00
# Names of all Danbooru servers which serve out of the same common database.
2010-02-08 01:40:39 -05:00
# Used in conjunction with load balancing to distribute files from one server to
# the others. This should match whatever gethostname returns on the other servers.
2010-10-08 18:42:26 -04:00
def all_server_hosts
[server_host]
2010-02-08 01:40:39 -05:00
end
2013-03-19 08:10:10 -04:00
2010-10-08 18:42:26 -04:00
# Names of other Danbooru servers.
def other_server_hosts
2013-03-03 01:12:31 -05:00
@other_server_hosts ||= all_server_hosts.reject {|x| x == server_host}
2010-10-08 18:42:26 -04:00
end
def remote_server_login
"albert"
end
2013-03-19 08:10:10 -04:00
2010-02-06 23:11:26 -05:00
# Returns a hash mapping various tag categories to a numerical value.
# Be sure to update the reverse_tag_category_mapping also.
def tag_category_mapping
@tag_category_mapping ||= {
"general" => 0,
"gen" => 0,
"artist" => 1,
"art" => 1,
"copyright" => 3,
"copy" => 3,
"co" => 3,
"character" => 4,
"char" => 4,
"ch" => 4
}
end
2013-03-19 08:10:10 -04:00
2011-07-17 19:05:31 -04:00
def canonical_tag_category_mapping
@canonical_tag_category_mapping ||= {
"General" => 0,
"Artist" => 1,
2013-02-18 20:50:38 -05:00
"Copyright" => 3,
"Character" => 4
2011-07-17 19:05:31 -04:00
}
end
2013-03-19 08:10:10 -04:00
2010-02-06 23:11:26 -05:00
# Returns a hash maping numerical category values to their
# string equivalent. Be sure to update the tag_category_mapping also.
def reverse_tag_category_mapping
@reverse_tag_category_mapping ||= {
0 => "General",
1 => "Artist",
3 => "Copyright",
4 => "Character"
}
end
2013-03-19 08:10:10 -04:00
2010-03-11 19:42:04 -05:00
# If enabled, users must verify their email addresses.
def enable_email_verification?
false
2010-03-11 19:42:04 -05:00
end
2013-03-19 08:10:10 -04:00
# Any custom code you want to insert into the default layout without
# having to modify the templates.
def custom_html_header_content
nil
end
2013-03-19 08:10:10 -04:00
2010-03-17 19:20:44 -04:00
# The number of posts displayed per page.
def posts_per_page
20
end
2010-10-08 18:42:26 -04:00
def is_post_restricted?(post)
false
2010-10-08 18:42:26 -04:00
end
2013-03-19 08:10:10 -04:00
2010-10-08 18:42:26 -04:00
def is_user_restricted?(user)
!user.is_gold?
2010-10-08 18:42:26 -04:00
end
2013-03-19 08:10:10 -04:00
def is_user_advertiser?(user)
user.is_admin?
end
2013-03-19 08:10:10 -04:00
2010-10-08 18:42:26 -04:00
def can_user_see_post?(user, post)
if is_user_restricted?(user) && is_post_restricted?(post)
false
else
true
end
end
2013-03-19 08:10:10 -04:00
2010-10-08 18:42:26 -04:00
def select_posts_visible_to_user(user, posts)
2011-11-11 17:50:26 -05:00
posts.select {|x| can_user_see_post?(user, x)}
2010-10-08 18:42:26 -04:00
end
2013-03-19 08:10:10 -04:00
2011-12-22 18:22:32 -05:00
def max_appeals_per_day
1
end
2013-03-19 08:10:10 -04:00
2013-01-10 17:45:52 -05:00
# Counting every post is typically expensive because it involves a sequential scan on
# potentially millions of rows. If this method returns a value, then blank searches
# will return that number for the fast_count call instead.
def blank_tag_search_fast_count
nil
end
2013-03-19 08:10:10 -04:00
2011-09-26 17:32:52 -04:00
def pixiv_login
nil
end
2013-03-19 08:10:10 -04:00
2011-09-26 17:32:52 -04:00
def pixiv_password
nil
end
2013-03-19 08:10:10 -04:00
2011-09-26 17:32:52 -04:00
def tinami_login
nil
end
2013-03-19 08:10:10 -04:00
2011-09-26 17:32:52 -04:00
def tinami_password
nil
end
2013-03-19 08:10:10 -04:00
2011-09-28 18:46:28 -04:00
def nico_seiga_login
nil
end
2013-03-19 08:10:10 -04:00
2011-09-28 18:46:28 -04:00
def nico_seiga_password
nil
end
2013-03-19 08:10:10 -04:00
2011-09-29 11:34:31 -04:00
def pixa_login
nil
end
2013-03-19 08:10:10 -04:00
2011-09-29 11:34:31 -04:00
def pixa_password
nil
end
2013-03-19 08:10:10 -04:00
2013-03-08 17:41:40 -05:00
def amazon_ses
2013-03-08 17:49:50 -05:00
# {:smtp_server_name => "smtp server", :user_name => "user name", :ses_smtp_user_name => "smtp user name", :ses_smtp_password => "smtp password"}
2013-03-08 17:41:40 -05:00
nil
end
2013-03-19 08:10:10 -04:00
def amazon_s3_bucket_name
"danbooru"
end
2013-03-12 17:01:52 -04:00
def enable_dimension_autotagging
true
end
2010-02-06 16:48:40 -05:00
end
end