sync
This commit is contained in:
@@ -1,33 +1,15 @@
|
||||
require File.expand_path('../boot', __FILE__)
|
||||
|
||||
require 'rails/all'
|
||||
|
||||
# Auto-require default libraries and those for the current Rails environment.
|
||||
Bundler.require :default, Rails.env
|
||||
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
||||
|
||||
module Danbooru
|
||||
class Application < Rails::Application
|
||||
# Add additional load paths for your own custom dirs
|
||||
config.load_paths += %W( #{config.root}/presenters #{config.root}/logical )
|
||||
|
||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||
# :all can be used as a placeholder for all plugins not explicitly named
|
||||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||
|
||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
|
||||
# config.i18n.default_locale = :de
|
||||
|
||||
# Configure generators values. Many other options are available, be sure to check the documentation.
|
||||
# config.generators do |g|
|
||||
# g.orm :active_record
|
||||
# g.template_engine :erb
|
||||
# g.test_framework :test_unit, :fixture => true
|
||||
# end
|
||||
|
||||
config.autoload_paths += %W(#{config.root}/app/presenters #{config.root}/app/logical)
|
||||
config.plugins = [:all]
|
||||
config.time_zone = 'Eastern Time (US & Canada)'
|
||||
config.encoding = "utf-8"
|
||||
config.active_record.schema_format = :sql
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
config.filter_parameters << :password
|
||||
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
# Use Bundler (preferred)
|
||||
require 'rubygems'
|
||||
|
||||
# Set up gems listed in the Gemfile.
|
||||
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
||||
begin
|
||||
require File.expand_path('../../.bundle/environment', __FILE__)
|
||||
rescue LoadError
|
||||
require 'rubygems'
|
||||
ENV['BUNDLE_GEMFILE'] = gemfile
|
||||
require 'bundler'
|
||||
Bundler.setup
|
||||
|
||||
# To use 2.x style vendor/rails and RubyGems
|
||||
#
|
||||
# vendor_rails = File.expand_path('../../vendor/rails', __FILE__)
|
||||
# if File.exist?(vendor_rails)
|
||||
# Dir["#{vendor_rails}/*/lib"].each { |path| $:.unshift(path) }
|
||||
# end
|
||||
#
|
||||
# require 'rubygems'
|
||||
end
|
||||
rescue Bundler::GemNotFound => e
|
||||
STDERR.puts e.message
|
||||
STDERR.puts "Try running `bundle install`."
|
||||
exit!
|
||||
end if File.exist?(gemfile)
|
||||
|
||||
@@ -16,4 +16,7 @@ Danbooru::Application.configure do
|
||||
|
||||
# Don't care if the mailer can't send
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Print deprecation notices to the Rails logger
|
||||
config.active_support.deprecation = :log
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Danboorus::Application.configure do
|
||||
Danbooru::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
|
||||
# The production environment is meant for finished, "live" apps.
|
||||
@@ -9,6 +9,15 @@ Danboorus::Application.configure do
|
||||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Specifies the header that your server uses for sending files
|
||||
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
||||
|
||||
# For nginx:
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
||||
|
||||
# If you have no front-end server that supports something like X-Sendfile,
|
||||
# just comment this out and Rails will serve the files
|
||||
|
||||
# See everything in the log (default is :info)
|
||||
# config.log_level = :debug
|
||||
|
||||
@@ -30,4 +39,11 @@ Danboorus::Application.configure do
|
||||
|
||||
# Enable threaded mode
|
||||
# config.threadsafe!
|
||||
|
||||
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
||||
# the I18n.default_locale when a translation can not be found)
|
||||
config.i18n.fallbacks = true
|
||||
|
||||
# Send deprecation notices to registered listeners
|
||||
config.active_support.deprecation = :notify
|
||||
end
|
||||
|
||||
@@ -14,6 +14,9 @@ Danbooru::Application.configure do
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Raise exceptions instead of rendering exception templates
|
||||
config.action_dispatch.show_exceptions = false
|
||||
|
||||
# Disable request forgery protection in test environment
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
@@ -26,4 +29,7 @@ Danbooru::Application.configure do
|
||||
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
||||
# like if you have constraints or database-specific column types
|
||||
# config.active_record.schema_format = :sql
|
||||
|
||||
# Print deprecation notices to the stderr
|
||||
config.active_support.deprecation = :stderr
|
||||
end
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key for verifying the integrity of signed cookies.
|
||||
# If you change this key, all old signed cookies will become invalid!
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
ActionController::Base.cookie_verifier_secret = '214c98302eef905ab8bce4a19562e322097c526f28e718160a3c0d617ddc8edab6ae7e22cb5eec8930e215bfb936a7086d6f5b146c0092a9af1884613ce0a260'
|
||||
@@ -1,31 +1,37 @@
|
||||
module Danbooru
|
||||
module Extensions
|
||||
module ActiveRecord
|
||||
%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]))
|
||||
end
|
||||
|
||||
self.class.__send__(:define_method, "#{method_name}_sql") do |sql, *params|
|
||||
connection.__send__(method_name, sanitize_sql_array([sql, *params]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module String
|
||||
def to_escaped_for_sql_like
|
||||
return self.gsub(/\\/, '\0\0').gsub(/%/, '\\%').gsub(/_/, '\\_').gsub(/\*/, '%')
|
||||
end
|
||||
|
||||
def to_escaped_js
|
||||
return self.gsub(/\\/, '\0\0').gsub(/['"]/) {|m| "\\#{m}"}.gsub(/\r\n|\r|\n/, '\\n')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ActiveRecord::Base
|
||||
class << self
|
||||
public :sanitize_sql_array
|
||||
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]))
|
||||
end
|
||||
|
||||
self.class.__send__(:define_method, "#{method_name}_sql") do |sql, *params|
|
||||
connection.__send__(method_name, sanitize_sql_array([sql, *params]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class NilClass
|
||||
def id
|
||||
raise NoMethodError
|
||||
end
|
||||
include Danbooru::Extensions::ActiveRecord
|
||||
end
|
||||
|
||||
class String
|
||||
def to_escaped_for_sql_like
|
||||
return self.gsub(/\\/, '\0\0').gsub(/%/, '\\%').gsub(/_/, '\\_').gsub(/\*/, '%')
|
||||
end
|
||||
|
||||
def to_escaped_js
|
||||
return self.gsub(/\\/, '\0\0').gsub(/['"]/) {|m| "\\#{m}"}.gsub(/\r\n|\r|\n/, '\\n')
|
||||
end
|
||||
include Danbooru::Extensions::String
|
||||
end
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
ActiveSupport::Inflector.inflections do |inflect|
|
||||
inflect.uncountable %w( user_feedback )
|
||||
end
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new inflection rules using the following format
|
||||
# (all these examples are active by default):
|
||||
# ActiveSupport::Inflector.inflections do |inflect|
|
||||
# inflect.plural /^(ox)$/i, '\1en'
|
||||
# inflect.singular /^(ox)en/i, '\1'
|
||||
# inflect.irregular 'person', 'people'
|
||||
# inflect.uncountable %w( fish sheep )
|
||||
# end
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key for verifying cookie session data integrity.
|
||||
# If you change this key, all old sessions will become invalid!
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
ActionController::Base.session = {
|
||||
:key => '_danbooru_session',
|
||||
:secret => '3102c705148af8124298f9e89d45da3d26e47cc4d9a67cb1c8d9c42c008ee253786346efda50331bb14811f1f445c1c9ed2d51597ad2017328de0dd263048d1a'
|
||||
}
|
||||
Danbooru::Application.config.session_store :cookie_store, :key => '_config_session'
|
||||
|
||||
# Use the database for sessions instead of the cookie-based default,
|
||||
# which shouldn't be used to store highly confidential information
|
||||
# (create the session table with "rake db:sessions:create")
|
||||
# ActionController::Base.session_store = :active_record_store
|
||||
# Config::Application.config.session_store :active_record_store
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Danbooru::Application.routes.draw do |map|
|
||||
Danbooru::Application.routes.draw do
|
||||
namespace :admin do
|
||||
resources :users
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user