Mercurial > zeropaste
changeset 437:d31fe32da7a0
Finish updating to rails 5
author | nanaya <me@myconan.net> |
---|---|
date | Sat, 02 Jul 2016 17:04:25 +0900 |
parents | 72557a5310d9 |
children | a5eae5b07abf |
files | .hgignore Gemfile Gemfile.lock Rakefile app/assets/config/manifest.js app/helpers/application_helper.rb app/helpers/pastes_helper.rb bin/run_test config.ru config/application.rb config/config_init.rb config/config_local_env.rb.example config/default_config.rb config/environments/development.rb config/environments/production.rb config/init_config.rb config/initializers/cookies_serializer.rb config/initializers/new_framework_defaults.rb config/initializers/secret_token.rb config/local_config.rb.example |
diffstat | 20 files changed, 153 insertions(+), 119 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Mon Jun 13 15:07:38 2016 +0900 +++ b/.hgignore Sat Jul 02 17:04:25 2016 +0900 @@ -1,6 +1,6 @@ ^\.bundle$ ^config/database\.yml$ -^config/local_config\.rb$ +^config/config_local_(\w+)\.rb$ ^config/newrelic\.yml$ ^config/unicorn\.rb$ ^log$
--- a/Gemfile Mon Jun 13 15:07:38 2016 +0900 +++ b/Gemfile Sat Jul 02 17:04:25 2016 +0900 @@ -1,8 +1,8 @@ source "https://rubygems.org" -gem "rails", ">= 5.0.0.rc1", "< 5.1" +gem "rails", "~> 5.0.0" gem "jquery-rails" -gem "coffee-rails", "~> 4.1.0" # Rails 4.2 default +gem "coffee-rails", "~> 4.2" # Rails 4.2 default gem "bootstrap-sass" source "https://rails-assets.org" do @@ -39,6 +39,4 @@ gem "newrelic_rpm" end -group :development do - gem "quiet_assets" -end +gem "puma", :require => false
--- a/Gemfile.lock Mon Jun 13 15:07:38 2016 +0900 +++ b/Gemfile.lock Sat Jul 02 17:04:25 2016 +0900 @@ -2,60 +2,60 @@ remote: https://rubygems.org/ remote: https://rails-assets.org/ specs: - actioncable (5.0.0.rc1) - actionpack (= 5.0.0.rc1) + actioncable (5.0.0) + actionpack (= 5.0.0) nio4r (~> 1.2) websocket-driver (~> 0.6.1) - actionmailer (5.0.0.rc1) - actionpack (= 5.0.0.rc1) - actionview (= 5.0.0.rc1) - activejob (= 5.0.0.rc1) + actionmailer (5.0.0) + actionpack (= 5.0.0) + actionview (= 5.0.0) + activejob (= 5.0.0) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (5.0.0.rc1) - actionview (= 5.0.0.rc1) - activesupport (= 5.0.0.rc1) - rack (~> 2.x) + rails-dom-testing (~> 2.0) + actionpack (5.0.0) + actionview (= 5.0.0) + activesupport (= 5.0.0) + rack (~> 2.0) rack-test (~> 0.6.3) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.0.rc1) - activesupport (= 5.0.0.rc1) + actionview (5.0.0) + activesupport (= 5.0.0) builder (~> 3.1) erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (5.0.0.rc1) - activesupport (= 5.0.0.rc1) + activejob (5.0.0) + activesupport (= 5.0.0) globalid (>= 0.3.6) - activemodel (5.0.0.rc1) - activesupport (= 5.0.0.rc1) - activerecord (5.0.0.rc1) - activemodel (= 5.0.0.rc1) - activesupport (= 5.0.0.rc1) + activemodel (5.0.0) + activesupport (= 5.0.0) + activerecord (5.0.0) + activemodel (= 5.0.0) + activesupport (= 5.0.0) arel (~> 7.0) - activesupport (5.0.0.rc1) + activesupport (5.0.0) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) arel (7.0.0) - autoprefixer-rails (6.3.6) + autoprefixer-rails (6.3.6.2) execjs bootstrap-sass (3.3.6) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) builder (3.2.2) - coffee-rails (4.1.1) + coffee-rails (4.2.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.1.x) + railties (>= 4.0.0, < 5.2.x) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.10.0) concurrent-ruby (1.0.2) erubis (2.7.0) - execjs (2.6.0) + execjs (2.7.0) globalid (0.3.6) activesupport (>= 4.1.0) i18n (0.7.0) @@ -63,79 +63,75 @@ rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (1.8.3) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.4) mime-types (>= 1.16, < 4) method_source (0.8.2) - mime-types (3.0) + mime-types (3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0221) - mini_portile2 (2.0.0) - minitest (5.8.4) - newrelic_rpm (3.15.2.317) + mime-types-data (3.2016.0521) + mini_portile2 (2.1.0) + minitest (5.9.0) + newrelic_rpm (3.16.0.318) nio4r (1.2.1) - nokogiri (1.6.7.2) - mini_portile2 (~> 2.0.0.rc2) + nokogiri (1.6.8) + mini_portile2 (~> 2.1.0) + pkg-config (~> 1.1.7) pg (0.18.4) - quiet_assets (1.1.0) - railties (>= 3.1, < 5.0) - rack (2.0.0.rc1) - json + pkg-config (1.1.7) + puma (3.4.0) + rack (2.0.1) rack-test (0.6.3) rack (>= 1.0) - rails (5.0.0.rc1) - actioncable (= 5.0.0.rc1) - actionmailer (= 5.0.0.rc1) - actionpack (= 5.0.0.rc1) - actionview (= 5.0.0.rc1) - activejob (= 5.0.0.rc1) - activemodel (= 5.0.0.rc1) - activerecord (= 5.0.0.rc1) - activesupport (= 5.0.0.rc1) + rails (5.0.0) + actioncable (= 5.0.0) + actionmailer (= 5.0.0) + actionpack (= 5.0.0) + actionview (= 5.0.0) + activejob (= 5.0.0) + activemodel (= 5.0.0) + activerecord (= 5.0.0) + activesupport (= 5.0.0) bundler (>= 1.3.0, < 2.0) - railties (= 5.0.0.rc1) + railties (= 5.0.0) sprockets-rails (>= 2.0.0) rails-assets-commonmark (0.25.1) - rails-assets-highlightjs (9.2.0) - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) + rails-assets-highlightjs (9.4.0) + rails-dom-testing (2.0.1) + activesupport (>= 4.2.0, < 6.0) nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (5.0.0.rc1) - actionpack (= 5.0.0.rc1) - activesupport (= 5.0.0.rc1) + railties (5.0.0) + actionpack (= 5.0.0) + activesupport (= 5.0.0) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (11.1.2) + rake (11.2.2) sass (3.4.22) - sass-rails (5.0.4) - railties (>= 4.0.0, < 5.0) + sass-rails (5.0.5) + railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sprockets (3.6.0) + sprockets (3.6.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.0.4) + sprockets-rails (3.1.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) thor (0.19.1) thread_safe (0.3.5) - tilt (2.0.3) + tilt (2.0.5) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (3.0.0) execjs (>= 0.3.0, < 3) - websocket-driver (0.6.3) + websocket-driver (0.6.4) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) @@ -145,13 +141,13 @@ DEPENDENCIES activerecord-jdbcpostgresql-adapter bootstrap-sass - coffee-rails (~> 4.1.0) + coffee-rails (~> 4.2) jquery-rails jruby-openssl newrelic_rpm pg - quiet_assets - rails (>= 5.0.0.rc1, < 5.1) + puma + rails (~> 5.0.0) rails-assets-commonmark! rails-assets-highlightjs! sass-rails (~> 5.0)
--- a/Rakefile Mon Jun 13 15:07:38 2016 +0900 +++ b/Rakefile Sat Jul 02 17:04:25 2016 +0900 @@ -2,6 +2,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require_relative "config/application" -Zeropaste::Application.load_tasks +Rails.application.load_tasks
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/assets/config/manifest.js Sat Jul 02 17:04:25 2016 +0900 @@ -0,0 +1,2 @@ +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css
--- a/app/helpers/application_helper.rb Mon Jun 13 15:07:38 2016 +0900 +++ b/app/helpers/application_helper.rb Sat Jul 02 17:04:25 2016 +0900 @@ -11,4 +11,10 @@ def error_class(object, attribute) "has-error" if object.errors.include? attribute end + + def with_host(url) + return url if url[0] != "/" + + "#{request.protocol}#{request.host_with_port}#{url}" + end end
--- a/app/helpers/pastes_helper.rb Mon Jun 13 15:07:38 2016 +0900 +++ b/app/helpers/pastes_helper.rb Sat Jul 02 17:04:25 2016 +0900 @@ -3,7 +3,7 @@ if @paste.errors.any? "Failed" else - url = paste_path @paste, :only_path => false + url = with_url paste_path(@paste) if @fresh "#{url} (key: #{@paste.key})" else
--- a/bin/run_test Mon Jun 13 15:07:38 2016 +0900 +++ b/bin/run_test Sat Jul 02 17:04:25 2016 +0900 @@ -19,8 +19,8 @@ # local_config. touch config/local_config.rb cat << EOF > config/local_config.rb -CONFIG["standalone"] = true -CONFIG["secret_key"] = "$(bundle exec rake secret)" +\$cfg[:standalone] = true +\$cfg[:secret_key] = "$(bundle exec rake secret)" EOF fi
--- a/config.ru Mon Jun 13 15:07:38 2016 +0900 +++ b/config.ru Sat Jul 02 17:04:25 2016 +0900 @@ -1,6 +1,7 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require_relative "config/environment" + map (ENV['RAILS_RELATIVE_URL_ROOT'] || '/') do - run Zeropaste::Application + run Rails.application end
--- a/config/application.rb Mon Jun 13 15:07:38 2016 +0900 +++ b/config/application.rb Sat Jul 02 17:04:25 2016 +0900 @@ -6,16 +6,13 @@ require "active_record/railtie" require "action_controller/railtie" # require "action_mailer/railtie" -# require "active_resource/railtie" require "sprockets/railtie" require "rails/test_unit/railtie" -require_relative "init_config" -suppress(LoadError) { require_relative "local_config" } -require_relative "default_config" +require_relative "config_init" # If you precompile assets before deploying to production, use this line -Bundler.require(*CONFIG["bundler_groups"]) +Bundler.require(*$cfg[:bundler_groups]) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/config_init.rb Sat Jul 02 17:04:25 2016 +0900 @@ -0,0 +1,17 @@ +$cfg = {} +$cfg[:secret_key] = ENV["ZP_SECRET_KEY"] +$cfg[:newrelic] = ENV["ZP_NEWRELIC"] == 1 + +config_local = File.expand_path("config_local_#{Rails.env}.rb", __dir__) + +require config_local if File.exist? config_local + +$cfg[:standalone] = true if $cfg[:standalone].nil? +$cfg[:newrelic] = false if $cfg[:newrelic].nil? +$cfg[:log_to_stdout] = true if $cfg[:log_to_stdout].nil? + +$cfg[:bundler_groups] ||= [:default, Rails.env] +$cfg[:bundler_groups] << "standalone" if $cfg[:standalone] +$cfg[:bundler_groups] << "newrelic" if $cfg[:newrelic] + +$cfg.freeze
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/config_local_env.rb.example Sat Jul 02 17:04:25 2016 +0900 @@ -0,0 +1,19 @@ +# Required: generate with `bundle exec secret` +# +# $cfg[:secret_key] = "FILL_IN_HERE" +# Or set environment variable ZP_SECRET_KEY + +# Set to false if you want to use different web server (e.g. passenger) +# Default is set to use standalone server: +# - MRI Ruby: Unicorn +# - JRuby and Rubinius: Puma +# $cfg[:standalone] = true + +# Set to true to use newrelic monitoring. +# Don't forget to put your newrelic.yml in config directory. +# Default: false +# $cfg[:newrelic] = false +# Or set environment variable ZP_NEWRELIC to 1 +# + +# If you want to deploy with just environment variable, also set ZP_DATABASE_URL or DATABASE_URL.
--- a/config/default_config.rb Mon Jun 13 15:07:38 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -CONFIG["standalone"] = true if CONFIG["standalone"].nil? -CONFIG["newrelic"] = false if CONFIG["newrelic"].nil? -CONFIG["log_to_stdout"] = true if CONFIG["log_to_stdout"].nil? -CONFIG["bundler_groups"] ||= [:default, Rails.env] -CONFIG["bundler_groups"] << "standalone" if CONFIG["standalone"] -CONFIG["bundler_groups"] << "newrelic" if CONFIG["newrelic"] - -CONFIG["secret_key"] ||= ENV["ZP_SECRET_KEY"] if ENV["ZP_SECRET_KEY"] -CONFIG["newrelic"] = (ENV["ZP_NEWRELIC"] == 1) if ENV["ZP_NEWRELIC"]
--- a/config/environments/development.rb Mon Jun 13 15:07:38 2016 +0900 +++ b/config/environments/development.rb Sat Jul 02 17:04:25 2016 +0900 @@ -42,6 +42,9 @@ # Raises error for missing translations. config.action_view.raise_on_missing_translations = true + # Suppress logger output for asset requests. + config.assets.quiet = true + # Use an evented file watcher to asynchronously detect changes in source code # routes, locales, etc. This feature depends on the listen gem. # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
--- a/config/environments/production.rb Mon Jun 13 15:07:38 2016 +0900 +++ b/config/environments/production.rb Sat Jul 02 17:04:25 2016 +0900 @@ -77,8 +77,8 @@ # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') - if CONFIG["log_to_stdout"] - logger = ActiveSupport::Logger.new(STDOUT) + if $cfg[:log_to_stdout] + logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end
--- a/config/init_config.rb Mon Jun 13 15:07:38 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -CONFIG = {}
--- a/config/initializers/cookies_serializer.rb Mon Jun 13 15:07:38 2016 +0900 +++ b/config/initializers/cookies_serializer.rb Sat Jul 02 17:04:25 2016 +0900 @@ -2,4 +2,4 @@ # Specify a serializer for the signed and encrypted cookie jars. # Valid options are :json, :marshal, and :hybrid. -Rails.application.config.action_dispatch.cookies_serializer = :marshal +Rails.application.config.action_dispatch.cookies_serializer = :json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/new_framework_defaults.rb Sat Jul 02 17:04:25 2016 +0900 @@ -0,0 +1,24 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.0 upgrade. +# +# Read the Rails 5.0 release notes for more info on each option. + +# Enable per-form CSRF tokens. Previous versions had false. +Rails.application.config.action_controller.per_form_csrf_tokens = true + +# Enable origin-checking CSRF mitigation. Previous versions had false. +Rails.application.config.action_controller.forgery_protection_origin_check = true + +# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. +# Previous versions had false. +ActiveSupport.to_time_preserves_timezone = true + +# Require `belongs_to` associations by default. Previous versions had false. +Rails.application.config.active_record.belongs_to_required_by_default = true + +# Do not halt callback chains when a callback returns false. Previous versions had true. +ActiveSupport.halt_callback_chains_on_return_false = false + +# Configure SSL options to enable HSTS with subdomains. Previous versions had false. +Rails.application.config.ssl_options = { hsts: { subdomains: true } }
--- a/config/initializers/secret_token.rb Mon Jun 13 15:07:38 2016 +0900 +++ b/config/initializers/secret_token.rb Sat Jul 02 17:04:25 2016 +0900 @@ -1,1 +1,1 @@ -Zeropaste::Application.config.secret_key_base = CONFIG["secret_key"] +Rails.application.config.secret_key_base = $cfg[:secret_key]
--- a/config/local_config.rb.example Mon Jun 13 15:07:38 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -# Required: generate with `bundle exec secret` -# -# CONFIG['secret_key'] = 'FILL_IN_HERE' -# Or set environment variable ZP_SECRET_KEY - -# Set to false if you want to use different web server (e.g. passenger) -# Default is set to use standalone server: -# - MRI Ruby: Unicorn -# - JRuby and Rubinius: Puma -# CONFIG['standalone'] = true - -# Set to true to use newrelic monitoring. -# Don't forget to put your newrelic.yml in config directory. -# Default: false -# CONFIG['newrelic'] = false -# Or set environment variable ZP_NEWRELIC to 1 -# - -# If you want to deploy with just environment variable, also set ZP_DATABASE_URL or DATABASE_URL.