forked from saurabh/orbit4-5
debug added for modules and widgets frontend
This commit is contained in:
parent
72c120c0ae
commit
449d809b35
|
@ -229,7 +229,11 @@ module ApplicationHelper
|
|||
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
||||
file.close
|
||||
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
|
||||
data = controller.send("#{params[:target_action]}") rescue nil
|
||||
begin
|
||||
data = controller.send("#{params[:target_action]}")# rescue nil
|
||||
rescue Exception => e
|
||||
write_debug_file(e,params[:target_controller],params[:target_action]) if Site::DEBUG
|
||||
end
|
||||
if !data.nil?
|
||||
wrap_elements = doc.css("*[data-list][data-level='0']")
|
||||
htmls = parsing_repeats_again(wrap_elements,data,1)
|
||||
|
@ -261,7 +265,11 @@ module ApplicationHelper
|
|||
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
||||
file.close
|
||||
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
|
||||
data = controller.send("#{params[:target_action]}") rescue nil
|
||||
begin
|
||||
data = controller.send("#{params[:target_action]}")# rescue nil
|
||||
rescue Exception => e
|
||||
write_debug_file(e,params[:target_controller],params[:target_action]) if Site::DEBUG
|
||||
end
|
||||
if data.nil?
|
||||
return "<div class='well'> No content to show. </div>".html_safe
|
||||
end
|
||||
|
@ -496,4 +504,43 @@ module ApplicationHelper
|
|||
target
|
||||
end
|
||||
|
||||
def write_debug_file(e,controller_name,action_name)
|
||||
directory_name = "tmp/debug"
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
fn = "#{directory_name}/#{controller_name}_#{action_name}.html"
|
||||
error_trace_spans = ""
|
||||
e.backtrace.each do |bt|
|
||||
error_trace_spans = error_trace_spans + "<span>#{bt}</span><br />"
|
||||
end
|
||||
con = "#{controller_name.capitalize}_controller".classify.constantize
|
||||
File.open(fn, "w"){ |file|
|
||||
file.puts "<html>
|
||||
<head>
|
||||
<title>Debug result</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Error Message</h3>
|
||||
<div class='error-message'>
|
||||
<h2><i>#{e.message}</i></h2>
|
||||
</div>
|
||||
<h3>Request Details</h3>
|
||||
<div class='request-details'>
|
||||
<span>Url : <b>#{request.url}</b> </span><br />
|
||||
<span>Controller : <b>#{con.to_s}</b> </span><br />
|
||||
<span>Action : <b>#{action_name.capitalize}</b> </span>
|
||||
</div>
|
||||
<h3>Error Trace</h3>
|
||||
<div class='error-trace'>
|
||||
#{error_trace_spans}
|
||||
</div>
|
||||
<h3>Params</h3>
|
||||
<div class='params'>
|
||||
#{OrbitHelper.params}
|
||||
</div>
|
||||
</body>
|
||||
</html>"
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -71,7 +71,11 @@ module PagesHelper
|
|||
wrap_elements = doc.css("*[data-repeat]")
|
||||
controller = "#{controller_name.capitalize.pluralize}_controller".classify.constantize.new
|
||||
OrbitHelper.set_current_widget_module controller_name
|
||||
data = controller.send("#{widget_method}") rescue nil
|
||||
begin
|
||||
data = controller.send("#{widget_method}") #rescue nil
|
||||
rescue Exception => e
|
||||
write_widget_debug_file(e,controller_name,widget_method,subpart_id)
|
||||
end
|
||||
if !data.nil?
|
||||
wrap_elements = doc.css("*[data-list][data-level='0']")
|
||||
htmls = widget_parsing_repeats_again(wrap_elements,data,1)
|
||||
|
@ -91,5 +95,45 @@ module PagesHelper
|
|||
end
|
||||
end
|
||||
|
||||
def write_widget_debug_file(e,controller_name,action_name,sub_part)
|
||||
directory_name = "tmp/debug"
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
fn = "#{directory_name}/#{controller_name}_#{action_name}_#{(sub_part if !sub_part.nil?)}.html"
|
||||
error_trace_spans = ""
|
||||
e.backtrace.each do |bt|
|
||||
error_trace_spans = error_trace_spans + "<span>#{bt}</span><br />"
|
||||
end
|
||||
con = "#{controller_name.capitalize.pluralize}_controller".classify.constantize
|
||||
File.open(fn, "w"){ |file|
|
||||
file.puts "<html>
|
||||
<head>
|
||||
<title>Debug result</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Error Message</h3>
|
||||
<div class='error-message'>
|
||||
<h2><i>#{e.message}</i></h2>
|
||||
</div>
|
||||
<h3>Request Details</h3>
|
||||
<div class='request-details'>
|
||||
<span>Url : <b>#{request.url}</b></span><br />
|
||||
<span>Controller : <b>#{con.to_s}</b></span><br />
|
||||
<span>Action : <b>#{action_name.capitalize}</b></span><br />
|
||||
<span>SubPart Id : <b>#{sub_part}</b></span>
|
||||
</div>
|
||||
<h3>Error Trace</h3>
|
||||
<div class='error-trace'>
|
||||
#{error_trace_spans}
|
||||
</div>
|
||||
<h3>Params</h3>
|
||||
<div class='params'>
|
||||
#{OrbitHelper.params}
|
||||
</div>
|
||||
</body>
|
||||
</html>"
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ class Site
|
|||
include Mongoid::Timestamps
|
||||
include Slug
|
||||
|
||||
DEBUG = false
|
||||
|
||||
field :title, as: :slug_title, type: String, localize: true
|
||||
field :school, type: String
|
||||
field :department, type: String
|
||||
|
|
Loading…
Reference in New Issue