eBooru/config/danbooru_default_config.rb

701 lines
16 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
2016-08-11 17:16:19 -04:00
"2.105.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
2014-10-28 14:05:21 -04:00
if CurrentUser.safe_mode?
"Safebooru"
else
"Danbooru"
end
2010-02-06 16:48:40 -05:00
end
2013-03-19 08:10:10 -04:00
def description
"Find good anime art fast"
end
# The canonical hostname of the site.
def hostname
Socket.gethostname
end
2013-03-19 08:10:10 -04:00
# The list of all domain names this site is accessible under.
# Example: %w[danbooru.donmai.us sonohara.donmai.us hijiribe.donmai.us safebooru.donmai.us]
def hostnames
[hostname]
end
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
# System actions, such as sending automated dmails, will be performed with
# this account. This account must have Moderator privileges.
#
# Run `rake db:seed` to create this account if it doesn't already exist in your install.
def system_user
"DanbooruBot"
end
def upload_feedback_topic
ForumTopic.where(title: "Upload Feedback Thread").first
end
2011-12-02 16:46:37 -05:00
def upgrade_account_email
contact_email
end
2013-03-19 08:10:10 -04:00
def source_code_url
"https://github.com/r888888888/danbooru"
end
def commit_url(hash)
"#{source_code_url}/commit/#{hash}"
end
def releases_url
"#{source_code_url}/releases"
end
def issues_url
"#{source_code_url}/issues"
end
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
# Set the default level, permissions, and other settings for new users here.
def customize_new_user(user)
# user.level = User::Levels::MEMBER
# user.can_approve_posts = false
# user.can_upload_free = false
# user.is_super_voter = false
#
# user.base_upload_limit = 10
# user.comment_threshold = -1
# user.blacklisted_tags = ["spoilers", "guro", "scat", "furry -rating:s"].join("\n")
# user.default_image_size = "large"
# user.per_page = 20
# user.disable_tagged_filenames = false
true
2010-02-06 16:48:40 -05:00
end
2013-03-19 08:10:10 -04:00
# What method to use to backup images.
#
# NullBackupService: Don't backup images at all.
#
# S3BackupService: Backup to Amazon S3. Must configure aws_access_key_id,
# aws_secret_access_key, and aws_s3_bucket_name. Bucket must exist and be writable.
2017-05-05 22:45:14 -04:00
def backup_service
if Rails.env.production?
S3BackupService.new
else
NullBackupService.new
end
2017-05-05 22:45:14 -04:00
end
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
2010-02-06 16:48:40 -05:00
# List of memcached servers
def memcached_servers
2016-10-17 18:53:37 -04:00
%w(127.0.0.1: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
# Whether safe mode should be enabled. Safe mode hides all non-rating:safe posts from view.
def enable_safe_mode?(request, user)
!!(request.host =~ /safe/ || request.params[:safe_mode] || user.enable_safe_mode?)
end
2010-02-06 16:48:40 -05:00
# 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
# Return true if the given tag shouldn't count against the user's tag search limit.
def is_unlimited_tag?(tag)
!!(tag =~ /\A(-?status:deleted|rating:s.*|limit:.+)\z/i)
end
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-08 01:40:39 -05:00
# Maximum size of an upload.
def max_file_size
35.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
#TAG CONFIGURATION
#Full tag configuration info for all tags
def full_tag_config_info
@full_tag_category_mapping ||= {
"general" => {
"category" => 0,
"short" => "gen",
"extra" => [],
"header" => %{<h1 class="general-tag-list">Tags</h1>},
"humanized" => nil,
"relatedbutton" => "General",
"css" => {
"color" => "$link_color",
"hover" => "$link_hover_color"
}
},
"character" => {
"category" => 4,
"short" => "char",
"extra" => ["ch"],
"header" => %{<h2 class="character-tag-list">Characters</h2>},
"humanized" => {
"slice" => 5,
"exclusion" => [],
"regexmap" => /^(.+?)(?:_\(.+\))?$/,
"formatstr" => "%s"
},
"relatedbutton" => "Characters",
"css" => {
"color" => "#0A0",
"hover" => "#6B6"
}
},
"copyright" => {
"category" => 3,
"short" => "copy",
"extra" => ["co"],
"header" => %{<h2 class="copyright-tag-list">Copyrights</h2>},
"humanized" => {
"slice" => 5,
"exclusion" => [],
"regexmap" => //,
"formatstr" => "(%s)"
},
"relatedbutton" => "Copyrights",
"css" => {
"color" => "#A0A",
"hover" => "#B6B"
}
},
"artist" => {
"category" => 1,
"short" => "art",
"extra" => [],
"header" => %{<h2 class="artist-tag-list">Artists</h2>},
"humanized" => {
"slice" => 0,
"exclusion" => %w(banned_artist),
"regexmap" => //,
"formatstr" => "drawn by %s"
},
"relatedbutton" => "Artists",
"css" => {
"color" => "#A00",
"hover" => "#B66"
}
2017-11-06 18:03:45 -05:00
},
"meta" => {
"category" => 5,
"short" => "meta",
"extra" => [],
"header" => %{<h2 class="meta-tag-list">Meta</h2>},
2017-11-06 18:03:45 -05:00
"humanized" => nil,
"relatedbutton" => nil,
"css" => {
"color" => "#F80",
"hover" => "#FA6"
}
}
}
end
#TAG ORDERS
#Sets the order of the humanized essential tag string (models/post.rb)
def humanized_tag_category_list
@humanized_tag_category_list ||= ["character","copyright","artist"]
end
#Sets the order of the split tag header list (presenters/tag_set_presenter.rb)
def split_tag_header_list
2017-11-06 18:03:45 -05:00
@split_tag_header_list ||= ["copyright","character","artist","general","meta"]
end
#Sets the order of the categorized tag string (presenters/post_presenter.rb)
def categorized_tag_list
2017-11-06 18:03:45 -05:00
@categorized_tag_list ||= ["copyright","character","artist","meta","general"]
end
#Sets the order of the related tag buttons (javascripts/related_tag.js)
def related_tag_button_list
@related_tag_button_list ||= ["general","artist","character","copyright"]
end
#END TAG
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
def upload_notice_wiki_page
"help:upload_notice"
end
def flag_notice_wiki_page
"help:flag_notice"
end
def appeal_notice_wiki_page
"help:appeal_notice"
end
def replacement_notice_wiki_page
"help:replacement_notice"
end
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
2010-10-08 18:42:26 -04:00
def can_user_see_post?(user, post)
if is_user_restricted?(user) && is_post_restricted?(post)
2010-10-08 18:42:26 -04:00
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
def nijie_login
nil
end
def nijie_password
nil
end
def deviantart_login
nil
end
def deviantart_password
nil
end
# http://tinysubversions.com/notes/mastodon-bot/
def pawoo_client_id
nil
end
def pawoo_client_secret
nil
end
# 1. Register app at https://www.tumblr.com/oauth/register.
# 2. Copy "OAuth Consumer Key" from https://www.tumblr.com/oauth/apps.
def tumblr_consumer_key
nil
end
2013-03-12 17:01:52 -04:00
def enable_dimension_autotagging
true
end
2014-03-21 19:43:02 -04:00
# 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 =~ /replaceme|.*_sample|resized|upscaled|downscaled|md5_mismatch|jpeg_artifacts/i
end
2014-05-22 20:42:34 -04:00
def shared_dir_path
"/var/www/danbooru2/shared"
end
2014-11-24 23:21:54 -05:00
2015-01-22 18:55:35 -05:00
def stripe_secret_key
end
def stripe_publishable_key
end
2015-01-24 15:11:39 -05:00
def twitter_api_key
2015-01-24 15:11:39 -05:00
end
def twitter_api_secret
2015-01-24 15:11:39 -05:00
end
def enable_post_search_counts
false
end
# The default headers to be sent with outgoing http requests. Some external
# services will fail if you don't set a valid User-Agent.
def http_headers
{
"User-Agent" => "#{Danbooru.config.safe_app_name}/#{Danbooru.config.version}",
}
end
2017-07-12 18:52:09 -04:00
def httparty_options
# proxy example:
2017-06-29 21:07:07 -04:00
# {http_proxyaddr: "", http_proxyport: "", http_proxyuser: nil, http_proxypass: nil}
{
headers: Danbooru.config.http_headers,
}
2017-06-29 21:07:07 -04:00
end
# you should override this
def email_key
"zDMSATq0W3hmA5p3rKTgD"
end
# impose additional requirements to create tag aliases and implications
def strict_tag_requirements
true
end
2017-12-29 20:15:31 -05:00
def image_magick_srgb_profile_path
# "/usr/share/ghostscript/9.06/Resource/ColorSpace/sRGB"
end
# For downloads, if the host matches any of these IPs, block it
def banned_ip_for_download?(ip_addr)
raise ArgumentError unless ip_addr.is_a?(IPAddr)
if ip_addr.ipv4?
if IPAddr.new("127.0.0.1") == ip_addr
true
elsif IPAddr.new("169.254.0.0/16").include?(ip_addr)
true
elsif IPAddr.new("10.0.0.0/8").include?(ip_addr)
true
elsif IPAddr.new("172.16.0.0/12").include?(ip_addr)
true
elsif IPAddr.new("192.168.0.0/16").include?(ip_addr)
true
else
false
end
elsif ip_addr.ipv6?
if IPAddr.new("::1") == ip_addr
true
elsif IPAddr.new("fe80::/10").include?(ip_addr)
true
elsif IPAddr.new("fd00::/8").include?(ip_addr)
true
else
false
end
else
false
end
end
def twitter_site
end
2015-10-19 16:50:37 -04:00
def addthis_key
end
2015-10-23 19:49:51 -04:00
2017-03-09 21:18:06 -05:00
# enable s3-nginx proxy caching
def use_s3_proxy?(post)
false
2017-03-09 21:18:06 -05:00
end
# include essential tags in image urls (requires nginx/apache rewrites)
2016-05-23 14:50:26 -04:00
def enable_seo_post_urls
false
end
2016-01-18 20:13:26 -05:00
# enable some (donmai-specific) optimizations for post counts
def estimate_post_counts
false
2016-01-18 20:13:26 -05:00
end
# disable this for tests
def enable_sock_puppet_validation?
true
end
# reportbooru options - see https://github.com/r888888888/reportbooru
def reportbooru_server
end
def reportbooru_key
end
# listbooru options - see https://github.com/r888888888/listbooru
2015-10-23 19:49:51 -04:00
def listbooru_server
end
def listbooru_auth_key
end
# iqdbs options - see https://github.com/r888888888/iqdbs
2016-11-28 20:14:25 -05:00
def iqdbs_auth_key
end
def iqdbs_server
end
2016-07-27 20:20:48 -04:00
# google api options
def google_api_project
end
2016-09-07 17:35:35 -04:00
def google_api_json_key_path
"/var/www/danbooru2/shared/config/google-key.json"
2016-09-07 17:35:35 -04:00
end
# AWS config options
def aws_access_key_id
end
def aws_secret_access_key
end
def aws_ses_enabled?
false
end
def aws_ses_options
# {:smtp_server_name => "smtp server", :user_name => "user name", :ses_smtp_user_name => "smtp user name", :ses_smtp_password => "smtp password"}
end
def aws_s3_enabled?
false
end
2017-05-05 22:45:14 -04:00
# Used for backing up images to S3. Must be changed to your own S3 bucket.
def aws_s3_bucket_name
"danbooru"
end
def aws_sqs_enabled?
false
end
def aws_sqs_saved_search_url
end
2016-01-04 14:52:07 -05:00
def aws_sqs_reltagcalc_url
end
2016-06-21 16:14:27 -04:00
def aws_sqs_post_versions_url
end
def aws_sqs_region
end
2016-11-28 20:14:25 -05:00
def aws_sqs_iqdb_url
end
2016-12-14 21:09:45 -05:00
def aws_sqs_archives_url
end
def ccs_server
end
def ccs_key
end
2017-10-03 16:45:26 -04:00
def aws_sqs_cropper_url
end
# Use a recaptcha on the signup page to protect against spambots creating new accounts.
# https://developers.google.com/recaptcha/intro
def enable_recaptcha?
Rails.env.production? && Danbooru.config.recaptcha_site_key.present? && Danbooru.config.recaptcha_secret_key.present?
end
def recaptcha_site_key
end
def recaptcha_secret_key
end
# Akismet API key. Used for Dmail spam detection. http://akismet.com/signup/
def rakismet_key
end
def rakismet_url
end
2017-12-29 20:15:31 -05:00
# Cloudflare data
def cloudflare_email
end
def cloudflare_zone
end
def cloudflare_key
end
2010-02-06 16:48:40 -05:00
end
class EnvironmentConfiguration
def custom_configuration
@custom_configuration ||= CustomConfiguration.new
end
def method_missing(method, *args)
var = ENV["DANBOORU_#{method.to_s.upcase}"]
if var.present?
var
else
custom_configuration.send(method, *args)
end
end
end
2010-02-06 16:48:40 -05:00
end