Kill trailing whitespace in ruby files

This commit is contained in:
小太
2013-03-19 23:10:10 +11:00
parent c107f96cec
commit cba839ba76
319 changed files with 2710 additions and 2710 deletions

View File

@@ -10,7 +10,7 @@ end
module Danbooru
class Application < Rails::Application
config.active_record.schema_format = :sql
config.encoding = "utf-8"
config.filter_parameters += [:password]

View File

@@ -6,102 +6,102 @@ module Danbooru
def version
"2.1.0"
end
# The name of this Danbooru.
def app_name
"Danbooru"
end
# The hostname of the server.
def hostname
Socket.gethostname
end
# Contact email address of the admin.
def contact_email
"webmaster@#{server_host}"
end
def upgrade_account_email
contact_email
end
# Stripped of any special characters.
def safe_app_name
app_name.gsub(/[^a-zA-Z0-9_-]/, "_")
end
# The default name to use for anyone who isn't logged in.
def default_guest_name
"Anonymous"
end
# This is a salt used to make dictionary attacks on account passwords harder.
def password_salt
"choujin-steiner"
end
# Set to true to allow new account signups.
def enable_signups?
true
end
# Set to true to give all new users privileged access.
def start_as_privileged?
false
end
# Set to true to give all new users contributor access.
def start_as_contributor?
false
end
# 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
# Thumbnail size
def small_image_width
150
end
# Large resize image width. Set to nil to disable.
def large_image_width
850
end
def large_image_prefix
"sample-"
end
# When calculating statistics based on the posts table, gather this many posts to sample from.
def post_sample_size
300
end
# If a solid state drive is availble, cache the thumbnails on the SSD to reduce disk seek times.
def ssd_path
nil
end
# Where the ad banners are stored in the file system
def advertisement_path
nil
end
# List of memcached servers
def memcached_servers
%w(localhost:11211)
end
# After a post receives this many comments, new comments will no longer bump the post in comment/index.
def comment_threshold
40
end
# Members cannot post more than X comments in an hour.
def member_comment_limit
2
@@ -111,12 +111,12 @@ module Danbooru
def can_see_ads?(user)
!user.is_privileged?
end
# Users cannot search for more than X regular tags at a time.
def base_tag_query_limit
6
end
def tag_query_limit
if CurrentUser.user.present?
CurrentUser.user.tag_query_limit
@@ -124,43 +124,43 @@ module Danbooru
base_tag_query_limit * 2
end
end
# Max number of posts to cache
def tag_subscription_post_limit
200
end
# After this many pages, the paginator will switch to sequential mode.
def max_numbered_pages
1_000
end
# Max number of tag subscriptions per user
def max_tag_subscriptions
5
end
# Maximum size of an upload.
def max_file_size
25.megabytes
end
def member_comment_time_threshold
1.week.ago
end
# The name of the server the app is hosted on.
def server_host
Socket.gethostname
end
# Names of all Danbooru servers which serve out of the same common database.
# 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.
def all_server_hosts
[server_host]
end
# Names of other Danbooru servers.
def other_server_hosts
@other_server_hosts ||= all_server_hosts.reject {|x| x == server_host}
@@ -169,7 +169,7 @@ module Danbooru
def remote_server_login
"albert"
end
# 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
@@ -189,7 +189,7 @@ module Danbooru
"ch" => 4
}
end
def canonical_tag_category_mapping
@canonical_tag_category_mapping ||= {
"General" => 0,
@@ -198,7 +198,7 @@ module Danbooru
"Character" => 4
}
end
# 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
@@ -209,18 +209,18 @@ module Danbooru
4 => "Character"
}
end
# If enabled, users must verify their email addresses.
def enable_email_verification?
false
end
# Any custom code you want to insert into the default layout without
# having to modify the templates.
def custom_html_header_content
nil
end
# The number of posts displayed per page.
def posts_per_page
20
@@ -229,15 +229,15 @@ module Danbooru
def is_post_restricted?(post)
false
end
def is_user_restricted?(user)
!user.is_privileged?
end
def is_user_advertiser?(user)
user.is_admin?
end
def can_user_see_post?(user, post)
if is_user_restricted?(user) && is_post_restricted?(post)
false
@@ -245,59 +245,59 @@ module Danbooru
true
end
end
def select_posts_visible_to_user(user, posts)
posts.select {|x| can_user_see_post?(user, x)}
end
def max_appeals_per_day
1
end
# 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
def pixiv_login
nil
end
def pixiv_password
nil
end
def tinami_login
nil
end
def tinami_password
nil
end
def nico_seiga_login
nil
end
def nico_seiga_password
nil
end
def pixa_login
nil
end
def pixa_password
nil
end
def amazon_ses
# {:smtp_server_name => "smtp server", :user_name => "user name", :ses_smtp_user_name => "smtp user name", :ses_smtp_password => "smtp password"}
nil
end
def enable_dimension_autotagging
true
end

View File

