X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fapplication_controller.rb;h=5b32d2ee05cc72efe401fc47482cf07f49639fca;hb=f9240d899023f9b75eb0a87f0a32c675d1149ee9;hp=b7496a238cc14645622726146ad3e17fa9e77023;hpb=93b359296a4d2da735cf200bea2476c2dffcee3f;p=pettanr%2Fpettanr.git diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b7496a23..5b32d2ee 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,8 +1,28 @@ class ApplicationController < ActionController::Base protect_from_forgery + layout :devise_layout if MagicNumber['test_layout'] before_filter :bf + def devise_layout + if devise_controller? + case resource_name + when :admin + 'test' + when :user + 'test' + when :demand_user + 'test' + end + else + 'application' + end + end + def bf + @server_result = { + :location => {:controller => params[:controller], :action => params[:action]} + } + @server_result[:location][:id] = params[:id] if params[:id] if Admin.count.to_i == 0 or License.count.to_i == 0 if params[:controller] == 'system' and params[:action] == 'start' else @@ -15,9 +35,34 @@ class ApplicationController < ActionController::Base @artist = if @author and @author.artist? @author.artist else - Artist.new author_id: @author.id, email: @user.email, name: @author.name + nil end end + @admin = if admin_signed_in? + current_admin + else + nil + end + @demand_user = if demand_user_signed_in? + current_demand_user + else + nil + end + end + end + + def authenticate_author + if @author + true + else + respond_to do |format| + format.html { redirect_to main_app.new_author_path, :status => :found } + format.js { render "authors/new" } + format.json { + raise ActiveRecord::Forbidden + } + end + false end end @@ -40,7 +85,7 @@ class ApplicationController < ActionController::Base if file.respond_to?(:read) file.read else - Base64.decode64(file.to_s.gsub(' ', '+')) #rubyのバグ?+でデコードされるべきキャラがスペースになる + Base64.decode64(file.to_s.gsub(' ', '+')) end end