1 class ApplicationController < ActionController::Base
3 layout :devise_layout if MagicNumber['test_layout']
23 :location => {:controller => params[:controller], :action => params[:action]}
25 @server_result[:location][:id] = params[:id] if params[:id]
26 if Admin.count.to_i == 0 or License.count.to_i == 0
27 if params[:controller] == 'system' and params[:action] == 'start'
29 redirect_to :controller => '/system', :action => 'start'
34 @author = @user.author
35 @artist = if @author and @author.artist?
41 @admin = if admin_signed_in?
46 @demand_user = if demand_user_signed_in?
54 def authenticate_author
58 respond_to do |format|
59 format.html { redirect_to main_app.new_author_path, :status => :found }
60 format.js { render "authors/new" }
62 raise ActiveRecord::Forbidden
69 def authenticate_artist
70 if @author and @author.artist?
73 respond_to do |format|
74 format.html { redirect_to main_app.new_artist_path, :status => :found }
75 format.js { render "artists/new" }
77 raise ActiveRecord::Forbidden
85 if file.respond_to?(:read)
88 Base64.decode64(file.to_s.gsub(' ', '+'))
92 if Rails.env == 'production'
93 rescue_from ActiveRecord::RecordNotFound, :with => :render_404
94 rescue_from ActiveRecord::Forbidden, :with => :render_403
97 def render_404(exception = nil)
99 logger.info "Rendering 404: #{exception.message}"
101 respond_to do |format|
103 render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
106 render :text => "404 Not found", :status => 404
111 def render_403(exception = nil)
113 logger.info "Rendering 403: #{exception.message}"
115 respond_to do |format|
117 render :file => "#{Rails.root}/public/403.html", :status => 404, :layout => false
120 render :text => "403 Forbidden", :status => 403