forgeplus/app/controllers/main_controller.rb

48 lines
1.7 KiB
Ruby
Raw Permalink Normal View History

2020-03-09 00:40:16 +08:00
class MainController < ApplicationController
protect_from_forgery except: :index
skip_before_action :check_sign
skip_before_action :user_setup
skip_before_action :setup_laboratory
def first_stamp
render :json => { status: 0, message: Time.now.to_i }
end
2023-08-30 09:13:05 +08:00
def test_404
status_code = 404
status = status_code.to_s
fname = %w[404 403 422 500].include?(status) ? status : "unknown"
respond_to do |format|
format.html { render template: "/shared/#{fname}", handler: [:erb], status: status }
2023-08-30 09:23:56 +08:00
format.xml { render :xml => Laboratory.limit(1).to_xml, status: status }
2023-08-30 09:13:05 +08:00
format.all { render body: nil, status: status }
end
end
2020-03-09 00:40:16 +08:00
def index
2024-06-11 10:28:55 +08:00
Rails.logger.info("request.referer============#{request.referer},#{params[:path]}") if request.referer.to_s.include?("educoder.net")
2020-03-09 00:40:16 +08:00
domain_session = params[:_educoder_session]
if domain_session
uid_logger("main start domain_session is #{domain_session}")
if cookies[:_educoder_session] != domain_session
cookies[:_educoder_session] = nil
cookies[:_educoder_session] = domain_session
end
uid_logger("main start is #{cookies[:_educoder_session]}")
end
# TODO: 这块之后需要整合者架构重新变化统一跳转到index后再路由分发
if params[:path] && params[:path]&.include?("h5educoderbuild") && params[:path].split("/").first == "h5educoderbuild"
2021-10-08 14:04:13 +08:00
render file: 'public/h5educoderbuild/index.html', :layout => false, :content_type=> 'text/html'
2023-08-30 09:13:05 +08:00
elsif params[:path].to_s.include?("test_404")
test_404
2020-03-09 00:40:16 +08:00
else
2021-10-08 14:04:13 +08:00
render file: 'public/react/build/index.html', :layout => false, :content_type=> 'text/html'
2020-03-09 00:40:16 +08:00
end
end
end