rubocop: fix various style issues.
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
require_relative 'boot'
|
||||
require "rails"
|
||||
require "active_record/railtie"
|
||||
#require "active_storage/engine"
|
||||
# require "active_storage/engine"
|
||||
require "action_controller/railtie"
|
||||
require "action_view/railtie"
|
||||
require "action_mailer/railtie"
|
||||
require "active_job/railtie"
|
||||
#require "action_cable/engine"
|
||||
#require "action_mailbox/engine"
|
||||
#require "action_text/engine"
|
||||
# require "action_cable/engine"
|
||||
# require "action_mailbox/engine"
|
||||
# require "action_text/engine"
|
||||
require "rails/test_unit/railtie"
|
||||
#require "sprockets/railtie"
|
||||
# require "sprockets/railtie"
|
||||
|
||||
Bundler.require(*Rails.groups)
|
||||
|
||||
@@ -27,8 +27,8 @@ module Danbooru
|
||||
config.active_record.schema_format = :sql
|
||||
config.encoding = "utf-8"
|
||||
config.filter_parameters += [:password, :password_confirmation, :password_hash, :api_key]
|
||||
#config.assets.enabled = true
|
||||
#config.assets.version = '1.0'
|
||||
# config.assets.enabled = true
|
||||
# config.assets.version = '1.0'
|
||||
config.autoload_paths += %W(#{config.root}/app/presenters #{config.root}/app/logical #{config.root}/app/mailers)
|
||||
config.plugins = [:all]
|
||||
config.time_zone = 'Eastern Time (US & Canada)'
|
||||
@@ -58,17 +58,17 @@ module Danbooru
|
||||
}
|
||||
end
|
||||
|
||||
if File.exists?("#{config.root}/REVISION")
|
||||
if File.exist?("#{config.root}/REVISION")
|
||||
config.x.git_hash = File.read("#{config.root}/REVISION").strip
|
||||
elsif system("type git > /dev/null && git rev-parse --show-toplevel > /dev/null")
|
||||
config.x.git_hash = %x(git rev-parse --short HEAD).strip
|
||||
config.x.git_hash = `git rev-parse --short HEAD`.strip
|
||||
else
|
||||
config.x.git_hash = nil
|
||||
end
|
||||
|
||||
config.after_initialize do
|
||||
Rails.application.routes.default_url_options = {
|
||||
host: Danbooru.config.hostname,
|
||||
host: Danbooru.config.hostname
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module Danbooru
|
||||
module_function
|
||||
|
||||
class Configuration
|
||||
# A secret key used to encrypt session cookies, among other things. If this
|
||||
# token is changed, existing login sessions will become invalid. If this
|
||||
@@ -136,7 +138,7 @@ module Danbooru
|
||||
|
||||
# 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)
|
||||
tag.match?(/\A(-?status:deleted|rating:s.*|limit:.+)\z/i)
|
||||
end
|
||||
|
||||
# After this many pages, the paginator will switch to sequential mode.
|
||||
@@ -195,8 +197,8 @@ module Danbooru
|
||||
hsts: {
|
||||
expires: 1.year,
|
||||
preload: true,
|
||||
subdomains: false,
|
||||
},
|
||||
subdomains: false
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
@@ -224,7 +226,7 @@ module Danbooru
|
||||
# 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
|
||||
StorageManager::Local.new(base_url: "#{CurrentUser.root_url}/data", base_dir: "#{Rails.root}/public/data", hierarchical: false)
|
||||
StorageManager::Local.new(base_url: "#{CurrentUser.root_url}/data", base_dir: Rails.root.join("/public/data"), hierarchical: false)
|
||||
|
||||
# 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)
|
||||
@@ -259,9 +261,9 @@ module Danbooru
|
||||
# StorageManager::SFTP.new("www.example.com", base_dir: "/mnt/backup", ssh_options: {})
|
||||
end
|
||||
|
||||
#TAG CONFIGURATION
|
||||
# TAG CONFIGURATION
|
||||
|
||||
#Full tag configuration info for all tags
|
||||
# Full tag configuration info for all tags
|
||||
def full_tag_config_info
|
||||
@full_tag_category_mapping ||= {
|
||||
"general" => {
|
||||
@@ -322,24 +324,24 @@ module Danbooru
|
||||
}
|
||||
end
|
||||
|
||||
#TAG ORDERS
|
||||
# TAG ORDERS
|
||||
|
||||
#Sets the order of the split tag header list (presenters/tag_set_presenter.rb)
|
||||
# Sets the order of the split tag header list (presenters/tag_set_presenter.rb)
|
||||
def split_tag_header_list
|
||||
@split_tag_header_list ||= ["copyright","character","artist","general","meta"]
|
||||
@split_tag_header_list ||= ["copyright", "character", "artist", "general", "meta"]
|
||||
end
|
||||
|
||||
#Sets the order of the categorized tag string (presenters/post_presenter.rb)
|
||||
# Sets the order of the categorized tag string (presenters/post_presenter.rb)
|
||||
def categorized_tag_list
|
||||
@categorized_tag_list ||= ["copyright","character","artist","meta","general"]
|
||||
@categorized_tag_list ||= ["copyright", "character", "artist", "meta", "general"]
|
||||
end
|
||||
|
||||
#Sets the order of the related tag buttons (javascripts/related_tag.js)
|
||||
# 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"]
|
||||
@related_tag_button_list ||= ["general", "artist", "character", "copyright"]
|
||||
end
|
||||
|
||||
#END TAG
|
||||
# END TAG
|
||||
|
||||
# Any custom code you want to insert into the default layout without
|
||||
# having to modify the templates.
|
||||
@@ -377,7 +379,7 @@ module Danbooru
|
||||
end
|
||||
|
||||
def can_user_see_post?(user, post)
|
||||
if is_user_restricted?(user) && is_post_restricted?(post)
|
||||
if is_user_restricted?(user) && is_post_restricted?(post)
|
||||
false
|
||||
else
|
||||
true
|
||||
@@ -479,7 +481,7 @@ module Danbooru
|
||||
# services will fail if you don't set a valid User-Agent.
|
||||
def http_headers
|
||||
{
|
||||
"User-Agent" => "#{Danbooru.config.canonical_app_name}/#{Rails.application.config.x.git_hash}",
|
||||
"User-Agent" => "#{Danbooru.config.canonical_app_name}/#{Rails.application.config.x.git_hash}"
|
||||
}
|
||||
end
|
||||
|
||||
@@ -487,7 +489,7 @@ module Danbooru
|
||||
# proxy example:
|
||||
# {http_proxyaddr: "", http_proxyport: "", http_proxyuser: nil, http_proxypass: nil}
|
||||
{
|
||||
headers: Danbooru.config.http_headers,
|
||||
headers: Danbooru.config.http_headers
|
||||
}
|
||||
end
|
||||
|
||||
@@ -646,17 +648,11 @@ module Danbooru
|
||||
def method_missing(method, *args)
|
||||
var = ENV["DANBOORU_#{method.to_s.upcase.chomp("?")}"]
|
||||
|
||||
if var.present?
|
||||
var
|
||||
else
|
||||
custom_configuration.send(method, *args)
|
||||
end
|
||||
var.presence || custom_configuration.send(method, *args)
|
||||
end
|
||||
end
|
||||
|
||||
def config
|
||||
@configuration ||= EnvironmentConfiguration.new
|
||||
@config ||= EnvironmentConfiguration.new
|
||||
end
|
||||
|
||||
module_function :config
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ Rails.application.configure do
|
||||
config.log_level = :error
|
||||
|
||||
# Prepend all log lines with the following tags.
|
||||
config.log_tags = [ :request_id ]
|
||||
config.log_tags = [:request_id]
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
|
||||
config.cache_classes = true
|
||||
|
||||
# Do not eager load code on boot. This avoids loading your whole application
|
||||
|
||||
@@ -7,11 +7,11 @@ Rails.application.configure do
|
||||
{
|
||||
url: Danbooru.config.redis_url,
|
||||
namespace: nil,
|
||||
connect_timeout: 30, # default: 20 seconds
|
||||
write_timeout: 0.5, # default: 1 second
|
||||
read_timeout: 0.5, # default: 1 second
|
||||
connect_timeout: 30, # default: 20 seconds
|
||||
write_timeout: 0.5, # default: 1 second
|
||||
read_timeout: 0.5, # default: 1 second
|
||||
reconnect_attempts: 0, # default: 0
|
||||
error_handler: ->(method:, returning:, exception:) {
|
||||
error_handler: lambda { |method:, returning:, exception:|
|
||||
DanbooruLogger.log(exception, method: method, returning: returning)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ if Rails.env.test?
|
||||
referer = current_page,
|
||||
redirects = 0
|
||||
)
|
||||
action = "#{method.to_s.upcase} #{uri.to_s}"
|
||||
action = "#{method.to_s.upcase} #{uri}"
|
||||
retry_count = 0
|
||||
|
||||
begin
|
||||
@@ -43,13 +43,13 @@ if Rails.env.test?
|
||||
# Pass on the error if we've tried too many times.
|
||||
if retry_count >= MAX_RESET_RETRIES
|
||||
print "R"
|
||||
#puts "**** WARN: Mechanize retried connection reset #{MAX_RESET_RETRIES} times and never succeeded: #{action}"
|
||||
# puts "**** WARN: Mechanize retried connection reset #{MAX_RESET_RETRIES} times and never succeeded: #{action}"
|
||||
raise
|
||||
end
|
||||
|
||||
# Otherwise, shutdown the persistent HTTP connection and try again.
|
||||
print "R"
|
||||
#puts "**** WARN: Mechanize retrying connection reset error: #{action}"
|
||||
# puts "**** WARN: Mechanize retrying connection reset error: #{action}"
|
||||
retry_count += 1
|
||||
self.http.shutdown
|
||||
retry
|
||||
@@ -58,7 +58,7 @@ if Rails.env.test?
|
||||
|
||||
# Alias so #fetch actually uses our new #fetch_with_retry to wrap the
|
||||
# old one aliased as #fetch_without_retry.
|
||||
alias_method :fetch_without_retry, :fetch
|
||||
alias_method :fetch, :fetch_with_retry
|
||||
alias fetch_without_retry fetch
|
||||
alias fetch fetch_with_retry
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,8 +5,7 @@ SimpleForm.setup do |config|
|
||||
# wrapper, change the order or even add your own to the
|
||||
# stack. The options given below are used to wrap the
|
||||
# whole input.
|
||||
config.wrappers :default, class: :input,
|
||||
hint_class: :field_with_hint, error_class: :field_with_errors do |b|
|
||||
config.wrappers :default, class: :input, hint_class: :field_with_hint, error_class: :field_with_errors do |b|
|
||||
## Extensions enabled by default
|
||||
# Any of these extensions can be disabled for a
|
||||
# given input by passing: `f.input EXTENSION_NAME => false`.
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
# This is needed when using Unicorn and preload_app is not set to true.
|
||||
# See https://newrelic.com/docs/ruby/no-data-with-unicorn
|
||||
if defined? ::NewRelic
|
||||
::NewRelic::Agent.manual_start()
|
||||
::NewRelic::Agent.manual_start
|
||||
::NewRelic::Agent.after_fork(:force_reconnect => true)
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
namespace :admin do
|
||||
resources :users, :only => [:edit, :update]
|
||||
resource :alias_and_implication_import, :only => [:new, :create]
|
||||
@@ -155,7 +154,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
resources :ip_bans
|
||||
resources :ip_addresses, only: [:index]
|
||||
resource :iqdb_queries, :only => [:show, :create] do
|
||||
resource :iqdb_queries, :only => [:show, :create] do
|
||||
collection do
|
||||
get :preview
|
||||
get :check, to: redirect {|path_params, req| "/iqdb_queries?#{req.query_string}"}
|
||||
@@ -183,7 +182,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
resource :order, :only => [:edit], :controller => "pool_orders"
|
||||
end
|
||||
resource :pool_element, :only => [:create, :destroy] do
|
||||
resource :pool_element, :only => [:create, :destroy] do
|
||||
collection do
|
||||
get :all_select
|
||||
end
|
||||
@@ -303,12 +302,12 @@ Rails.application.routes.draw do
|
||||
resources :fposts, :controller => "forum_posts"
|
||||
|
||||
# legacy aliases
|
||||
get "/artist" => redirect {|params, req| "/artists?page=#{req.params[:page]}&search[name]=#{CGI::escape(req.params[:name].to_s)}"}
|
||||
get "/artist" => redirect {|params, req| "/artists?page=#{req.params[:page]}&search[name]=#{CGI.escape(req.params[:name].to_s)}"}
|
||||
get "/artist/index.xml", :controller => "legacy", :action => "artists", :format => "xml"
|
||||
get "/artist/index.json", :controller => "legacy", :action => "artists", :format => "json"
|
||||
get "/artist/index" => redirect {|params, req| "/artists?page=#{req.params[:page]}"}
|
||||
get "/artist/show/:id" => redirect("/artists/%{id}")
|
||||
get "/artist/show" => redirect {|params, req| "/artists?name=#{CGI::escape(req.params[:name].to_s)}"}
|
||||
get "/artist/show" => redirect {|params, req| "/artists?name=#{CGI.escape(req.params[:name].to_s)}"}
|
||||
get "/artist/history/:id" => redirect("/artist_versions?search[artist_id]=%{id}")
|
||||
get "/artist/recent_changes" => redirect("/artist_versions")
|
||||
|
||||
@@ -318,7 +317,7 @@ Rails.application.routes.draw do
|
||||
get "/comment/new" => redirect("/comments")
|
||||
get("/comment/search" => redirect do |params, req|
|
||||
if req.params[:query] =~ /^user:(.+)/i
|
||||
"/comments?group_by=comment&search[creator_name]=#{CGI::escape($1)}"
|
||||
"/comments?group_by=comment&search[creator_name]=#{CGI.escape($1)}"
|
||||
else
|
||||
"/comments/search"
|
||||
end
|
||||
@@ -333,7 +332,7 @@ Rails.application.routes.draw do
|
||||
get "/forum/show/:id" => redirect {|params, req| "/forum_posts/#{req.params[:id]}?page=#{req.params[:page]}"}
|
||||
get "/forum/search" => redirect("/forum_posts/search")
|
||||
|
||||
get "/help/:title" => redirect {|params, req| ("/wiki_pages?title=#{CGI::escape('help:' + req.params[:title])}")}
|
||||
get "/help/:title" => redirect {|params, req| "/wiki_pages?title=#{CGI.escape('help:' + req.params[:title])}"}
|
||||
|
||||
get "/note" => redirect {|params, req| "/notes?page=#{req.params[:page]}"}
|
||||
get "/note/index" => redirect {|params, req| "/notes?page=#{req.params[:page]}"}
|
||||
@@ -348,12 +347,12 @@ Rails.application.routes.draw do
|
||||
get "/post/index.xml", :controller => "legacy", :action => "posts", :format => "xml"
|
||||
get "/post/index.json", :controller => "legacy", :action => "posts", :format => "json"
|
||||
get "/post/piclens", :controller => "legacy", :action => "unavailable"
|
||||
get "/post/index" => redirect {|params, req| "/posts?tags=#{CGI::escape(req.params[:tags].to_s)}&page=#{req.params[:page]}"}
|
||||
get "/post" => redirect {|params, req| "/posts?tags=#{CGI::escape(req.params[:tags].to_s)}&page=#{req.params[:page]}"}
|
||||
get "/post/index" => redirect {|params, req| "/posts?tags=#{CGI.escape(req.params[:tags].to_s)}&page=#{req.params[:page]}"}
|
||||
get "/post" => redirect {|params, req| "/posts?tags=#{CGI.escape(req.params[:tags].to_s)}&page=#{req.params[:page]}"}
|
||||
get "/post/upload" => redirect("/uploads/new")
|
||||
get "/post/moderate" => redirect("/moderator/post/queue")
|
||||
get "/post/atom" => redirect {|params, req| "/posts.atom?tags=#{CGI::escape(req.params[:tags].to_s)}"}
|
||||
get "/post/atom.feed" => redirect {|params, req| "/posts.atom?tags=#{CGI::escape(req.params[:tags].to_s)}"}
|
||||
get "/post/atom" => redirect {|params, req| "/posts.atom?tags=#{CGI.escape(req.params[:tags].to_s)}"}
|
||||
get "/post/atom.feed" => redirect {|params, req| "/posts.atom?tags=#{CGI.escape(req.params[:tags].to_s)}"}
|
||||
get "/post/popular_by_day" => redirect("/explore/posts/popular")
|
||||
get "/post/popular_by_week" => redirect("/explore/posts/popular")
|
||||
get "/post/popular_by_month" => redirect("/explore/posts/popular")
|
||||
@@ -372,10 +371,10 @@ Rails.application.routes.draw do
|
||||
|
||||
get "/tag/index.xml", :controller => "legacy", :action => "tags", :format => "xml"
|
||||
get "/tag/index.json", :controller => "legacy", :action => "tags", :format => "json"
|
||||
get "/tag" => redirect {|params, req| "/tags?page=#{req.params[:page]}&search[name_matches]=#{CGI::escape(req.params[:name].to_s)}&search[order]=#{req.params[:order]}&search[category]=#{req.params[:type]}"}
|
||||
get "/tag/index" => redirect {|params, req| "/tags?page=#{req.params[:page]}&search[name_matches]=#{CGI::escape(req.params[:name].to_s)}&search[order]=#{req.params[:order]}"}
|
||||
get "/tag" => redirect {|params, req| "/tags?page=#{req.params[:page]}&search[name_matches]=#{CGI.escape(req.params[:name].to_s)}&search[order]=#{req.params[:order]}&search[category]=#{req.params[:type]}"}
|
||||
get "/tag/index" => redirect {|params, req| "/tags?page=#{req.params[:page]}&search[name_matches]=#{CGI.escape(req.params[:name].to_s)}&search[order]=#{req.params[:order]}"}
|
||||
|
||||
get "/tag_implication" => redirect {|params, req| "/tag_implications?search[name_matches]=#{CGI::escape(req.params[:query].to_s)}"}
|
||||
get "/tag_implication" => redirect {|params, req| "/tag_implications?search[name_matches]=#{CGI.escape(req.params[:query].to_s)}"}
|
||||
|
||||
get "/user/index.xml", :controller => "legacy", :action => "users", :format => "xml"
|
||||
get "/user/index.json", :controller => "legacy", :action => "users", :format => "json"
|
||||
@@ -392,7 +391,7 @@ Rails.application.routes.draw do
|
||||
get "/wiki" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"}
|
||||
get "/wiki/index" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"}
|
||||
get "/wiki/rename" => redirect("/wiki_pages")
|
||||
get "/wiki/show" => redirect {|params, req| "/wiki_pages?title=#{CGI::escape(req.params[:title].to_s)}"}
|
||||
get "/wiki/show" => redirect {|params, req| "/wiki_pages?title=#{CGI.escape(req.params[:title].to_s)}"}
|
||||
get "/wiki/recent_changes" => redirect {|params, req| "/wiki_page_versions?search[updater_id]=#{req.params[:user_id]}"}
|
||||
get "/wiki/history/:title" => redirect("/wiki_page_versions?title=%{title}")
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ user 'danbooru', 'danbooru'
|
||||
# Fill path to your app
|
||||
working_directory app_path
|
||||
|
||||
# Should be 'production' by default, otherwise use other env
|
||||
# Should be 'production' by default, otherwise use other env
|
||||
rails_env = ENV['RAILS_ENV'] || 'production'
|
||||
|
||||
# Log everything to one file
|
||||
|
||||
@@ -5,7 +5,7 @@ app_path = "/var/www/danbooru2/current"
|
||||
worker_processes 20
|
||||
|
||||
timeout 180
|
||||
#listen "127.0.0.1:9000", :tcp_nopush => true
|
||||
# listen "127.0.0.1:9000", :tcp_nopush => true
|
||||
listen "/tmp/.unicorn.sock", :backlog => 512
|
||||
|
||||
# Spawn unicorn master worker for user apps (group: apps)
|
||||
@@ -41,7 +41,7 @@ run_once = true
|
||||
before_fork do |server, worker|
|
||||
# the following is highly recomended for Rails + "preload_app true"
|
||||
# as there's no need for the master process to hold a connection
|
||||
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
|
||||
defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect!
|
||||
|
||||
# Occasionally, it may be necessary to run non-idempotent code in the
|
||||
# master before forking. Keep in mind the above disconnect! example
|
||||
|
||||
@@ -14,7 +14,7 @@ user 'danbooru', 'danbooru'
|
||||
# Fill path to your app
|
||||
working_directory app_path
|
||||
|
||||
# Should be 'production' by default, otherwise use other env
|
||||
# Should be 'production' by default, otherwise use other env
|
||||
rails_env = ENV['RAILS_ENV'] || 'staging'
|
||||
|
||||
# Log everything to one file
|
||||
@@ -26,8 +26,8 @@ pid "#{app_path}/tmp/pids/unicorn.pid"
|
||||
|
||||
before_fork do |server, worker|
|
||||
old_pid = "#{server.config[:pid]}.oldbin"
|
||||
|
||||
if File.exists?(old_pid) && server.pid != old_pid
|
||||
|
||||
if File.exist?(old_pid) && server.pid != old_pid
|
||||
begin
|
||||
Process.kill("QUIT", File.read(old_pid).to_i)
|
||||
rescue Errno::ENOENT, Errno::ESRCH
|
||||
@@ -44,4 +44,4 @@ after_fork do |server, worker|
|
||||
if defined?(ActiveRecord::Base)
|
||||
ActiveRecord::Base.establish_connection
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user