@@ -47,14 +47,14 @@ namespace :data do
run "mkdir #{deploy_to}/shared/data/preview"
run "mkdir #{deploy_to}/shared/data/sample"
end
task :link_directories do
run "rm -f #{release_path}/public/data"
run "ln -s #{deploy_to}/shared/data #{release_path}/public/data"
run "rm -f #{release_path}/public/ssd"
run "ln -s /mnt/ssd#{deploy_to}/current/public #{release_path}/public/ssd"
run "rm -f #{release_path}/public/images/advertisements"
run "ln -s #{deploy_to}/shared/advertisements #{release_path}/public/images/advertisements"
end
@@ -72,31 +72,31 @@ namespace :deploy do
maintenance_html_path = "#{current_path}/public/maintenance.html.bak"
run "if [ -e #{maintenance_html_path} ] ; then mv #{maintenance_html_path} #{current_path}/public/maintenance.html ; fi"
end
desc "Makes the application web-accessible again."
task :enable do
maintenance_html_path = "#{current_path}/public/maintenance.html"
run "if [ -e #{maintenance_html_path} ] ; then mv #{maintenance_html_path} #{current_path}/public/maintenance.html.bak ; fi"
end
end
namespace :nginx do
desc "Shut down Nginx"
task :stop do
sudo "/etc/init.d/nginx stop"
end
desc "Start Nginx"
task :start do
sudo "/etc/init.d/nginx start"
end
end
desc "Precompiles assets"
task :precompile_assets do
run "cd #{current_path}; bundle exec rake assets:precompile"
end
desc "Restart the application"
task :restart do
run "touch #{current_path}/tmp/restart.txt"
@@ -108,21 +108,21 @@ namespace :delayed_job do
task :start, :roles => :app do
run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec ruby script/delayed_job --queues=default,`hostname` start"
end
desc "Stop delayed_job process"
task :stop, :roles => :app do
run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec ruby script/delayed_job stop"
end
desc "Restart delayed_job process"
task :restart, :roles => :app do
find_and_execute_task("delayed_job:stop")
find_and_execute_task("delayed_job:start")
end
task :kill, :roles => :app do
procs = capture("ps -A -o pid,command").split(/\r\n|\r|\n/).grep(/delayed_job/).map(&:to_i)
if procs.any?
run "for i in #{procs.join(' ')} ; do kill -SIGTERM $i ; done"
end

View File

@@ -2,14 +2,14 @@ module Danbooru
module Extensions
module ActiveRecordApi
extend ActiveSupport::Concern
def serializable_hash(options = {})
options ||= {}
options[:except] ||= []
options[:except] += hidden_attributes
super(options)
end
def to_xml(options = {}, &block)
# to_xml ignores serializable_hash
options ||= {}
@@ -17,7 +17,7 @@ module Danbooru
options[:except] += hidden_attributes
super(options, &block)
end
protected
def hidden_attributes
[:uploader_ip_addr, :updater_ip_addr, :creator_ip_addr, :ip_addr]

View File

@@ -2,7 +2,7 @@ module Danbooru
module Extensions
module ActiveRecord
extend ActiveSupport::Concern
module ClassMethods
def without_timeout
connection.execute("SET STATEMENT_TIMEOUT = 0") unless Rails.env == "test"
@@ -20,7 +20,7 @@ module Danbooru
connection.execute("SET STATEMENT_TIMEOUT = 3000") unless Rails.env == "test"
end
end
%w(execute select_value select_values select_all).each do |method_name|
define_method("#{method_name}_sql") do |sql, *params|
connection.__send__(method_name, self.class.sanitize_sql_array([sql, *params]))
@@ -30,20 +30,20 @@ module Danbooru
connection.__send__(method_name, sanitize_sql_array([sql, *params]))
end
end
def arbitrary_sql_order_clause(ids, table_name = nil)
table_name = self.class.table_name if table_name.nil?
if ids.empty?
return "#{table_name}.id desc"
end
conditions = []
ids.each_with_index do |x, n|
conditions << "when #{x} then #{n}"
end
"case #{table_name}.id " + conditions.join(" ") + " end"
end
end
@@ -51,7 +51,7 @@ module Danbooru
end
class ActiveRecord::Base
class << self
class << self
public :sanitize_sql_array
end

View File

