From c0ea68c9b95c71485cb917d82b362cb000b933e0 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Tue, 9 Oct 2012 19:36:17 +0900 Subject: [PATCH] t#29693:test layout flag move to magic number --- app/controllers/artists_controller.rb | 2 +- app/controllers/authors_controller.rb | 1 + app/controllers/balloons_controller.rb | 1 + app/controllers/colors_controller.rb | 2 +- app/controllers/comics_controller.rb | 2 +- app/controllers/ground_colors_controller.rb | 2 +- app/controllers/ground_pictures_controller.rb | 2 +- app/controllers/home_controller.rb | 2 +- app/controllers/license_groups_controller.rb | 2 +- app/controllers/licenses_controller.rb | 2 +- .../original_picture_license_groups_controller.rb | 2 +- app/controllers/original_pictures_controller.rb | 2 +- app/controllers/panel_colors_controller.rb | 2 +- app/controllers/panel_pictures_controller.rb | 2 +- app/controllers/panels_controller.rb | 2 +- app/controllers/pictures_controller.rb | 2 +- app/controllers/resource_pictures_controller.rb | 2 +- app/controllers/speech_balloon_templates_controller.rb | 2 +- app/controllers/speech_balloons_controller.rb | 1 + app/controllers/speeches_controller.rb | 1 + app/controllers/stories_controller.rb | 2 +- app/controllers/system_controller.rb | 4 ++-- app/controllers/system_pictures_controller.rb | 2 +- app/views/layouts/test.html.erb | 1 + config/application.rb | 18 +++++------------- 25 files changed, 30 insertions(+), 33 deletions(-) diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index afacb4a3..aab67cb5 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,5 +1,5 @@ class ArtistsController < ApplicationController -layout 'test' + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy] before_filter :authenticate_admin!, :only => [:list, :browse] diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index da744884..7e2055ba 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -1,4 +1,5 @@ class AuthorsController < ApplicationController + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show, :edit, :update] before_filter :authenticate_admin!, :only => [:list, :browse] diff --git a/app/controllers/balloons_controller.rb b/app/controllers/balloons_controller.rb index 4d2bd336..8b588804 100644 --- a/app/controllers/balloons_controller.rb +++ b/app/controllers/balloons_controller.rb @@ -1,4 +1,5 @@ class BalloonsController < ApplicationController + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_admin!, :only => [:list, :browse] def list diff --git a/app/controllers/colors_controller.rb b/app/controllers/colors_controller.rb index d125dbb1..ea99428d 100644 --- a/app/controllers/colors_controller.rb +++ b/app/controllers/colors_controller.rb @@ -1,5 +1,5 @@ class ColorsController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] # GET /colors # GET /colors.json diff --git a/app/controllers/comics_controller.rb b/app/controllers/comics_controller.rb index 41073259..bac6ee00 100644 --- a/app/controllers/comics_controller.rb +++ b/app/controllers/comics_controller.rb @@ -1,5 +1,5 @@ class ComicsController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/ground_colors_controller.rb b/app/controllers/ground_colors_controller.rb index 459f0b3e..48797907 100644 --- a/app/controllers/ground_colors_controller.rb +++ b/app/controllers/ground_colors_controller.rb @@ -1,5 +1,5 @@ class GroundColorsController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index] # GET /ground_colors diff --git a/app/controllers/ground_pictures_controller.rb b/app/controllers/ground_pictures_controller.rb index 755c4199..64152649 100644 --- a/app/controllers/ground_pictures_controller.rb +++ b/app/controllers/ground_pictures_controller.rb @@ -1,5 +1,5 @@ class GroundPicturesController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index] # GET /ground_pictures diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index af11ec46..fdc3fe3e 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,5 +1,5 @@ class HomeController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [ :index, :show, :profile, :configure, :create_token, :delete_token, :step2, :save_step2, :step3, :save_step3, :comic, :panel, :picture, :panel_picture, :panel_color, :ground_picture, :ground_color diff --git a/app/controllers/license_groups_controller.rb b/app/controllers/license_groups_controller.rb index df576d8c..4433053b 100644 --- a/app/controllers/license_groups_controller.rb +++ b/app/controllers/license_groups_controller.rb @@ -1,5 +1,5 @@ class LicenseGroupsController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_admin!, :only => [:list, :browse] # GET /license_groups diff --git a/app/controllers/licenses_controller.rb b/app/controllers/licenses_controller.rb index 72c99331..59e24e20 100644 --- a/app/controllers/licenses_controller.rb +++ b/app/controllers/licenses_controller.rb @@ -1,5 +1,5 @@ class LicensesController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_admin!, :only => [:list, :browse] # GET /licenses diff --git a/app/controllers/original_picture_license_groups_controller.rb b/app/controllers/original_picture_license_groups_controller.rb index 296e3b29..fd85ceab 100644 --- a/app/controllers/original_picture_license_groups_controller.rb +++ b/app/controllers/original_picture_license_groups_controller.rb @@ -1,5 +1,5 @@ class OriginalPictureLicenseGroupsController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:new, :create] before_filter :authenticate_artist, :only => [:new, :create] diff --git a/app/controllers/original_pictures_controller.rb b/app/controllers/original_pictures_controller.rb index 3e5d9068..e322b6c5 100644 --- a/app/controllers/original_pictures_controller.rb +++ b/app/controllers/original_pictures_controller.rb @@ -1,6 +1,6 @@ #原画 class OriginalPicturesController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show, :history, :new, :edit, :create, :update, :destroy] before_filter :authenticate_admin!, :only => [:list, :browse] before_filter :authenticate_artist, :only => [:index, :show, :history, :new, :edit, :create, :update, :destroy] diff --git a/app/controllers/panel_colors_controller.rb b/app/controllers/panel_colors_controller.rb index 2d43bef3..11343791 100644 --- a/app/controllers/panel_colors_controller.rb +++ b/app/controllers/panel_colors_controller.rb @@ -1,5 +1,5 @@ class PanelColorsController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index] # GET /ground_pictures diff --git a/app/controllers/panel_pictures_controller.rb b/app/controllers/panel_pictures_controller.rb index d7695a6d..dc5cd21c 100644 --- a/app/controllers/panel_pictures_controller.rb +++ b/app/controllers/panel_pictures_controller.rb @@ -1,5 +1,5 @@ class PanelPicturesController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show] before_filter :authenticate_admin!, :only => [:list, :browse] diff --git a/app/controllers/panels_controller.rb b/app/controllers/panels_controller.rb index 4065e12a..544ecc08 100644 --- a/app/controllers/panels_controller.rb +++ b/app/controllers/panels_controller.rb @@ -1,5 +1,5 @@ class PanelsController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show, :new, :edit, :create, :update, :destroy] before_filter :authenticate_admin!, :only => [:list, :browse] diff --git a/app/controllers/pictures_controller.rb b/app/controllers/pictures_controller.rb index 850ef318..30dd929c 100644 --- a/app/controllers/pictures_controller.rb +++ b/app/controllers/pictures_controller.rb @@ -1,5 +1,5 @@ class PicturesController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:show, :credit, :md5] before_filter :authenticate_artist, :only => [:md5] diff --git a/app/controllers/resource_pictures_controller.rb b/app/controllers/resource_pictures_controller.rb index 5be77b5a..70542774 100644 --- a/app/controllers/resource_pictures_controller.rb +++ b/app/controllers/resource_pictures_controller.rb @@ -1,5 +1,5 @@ class ResourcePicturesController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show, :credit, :new, :create, :update] before_filter :authenticate_admin!, :only => [:list, :browse] before_filter :authenticate_artist, :only => [:new, :create] diff --git a/app/controllers/speech_balloon_templates_controller.rb b/app/controllers/speech_balloon_templates_controller.rb index 9f5bbd98..77a808da 100644 --- a/app/controllers/speech_balloon_templates_controller.rb +++ b/app/controllers/speech_balloon_templates_controller.rb @@ -1,5 +1,5 @@ class SpeechBalloonTemplatesController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show] before_filter :authenticate_admin!, :only => [:list, :browse, :destroy] diff --git a/app/controllers/speech_balloons_controller.rb b/app/controllers/speech_balloons_controller.rb index 85a39e28..2152cd1c 100644 --- a/app/controllers/speech_balloons_controller.rb +++ b/app/controllers/speech_balloons_controller.rb @@ -1,4 +1,5 @@ class SpeechBalloonsController < ApplicationController + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_admin!, :only => [:list, :browse] def list diff --git a/app/controllers/speeches_controller.rb b/app/controllers/speeches_controller.rb index 7e53b73f..b9a3c7b5 100644 --- a/app/controllers/speeches_controller.rb +++ b/app/controllers/speeches_controller.rb @@ -1,4 +1,5 @@ class SpeechesController < ApplicationController + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show] before_filter :authenticate_admin!, :only => [:list, :browse] diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index c8b710ce..bcb470ee 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -1,5 +1,5 @@ class StoriesController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/system_controller.rb b/app/controllers/system_controller.rb index 20ac6e41..d8cbb0b1 100644 --- a/app/controllers/system_controller.rb +++ b/app/controllers/system_controller.rb @@ -58,14 +58,14 @@ class SystemController < ApplicationController end def production_layout - Pettanr::Application.test_layout = false + MagicNumber['test_layout'] = false respond_to do |format| format.html { render text: 'production', status: 200 } end end def test_layout - Pettanr::Application.test_layout = 'test' + MagicNumber['test_layout'] = 'test' respond_to do |format| format.html { render text: 'test', status: 200 } end diff --git a/app/controllers/system_pictures_controller.rb b/app/controllers/system_pictures_controller.rb index 4d341f7e..ec7d4cb2 100644 --- a/app/controllers/system_pictures_controller.rb +++ b/app/controllers/system_pictures_controller.rb @@ -1,5 +1,5 @@ class SystemPicturesController < ApplicationController - layout 'test' if Pettanr::Application.test_layout + layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user!, :only => [:index, :show] before_filter :authenticate_admin!, :only => [:list, :browse, :new, :create] diff --git a/app/views/layouts/test.html.erb b/app/views/layouts/test.html.erb index 45a8b706..cb151c10 100644 --- a/app/views/layouts/test.html.erb +++ b/app/views/layouts/test.html.erb @@ -3,6 +3,7 @@ Pettanr <%= stylesheet_link_tag "application" %> + <%= stylesheet_link_tag "test.css" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> diff --git a/config/application.rb b/config/application.rb index 683056d2..66efbccc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -63,24 +63,16 @@ config.assets.initialize_on_precompile = false def self.licenses @@licenses end - - def self.test_layout=(arg) - @@test_layout = arg - end - - def self.test_layout - @@test_layout - end end end -if File.exist? Rails.root + 'config/test_layout' - Pettanr::Application.test_layout = 'test' -else - Pettanr::Application.test_layout = false -end Pettanr::Application.licenses = YAML.load(open(Rails.root + 'config/license.yml').read) MagicNumber = YAML.load(open(Rails.root + 'config/magic_number.yml').read) +MagicNumber['test_layout'] = if File.exist? Rails.root + 'config/test_layout' + 'test' +else + false +end y = YAML.load(open(Rails.root + 'config/picture_io.yml').read) require y[Rails.env]["adapter"] pio = PictureIO.const_get y[Rails.env]["io"] -- 2.11.0