2011-09-18 15:47:15 -04:00
|
|
|
require 'socket'
|
|
|
|
|
2010-02-06 16:48:40 -05:00
|
|
|
module Danbooru
|
|
|
|
class Configuration
|
|
|
|
# The version of this Danbooru.
|
|
|
|
def version
|
2019-06-16 21:47:05 -04:00
|
|
|
"2.0.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?
|
2019-06-16 21:47:05 -04:00
|
|
|
"e926"
|
2014-10-28 14:05:21 -04:00
|
|
|
else
|
2019-06-16 21:47:05 -04:00
|
|
|
"e621"
|
2014-10-28 14:05:21 -04:00
|
|
|
end
|
2010-02-06 16:48:40 -05:00
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2016-02-09 17:25:23 -05:00
|
|
|
def description
|
2019-06-16 21:47:05 -04:00
|
|
|
"Find good furry art, fast"
|
2016-02-09 17:25:23 -05:00
|
|
|
end
|
|
|
|
|
2018-04-26 13:24:20 -04:00
|
|
|
def domain
|
2019-06-16 21:47:05 -04:00
|
|
|
"e621.net"
|
2018-04-26 13:24:20 -04:00
|
|
|
end
|
|
|
|
|
2017-06-16 01:36:31 -04:00
|
|
|
# The canonical hostname of the site.
|
2011-09-18 15:47:15 -04:00
|
|
|
def hostname
|
|
|
|
Socket.gethostname
|
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2017-06-16 01:36:31 -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
|
2019-06-16 21:47:05 -04:00
|
|
|
"management@#{server_host}"
|
2010-02-20 18:08:22 -05:00
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2019-02-23 11:45:10 -05:00
|
|
|
def takedown_email
|
|
|
|
"management@#{server_host}"
|
|
|
|
end
|
|
|
|
|
2019-03-30 02:52:47 -04:00
|
|
|
def takedown_links
|
2019-02-27 06:47:23 -05:00
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2017-12-21 12:56:12 -05: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.
|
2017-02-23 21:15:29 -05:00
|
|
|
def system_user
|
2019-06-16 21:47:05 -04:00
|
|
|
"E621_Bot"
|
2017-02-23 21:15:29 -05:00
|
|
|
end
|
|
|
|
|
2017-03-22 19:33:14 -04:00
|
|
|
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
|
|
|
|
2016-10-24 19:06:39 -04:00
|
|
|
def source_code_url
|
2019-06-16 21:47:05 -04:00
|
|
|
"https://github.com/zwagoth/e621ng"
|
2016-10-24 19:06:39 -04:00
|
|
|
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
|
|
|
|
2016-10-04 20:56:07 -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
|
2016-10-05 15:46:04 -04:00
|
|
|
true
|
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
|
|
|
# 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
|
|
|
|
2019-06-16 21:47:05 -04:00
|
|
|
# This allows using statically linked copies of ffmpeg in non default locations. Not universally supported across
|
|
|
|
# the codebase at this time.
|
|
|
|
def ffmpeg_path
|
|
|
|
"/usr/bin/ffmpeg"
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
2012-08-21 18:29:09 -04:00
|
|
|
def large_image_prefix
|
|
|
|
"sample-"
|
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2019-02-12 06:00:57 -05:00
|
|
|
def protected_path_prefix
|
|
|
|
"deleted"
|
|
|
|
end
|
|
|
|
|
|
|
|
def protected_file_secret
|
|
|
|
"abc123"
|
|
|
|
end
|
|
|
|
|
2019-02-15 06:14:35 -05:00
|
|
|
def deleted_preview_url
|
|
|
|
"/images/deleted-preview.png"
|
|
|
|
end
|
|
|
|
|
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
|
2019-06-27 11:33:02 -04:00
|
|
|
15
|
|
|
|
end
|
|
|
|
|
|
|
|
def dmail_limit
|
|
|
|
20
|
|
|
|
end
|
|
|
|
|
|
|
|
def dmail_minute_limit
|
|
|
|
1
|
|
|
|
end
|
|
|
|
|
|
|
|
# Blips created in the last hour
|
|
|
|
def blip_limit
|
|
|
|
25
|
|
|
|
end
|
|
|
|
|
|
|
|
# Artists creator or edited in the last hour
|
|
|
|
def artist_edit_limit
|
|
|
|
25
|
|
|
|
end
|
|
|
|
|
|
|
|
# Wiki pages created or edited in the last hour
|
|
|
|
def wiki_edit_limit
|
|
|
|
60
|
|
|
|
end
|
|
|
|
|
|
|
|
# Notes applied to posts edited or created in the last hour
|
|
|
|
def note_edit_limit
|
|
|
|
50
|
|
|
|
end
|
|
|
|
|
|
|
|
# Pools created in the last hour
|
|
|
|
def pool_limit
|
2010-02-06 16:48:40 -05:00
|
|
|
2
|
|
|
|
end
|
|
|
|
|
2019-06-27 11:33:02 -04:00
|
|
|
# Pools created or edited in the last hour
|
|
|
|
def pool_edit_limit
|
|
|
|
10
|
|
|
|
end
|
|
|
|
|
2019-06-22 04:48:08 -04:00
|
|
|
# Members cannot create more than X post versions in an hour.
|
|
|
|
def post_edit_limit
|
|
|
|
150
|
|
|
|
end
|
|
|
|
|
2018-11-07 17:10:16 -05:00
|
|
|
# Members cannot change the category of pools with more than this many posts.
|
|
|
|
def pool_category_change_limit
|
|
|
|
100
|
|
|
|
end
|
|
|
|
|
2019-04-03 21:56:47 -04:00
|
|
|
def tag_type_change_cutoff
|
|
|
|
100
|
|
|
|
end
|
|
|
|
|
2017-11-20 19:33:59 -05:00
|
|
|
# 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)
|
2013-04-28 03:04:52 -04:00
|
|
|
!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.
|
2013-02-20 21:56:09 -05:00
|
|
|
def base_tag_query_limit
|
2019-02-20 07:42:10 -05:00
|
|
|
20
|
2010-02-06 16:48:40 -05:00
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2013-02-20 21:56:09 -05:00
|
|
|
def tag_query_limit
|
|
|
|
if CurrentUser.user.present?
|
|
|
|
CurrentUser.user.tag_query_limit
|
|
|
|
else
|
2019-02-20 07:42:10 -05:00
|
|
|
base_tag_query_limit
|
2013-02-20 21:56:09 -05:00
|
|
|
end
|
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2017-11-19 21:27:30 -05: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
|
|
|
|
2018-02-17 17:07:56 -05:00
|
|
|
# Maximum size of an upload. If you change this, you must also change
|
|
|
|
# `client_max_body_size` in your nginx.conf.
|
2010-02-08 01:40:39 -05:00
|
|
|
def max_file_size
|
2019-06-16 21:47:05 -04:00
|
|
|
100.megabytes
|
|
|
|
end
|
|
|
|
|
|
|
|
def max_file_sizes
|
|
|
|
{
|
|
|
|
'jpg' => 100.megabytes,
|
|
|
|
'gif' => 20.megabytes,
|
|
|
|
'png' => 100.megabytes,
|
|
|
|
'swf' => 100.megabytes,
|
|
|
|
'webm' => 100.megabytes,
|
|
|
|
'mp4' => 100.megabytes
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def max_apng_file_size
|
|
|
|
20.megabytes
|
|
|
|
end
|
|
|
|
|
|
|
|
# Measured in seconds
|
|
|
|
def max_video_duration
|
|
|
|
600
|
2010-02-08 01:40:39 -05:00
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2018-03-25 19:05:52 -04:00
|
|
|
# Maximum resolution (width * height) of an upload. Default: 441 megapixels (21000x21000 pixels).
|
|
|
|
def max_image_resolution
|
2019-06-16 21:47:05 -04:00
|
|
|
15000 * 15000
|
2018-03-25 19:05:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Maximum width of an upload.
|
|
|
|
def max_image_width
|
2019-06-16 21:47:05 -04:00
|
|
|
15000
|
2018-03-25 19:05:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Maximum height of an upload.
|
|
|
|
def max_image_height
|
2019-06-16 21:47:05 -04:00
|
|
|
15000
|
2018-03-25 19:05:52 -04:00
|
|
|
end
|
|
|
|
|
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
|
|
|
|
2018-01-28 20:57:45 -05:00
|
|
|
# Permanently redirect all HTTP requests to HTTPS.
|
|
|
|
#
|
|
|
|
# https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
|
|
|
|
# http://api.rubyonrails.org/classes/ActionDispatch/SSL.html
|
|
|
|
def ssl_options
|
|
|
|
{
|
|
|
|
redirect: { exclude: ->(request) { request.subdomain == "insecure" } },
|
|
|
|
hsts: {
|
|
|
|
expires: 1.year,
|
|
|
|
preload: true,
|
|
|
|
subdomains: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
# Disable the forced use of HTTPS.
|
|
|
|
# def ssl_options
|
|
|
|
# false
|
|
|
|
# end
|
|
|
|
|
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
|
2012-06-01 19:22:58 -04:00
|
|
|
[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
|
2018-10-08 18:51:23 -04:00
|
|
|
"danbooru"
|
2010-10-08 18:42:26 -04:00
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2018-02-22 14:15:42 -05:00
|
|
|
def archive_server_login
|
|
|
|
"danbooru"
|
|
|
|
end
|
|
|
|
|
2018-03-14 17:57:29 -04:00
|
|
|
# The method to use for storing image files.
|
|
|
|
def storage_manager
|
|
|
|
# Store files on the local filesystem.
|
|
|
|
# base_dir - where to store files (default: under public/data)
|
|
|
|
# base_url - where to serve files from (default: http://#{hostname}/data)
|
|
|
|
# hierarchical: false - store files in a single directory
|
|
|
|
# hierarchical: true - store files in a hierarchical directory structure, based on the MD5 hash
|
2018-08-15 19:08:10 -04:00
|
|
|
StorageManager::Local.new(base_url: "#{CurrentUser.root_url}/data", base_dir: "#{Rails.root}/public/data", hierarchical: false)
|
2018-03-14 17:57:29 -04:00
|
|
|
|
|
|
|
# Store files on one or more remote host(s). Configure SSH settings in
|
|
|
|
# ~/.ssh_config or in the ssh_options param (ref: http://net-ssh.github.io/net-ssh/Net/SSH.html#method-c-start)
|
|
|
|
# StorageManager::SFTP.new("i1.example.com", "i2.example.com", base_dir: "/mnt/backup", hierarchical: false, ssh_options: {})
|
|
|
|
|
|
|
|
# Store files in an S3 bucket. The bucket must already exist and be
|
|
|
|
# writable by you. Configure your S3 settings in aws_region and
|
|
|
|
# aws_credentials below, or in the s3_options param (ref:
|
|
|
|
# https://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#initialize-instance_method)
|
|
|
|
# StorageManager::S3.new("my_s3_bucket", base_url: "https://my_s3_bucket.s3.amazonaws.com/", s3_options: {})
|
|
|
|
|
|
|
|
# Select the storage method based on the post's id and type (preview, large, or original).
|
|
|
|
# StorageManager::Hybrid.new do |id, md5, file_ext, type|
|
|
|
|
# ssh_options = { user: "danbooru" }
|
|
|
|
#
|
|
|
|
# if type.in?([:large, :original]) && id.in?(0..850_000)
|
|
|
|
# StorageManager::SFTP.new("raikou1.donmai.us", base_url: "https://raikou1.donmai.us", base_dir: "/path/to/files", hierarchical: true, ssh_options: ssh_options)
|
|
|
|
# elsif type.in?([:large, :original]) && id.in?(850_001..2_000_000)
|
|
|
|
# StorageManager::SFTP.new("raikou2.donmai.us", base_url: "https://raikou2.donmai.us", base_dir: "/path/to/files", hierarchical: true, ssh_options: ssh_options)
|
|
|
|
# elsif type.in?([:large, :original]) && id.in?(2_000_001..3_000_000)
|
|
|
|
# StorageManager::SFTP.new(*all_server_hosts, base_url: "https://hijiribe.donmai.us/data", ssh_options: ssh_options)
|
|
|
|
# else
|
|
|
|
# StorageManager::SFTP.new(*all_server_hosts, ssh_options: ssh_options)
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
end
|
|
|
|
|
2018-03-18 17:33:26 -04:00
|
|
|
# The method to use for backing up image files.
|
|
|
|
def backup_storage_manager
|
|
|
|
# Don't perform any backups.
|
|
|
|
StorageManager::Null.new
|
|
|
|
|
|
|
|
# Backup files to /mnt/backup on the local filesystem.
|
|
|
|
# StorageManager::Local.new(base_dir: "/mnt/backup", hierarchical: false)
|
|
|
|
|
|
|
|
# Backup files to /mnt/backup on a remote system. Configure SSH settings
|
|
|
|
# in ~/.ssh_config or in the ssh_options param (ref: http://net-ssh.github.io/net-ssh/Net/SSH.html#method-c-start)
|
|
|
|
# StorageManager::SFTP.new("www.example.com", base_dir: "/mnt/backup", ssh_options: {})
|
|
|
|
|
|
|
|
# Backup files to an S3 bucket. The bucket must already exist and be
|
|
|
|
# writable by you. Configure your S3 settings in aws_region and
|
|
|
|
# aws_credentials below, or in the s3_options param (ref:
|
|
|
|
# https://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#initialize-instance_method)
|
|
|
|
# StorageManager::S3.new("my_s3_bucket_name", s3_options: {})
|
|
|
|
end
|
2018-01-03 14:42:08 -05:00
|
|
|
|
2017-11-06 02:17:32 -05:00
|
|
|
#TAG CONFIGURATION
|
|
|
|
|
2017-11-06 02:03:36 -05:00
|
|
|
#Full tag configuration info for all tags
|
|
|
|
def full_tag_config_info
|
|
|
|
@full_tag_category_mapping ||= {
|
|
|
|
"general" => {
|
|
|
|
"category" => 0,
|
|
|
|
"short" => "gen",
|
2017-11-06 02:17:32 -05:00
|
|
|
"extra" => [],
|
2017-11-14 20:51:47 -05:00
|
|
|
"header" => %{<h1 class="general-tag-list">Tags</h1>},
|
2017-11-06 17:43:06 -05:00
|
|
|
"humanized" => nil,
|
2017-12-24 14:01:17 -05:00
|
|
|
"relatedbutton" => "General",
|
|
|
|
"css" => {
|
|
|
|
"color" => "$link_color",
|
|
|
|
"hover" => "$link_hover_color"
|
|
|
|
}
|
2017-11-06 02:03:36 -05:00
|
|
|
},
|
2019-06-23 03:27:33 -04:00
|
|
|
"species" => {
|
|
|
|
"category" => 5,
|
|
|
|
"short" => "spec",
|
|
|
|
"extra" => [],
|
|
|
|
"header" => %{<h2 class="species-tag-list">Species</h2>},
|
|
|
|
"humanized" => nil,
|
|
|
|
"relatedbutton" => "Species",
|
|
|
|
"css" => {
|
|
|
|
"color" => "#0F0",
|
|
|
|
"hover" => "#070"
|
|
|
|
}
|
|
|
|
},
|
2017-11-06 02:03:36 -05:00
|
|
|
"character" => {
|
|
|
|
"category" => 4,
|
|
|
|
"short" => "char",
|
2017-11-06 02:17:32 -05:00
|
|
|
"extra" => ["ch"],
|
2017-11-14 20:51:47 -05:00
|
|
|
"header" => %{<h2 class="character-tag-list">Characters</h2>},
|
2017-11-06 02:17:32 -05:00
|
|
|
"humanized" => {
|
|
|
|
"slice" => 5,
|
|
|
|
"exclusion" => [],
|
|
|
|
"regexmap" => /^(.+?)(?:_\(.+\))?$/,
|
|
|
|
"formatstr" => "%s"
|
2017-11-06 17:43:06 -05:00
|
|
|
},
|
2017-12-24 14:01:17 -05:00
|
|
|
"relatedbutton" => "Characters",
|
|
|
|
"css" => {
|
|
|
|
"color" => "#0A0",
|
|
|
|
"hover" => "#6B6"
|
|
|
|
}
|
2017-11-06 02:03:36 -05:00
|
|
|
},
|
|
|
|
"copyright" => {
|
|
|
|
"category" => 3,
|
|
|
|
"short" => "copy",
|
2017-11-06 02:17:32 -05:00
|
|
|
"extra" => ["co"],
|
2017-11-14 20:51:47 -05:00
|
|
|
"header" => %{<h2 class="copyright-tag-list">Copyrights</h2>},
|
2017-11-06 02:17:32 -05:00
|
|
|
"humanized" => {
|
2018-11-05 17:34:07 -05:00
|
|
|
"slice" => 1,
|
2017-11-06 02:17:32 -05:00
|
|
|
"exclusion" => [],
|
|
|
|
"regexmap" => //,
|
|
|
|
"formatstr" => "(%s)"
|
2017-11-06 17:43:06 -05:00
|
|
|
},
|
2017-12-24 14:01:17 -05:00
|
|
|
"relatedbutton" => "Copyrights",
|
|
|
|
"css" => {
|
|
|
|
"color" => "#A0A",
|
|
|
|
"hover" => "#B6B"
|
|
|
|
}
|
2017-11-06 02:03:36 -05:00
|
|
|
},
|
|
|
|
"artist" => {
|
|
|
|
"category" => 1,
|
|
|
|
"short" => "art",
|
2017-11-06 02:17:32 -05:00
|
|
|
"extra" => [],
|
2017-11-14 20:51:47 -05:00
|
|
|
"header" => %{<h2 class="artist-tag-list">Artists</h2>},
|
2017-11-06 02:17:32 -05:00
|
|
|
"humanized" => {
|
|
|
|
"slice" => 0,
|
|
|
|
"exclusion" => %w(banned_artist),
|
|
|
|
"regexmap" => //,
|
|
|
|
"formatstr" => "drawn by %s"
|
2017-11-06 17:43:06 -05:00
|
|
|
},
|
2017-12-24 14:01:17 -05:00
|
|
|
"relatedbutton" => "Artists",
|
|
|
|
"css" => {
|
|
|
|
"color" => "#A00",
|
|
|
|
"hover" => "#B66"
|
|
|
|
}
|
2017-11-06 18:03:45 -05:00
|
|
|
},
|
2019-06-23 03:27:33 -04:00
|
|
|
"invalid" => {
|
|
|
|
"category" => 6,
|
|
|
|
"short" => "inv",
|
|
|
|
"extra" => [],
|
|
|
|
"header" => %{<h2 class="invalid-tag-list">Invalid</h2>},
|
|
|
|
"humanized" => nil,
|
|
|
|
"relatedbutton" => nil,
|
|
|
|
"css" => {
|
|
|
|
"color" => "#000",
|
|
|
|
"hover" => "#444"
|
|
|
|
}
|
|
|
|
},
|
2017-11-06 18:03:45 -05:00
|
|
|
"meta" => {
|
2019-06-23 03:27:33 -04:00
|
|
|
"category" => 7,
|
2017-11-06 18:03:45 -05:00
|
|
|
"short" => "meta",
|
|
|
|
"extra" => [],
|
2017-11-14 20:51:47 -05:00
|
|
|
"header" => %{<h2 class="meta-tag-list">Meta</h2>},
|
2017-11-06 18:03:45 -05:00
|
|
|
"humanized" => nil,
|
2017-12-24 14:01:17 -05:00
|
|
|
"relatedbutton" => nil,
|
|
|
|
"css" => {
|
|
|
|
"color" => "#F80",
|
|
|
|
"hover" => "#FA6"
|
|
|
|
}
|
2017-11-06 02:03:36 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2017-11-06 02:17:32 -05:00
|
|
|
#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
|
2019-06-23 03:27:33 -04:00
|
|
|
@split_tag_header_list ||= ["artist","copyright","character","species","general","meta","invalid"]
|
2017-11-06 02:17:32 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
#Sets the order of the categorized tag string (presenters/post_presenter.rb)
|
|
|
|
def categorized_tag_list
|
2019-06-23 03:27:33 -04:00
|
|
|
@categorized_tag_list ||= ["artist","copyright","character","species","meta","general","invalid"]
|
2017-11-06 02:17:32 -05:00
|
|
|
end
|
|
|
|
|
2017-11-06 17:43:06 -05:00
|
|
|
#Sets the order of the related tag buttons (javascripts/related_tag.js)
|
|
|
|
def related_tag_button_list
|
2019-06-23 03:27:33 -04:00
|
|
|
@related_tag_button_list ||= ["general","artist","species","character","copyright"]
|
2017-11-06 17:43:06 -05:00
|
|
|
end
|
|
|
|
|
2017-11-06 02:17:32 -05:00
|
|
|
#END TAG
|
|
|
|
|
2010-03-11 19:42:04 -05:00
|
|
|
# If enabled, users must verify their email addresses.
|
|
|
|
def enable_email_verification?
|
2010-10-27 20:16:43 -04:00
|
|
|
false
|
2010-03-11 19:42:04 -05:00
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2010-03-10 18:21:43 -05:00
|
|
|
# Any custom code you want to insert into the default layout without
|
|
|
|
# having to modify the templates.
|
|
|
|
def custom_html_header_content
|
2010-11-19 13:44:11 -05:00
|
|
|
nil
|
2010-03-10 18:21:43 -05:00
|
|
|
end
|
2013-03-19 08:10:10 -04:00
|
|
|
|
2016-11-21 02:17:15 -05:00
|
|
|
def upload_notice_wiki_page
|
|
|
|
"help:upload_notice"
|
|
|
|
end
|
|
|
|
|
2016-11-21 02:30:01 -05:00
|
|
|
def flag_notice_wiki_page
|
|
|
|
"help:flag_notice"
|
|
|
|
end
|
|
|
|
|
2016-12-22 22:53:10 -05:00
|
|
|
def appeal_notice_wiki_page
|
|
|
|
"help:appeal_notice"
|
|
|
|
end
|
|
|
|
|
2017-05-16 23:51:05 -04:00
|
|
|
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)
|
2010-11-19 13:44:11 -05:00
|
|
|
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)
|
2013-04-28 03:04:52 -04:00
|
|
|
!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)
|
2019-02-14 04:44:54 -05:00
|
|
|
return false if post.is_deleted? && !user.is_moderator?
|
2019-02-13 22:58:38 -05:00
|
|
|
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
|
|
|
|
2014-06-03 18:42:24 -04:00
|
|
|
def nijie_login
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def nijie_password
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2018-04-09 21:12:11 -04:00
|
|
|
# Register at https://www.deviantart.com/developers/.
|
|
|
|
def deviantart_client_id
|
2017-06-10 11:34:51 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2018-04-09 21:12:11 -04:00
|
|
|
def deviantart_client_secret
|
2017-06-10 11:34:51 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2017-06-13 02:14:04 -04:00
|
|
|
# http://tinysubversions.com/notes/mastodon-bot/
|
|
|
|
def pawoo_client_id
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def pawoo_client_secret
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2017-06-23 00:32:53 -04:00
|
|
|
# 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
|
|
|
|
2017-06-26 19:17:16 -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)
|
2019-01-13 16:06:30 -05:00
|
|
|
tag =~ /\A(?:replaceme|.*_sample|resized|upscaled|downscaled|md5_mismatch|jpeg_artifacts|corrupted_image|source_request)\z/i
|
2017-06-26 19:17:16 -04:00
|
|
|
end
|
|
|
|
|
2018-04-17 18:15:06 -04:00
|
|
|
# Posts with these tags will be highlighted yellow in the modqueue.
|
|
|
|
def modqueue_quality_warning_tags
|
2018-04-17 18:19:18 -04:00
|
|
|
%w[hard_translated self_upload nude_filter third-party_edit screencap]
|
2018-04-17 18:15:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Posts with these tags will be highlighted red in the modqueue.
|
|
|
|
def modqueue_sample_warning_tags
|
|
|
|
%w[duplicate image_sample md5_mismatch resized upscaled downscaled]
|
|
|
|
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
|
2019-06-16 21:47:05 -04:00
|
|
|
|
2015-01-22 18:55:35 -05:00
|
|
|
def stripe_publishable_key
|
|
|
|
end
|
2015-01-24 15:11:39 -05:00
|
|
|
|
2015-02-09 19:29:00 -05:00
|
|
|
def twitter_api_key
|
2015-01-24 15:11:39 -05:00
|
|
|
end
|
|
|
|
|
2015-02-09 19:29:00 -05:00
|
|
|
def twitter_api_secret
|
2015-01-24 15:11:39 -05:00
|
|
|
end
|
2015-07-21 16:09:32 -04:00
|
|
|
|
2017-07-19 20:37:14 -04:00
|
|
|
# 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}
|
2017-07-19 20:37:14 -04:00
|
|
|
{
|
|
|
|
headers: Danbooru.config.http_headers,
|
|
|
|
}
|
2017-06-29 21:07:07 -04:00
|
|
|
end
|
|
|
|
|
2016-11-28 20:28:47 -05:00
|
|
|
# you should override this
|
2015-09-03 20:03:03 -04:00
|
|
|
def email_key
|
|
|
|
"zDMSATq0W3hmA5p3rKTgD"
|
|
|
|
end
|
|
|
|
|
2016-01-28 20:39:01 -05:00
|
|
|
# impose additional requirements to create tag aliases and implications
|
|
|
|
def strict_tag_requirements
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-08-18 15:25:26 -04:00
|
|
|
# For downloads, if the host matches any of these IPs, block it
|
|
|
|
def banned_ip_for_download?(ip_addr)
|
2015-08-18 15:45:10 -04:00
|
|
|
raise ArgumentError unless ip_addr.is_a?(IPAddr)
|
2019-06-16 21:47:05 -04:00
|
|
|
ipv4s = %w(127.0.0.1/8 169.254.0.0/16 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16)
|
|
|
|
ipv6s = %w(::1 fe80::/10 fd00::/8)
|
|
|
|
|
2015-08-18 15:45:10 -04:00
|
|
|
|
2015-08-18 17:18:27 -04:00
|
|
|
if ip_addr.ipv4?
|
2019-06-16 21:47:05 -04:00
|
|
|
ipv4s.any? {|range| IPAddr.new(range).include?(ip_addr)}
|
2015-08-18 17:18:27 -04:00
|
|
|
elsif ip_addr.ipv6?
|
2019-06-16 21:47:05 -04:00
|
|
|
ipv6s.any? {|range| IPAddr.new(range).include?(ip_addr)}
|
2015-08-18 15:45:10 -04:00
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
2015-08-18 15:25:26 -04:00
|
|
|
end
|
2015-08-25 19:34:51 -04:00
|
|
|
|
|
|
|
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)
|
2017-05-14 11:40:15 -04:00
|
|
|
false
|
2017-03-09 21:18:06 -05:00
|
|
|
end
|
|
|
|
|
2016-05-23 20:05:23 -04:00
|
|
|
# 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
|
2016-06-29 18:45:22 -04:00
|
|
|
false
|
2016-01-18 20:13:26 -05:00
|
|
|
end
|
|
|
|
|
2018-01-02 17:32:38 -05:00
|
|
|
# disable this for tests
|
|
|
|
def enable_sock_puppet_validation?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2018-08-24 12:21:54 -04:00
|
|
|
# Enables recording of popular searches, missed searches, and post view
|
|
|
|
# counts. Requires Reportbooru to be configured and running - see below.
|
|
|
|
def enable_post_search_counts
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2016-11-28 20:28:47 -05:00
|
|
|
# reportbooru options - see https://github.com/r888888888/reportbooru
|
|
|
|
def reportbooru_server
|
|
|
|
end
|
|
|
|
|
|
|
|
def reportbooru_key
|
|
|
|
end
|
|
|
|
|
2019-06-16 21:47:05 -04:00
|
|
|
def iqdb_enabled?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2016-11-28 20:28:47 -05:00
|
|
|
# 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
|
|
|
|
|
2017-11-28 23:37:02 -05:00
|
|
|
# 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
|
2018-07-09 13:06:20 -04:00
|
|
|
|
|
|
|
def enable_image_cropping
|
|
|
|
true
|
|
|
|
end
|
2019-06-16 21:47:05 -04:00
|
|
|
|
2017-11-25 22:26:59 -05:00
|
|
|
# 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
|
2018-07-20 16:18:24 -04:00
|
|
|
|
|
|
|
def recommender_server
|
|
|
|
end
|
|
|
|
|
|
|
|
def recommender_key
|
|
|
|
end
|
2018-11-12 21:02:49 -05:00
|
|
|
|
|
|
|
def redis_url
|
|
|
|
end
|
2019-02-07 00:08:03 -05:00
|
|
|
|
|
|
|
def bypass_upload_whitelist?(user)
|
2019-02-07 13:05:50 -05:00
|
|
|
user.is_admin?
|
2019-02-07 00:08:03 -05:00
|
|
|
end
|
2010-02-06 16:48:40 -05:00
|
|
|
end
|
2017-01-21 02:15:11 -05:00
|
|
|
|
|
|
|
class EnvironmentConfiguration
|
2017-01-24 18:02:53 -05:00
|
|
|
def custom_configuration
|
|
|
|
@custom_configuration ||= CustomConfiguration.new
|
|
|
|
end
|
|
|
|
|
2017-01-21 02:15:11 -05:00
|
|
|
def method_missing(method, *args)
|
2018-04-08 12:24:53 -04:00
|
|
|
var = ENV["DANBOORU_#{method.to_s.upcase.chomp("?")}"]
|
2017-01-21 02:15:11 -05:00
|
|
|
|
|
|
|
if var.present?
|
|
|
|
var
|
|
|
|
else
|
2017-01-24 18:02:53 -05:00
|
|
|
custom_configuration.send(method, *args)
|
2017-01-21 02:15:11 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-01-28 17:49:24 -05:00
|
|
|
|
|
|
|
def config
|
|
|
|
@configuration ||= EnvironmentConfiguration.new
|
|
|
|
end
|
|
|
|
|
|
|
|
module_function :config
|
2010-02-06 16:48:40 -05:00
|
|
|
end
|