@@ -12,7 +12,7 @@ module Danbooru
def to_escaped_for_tsquery
"'#{gsub(/'/, '\0\0').gsub(/\\/, '\0\0\0\0')}'"
end
def to_escaped_js
return self.gsub(/\\/, '\0\0').gsub(/['"]/) {|m| "\\#{m}"}.gsub(/\r\n|\r|\n/, '\\n')
end

View File

@@ -5,6 +5,6 @@ module Danbooru
def config
@configuration ||= CustomConfiguration.new
end
module_function :config
end

View File

@@ -72,7 +72,7 @@ end
QueryTrace.attach_to :active_record
trap('QUIT') do
# Sending 2 backspace characters removes the ^\ that is
# Sending 2 backspace characters removes the ^\ that is
# printed to the console.
rm_noise = "\b\b"

View File

@@ -188,7 +188,7 @@ Danbooru::Application.routes.draw do
get :upgrade_information
get :search
end
member do
delete :cache
post :upgrade
@@ -210,7 +210,7 @@ Danbooru::Application.routes.draw do
get :diff
end
end
# aliases
resources :wpages, :controller => "wiki_pages"
resources :ftopics, :controller => "forum_topics"
@@ -228,17 +228,17 @@ Danbooru::Application.routes.draw do
match "/artist/destroy/:id" => redirect("/artists/%{id}")
match "/artist/recent_changes" => redirect("/artist_versions")
match "/artist/create" => redirect("/artists")
match "/comment" => redirect {|params, req| "/comments?page=#{req.params[:page]}"}
match "/comment/index" => redirect {|params, req| "/comments?page=#{req.params[:page]}"}
match "/comment/show/:id" => redirect("/comments/%{id}")
match "/comment/new" => redirect("/comments")
match "/comment/search" => redirect("/comments/search")
match "/favorite" => redirect {|params, req| "/favorites?page=#{req.params[:page]}"}
match "/favorite/index" => redirect {|params, req| "/favorites?page=#{req.params[:page]}"}
match "/favorite/list_users.json", :controller => "legacy", :action => "unavailable"
match "/forum" => redirect {|params, req| "/forum_topics?page=#{req.params[:page]}"}
match "/forum/index" => redirect {|params, req| "/forum_topics?page=#{req.params[:page]}"}
match "/forum/show/:id" => redirect("/forum_posts/%{id}")
@@ -251,13 +251,13 @@ Danbooru::Application.routes.draw do
match "/note" => redirect {|params, req| "/notes?page=#{req.params[:page]}"}
match "/note/index" => redirect {|params, req| "/notes?page=#{req.params[:page]}"}
match "/note/history" => redirect("/note_versions")
match "/pool" => redirect {|params, req| "/pools?page=#{req.params[:page]}"}
match "/pool/index" => redirect {|params, req| "/pools?page=#{req.params[:page]}"}
match "/pool/show/:id" => redirect("/pools/%{id}")
match "/pool/history/:id" => redirect("/pool_versions?search[pool_id]=%{id}")
match "/pool/recent_changes" => redirect("/pool_versions")
match "/post/index.xml", :controller => "legacy", :action => "posts", :format => "xml"
match "/post/index.json", :controller => "legacy", :action => "posts", :format => "json"
match "/post/create.xml", :controller => "legacy", :action => "create_post", :format => "xml"
@@ -276,22 +276,22 @@ Danbooru::Application.routes.draw do
match "/post/view/:id/:tag_title" => redirect("/posts/%{id}")
match "/post/view/:id" => redirect("/posts/%{id}")
match "/post/flag/:id" => redirect("/posts/%{id}")
match "/post_tag_history" => redirect {|params, req| "/post_versions?page=#{req.params[:page]}"}
match "/post_tag_history/index" => redirect {|params, req| "/post_versions?page=#{req.params[:page]}"}
match "/tag/index.xml", :controller => "legacy", :action => "tags", :format => "xml"
match "/tag/index.json", :controller => "legacy", :action => "tags", :format => "json"
match "/tag" => redirect {|params, req| "/tags?page=#{req.params[:page]}"}
match "/tag/index" => redirect {|params, req| "/tags?page=#{req.params[:page]}"}
match "/user/index.xml", :controller => "legacy", :action => "users", :format => "xml"
match "/user/index.json", :controller => "legacy", :action => "users", :format => "json"
match "/user" => redirect {|params, req| "/users?page=#{req.params[:page]}"}
match "/user/index" => redirect {|params, req| "/users?page=#{req.params[:page]}"}
match "/user/show/:id" => redirect("/users/%{id}")
match "/user/login" => redirect("/sessions/new")
match "/wiki" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"}
match "/wiki/index" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"}
match "/wiki/revert" => redirect("/wiki_pages")
@@ -308,6 +308,6 @@ Danbooru::Application.routes.draw do
match "/static/contact" => "static#contact", :as => "contact"
match "/static/benchmark" => "static#benchmark"
match "/static/name_change" => "static#name_change", :as => "name_change"
root :to => "posts#index"
end

View File

@@ -26,7 +26,7 @@ if environment == "production"
every 1.hour do
runner "AmazonBackup.execute"
end
every 1.week do
runner "UserPasswordResetNonce.prune!"
end

View File

@@ -5,11 +5,11 @@ class StateChecker
end
private
def secret_token_path
File.expand_path("~/.danbooru/secret_token")
end
def check_secret_token
unless File.exists?(secret_token_path)
raise "You must create a file in #{secret_token_path} containing a secret key. It should be a string of at least 32 random characters."
@@ -23,7 +23,7 @@ private
def session_secret_key_path
File.expand_path("~/.danbooru/session_secret_key")
end
def check_session_secret_key
unless File.exists?(session_secret_key_path)
raise "You must create a file in #{session_secret_key_path} containing a secret key. It should be a string of at least 32 random characters."