forked from saurabh/orbit4-5
now page will render not give 500 error if controller doesnt send anything back
This commit is contained in:
parent
8c0d4f53b0
commit
6f3e951ba8
|
@ -207,27 +207,31 @@ module ApplicationHelper
|
|||
file.close
|
||||
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
|
||||
data = controller.send("#{params[:target_action]}")
|
||||
wrap_elements = doc.css("*[data-list][data-level='0']")
|
||||
htmls = parsing_repeats_again(wrap_elements,data,1)
|
||||
html = doc.to_s
|
||||
htmls[0].each_with_index do |h,i|
|
||||
html = html.gsub(h,htmls[1][i])
|
||||
end
|
||||
|
||||
if data["extras"]
|
||||
data["extras"].each do |key,value|
|
||||
value = value.nil? ? "" : value
|
||||
html = html.gsub("{{#{key}}}",value.to_s)
|
||||
html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
|
||||
if !data.nil?
|
||||
wrap_elements = doc.css("*[data-list][data-level='0']")
|
||||
htmls = parsing_repeats_again(wrap_elements,data,1)
|
||||
html = doc.to_s
|
||||
htmls[0].each_with_index do |h,i|
|
||||
html = html.gsub(h,htmls[1][i])
|
||||
end
|
||||
end
|
||||
total_pages = data['total_pages'].to_i rescue 1
|
||||
if total_pages > 1
|
||||
html = html.gsub("{{pagination_goes_here}}",create_pagination(total_pages))
|
||||
|
||||
if data["extras"]
|
||||
data["extras"].each do |key,value|
|
||||
value = value.nil? ? "" : value
|
||||
html = html.gsub("{{#{key}}}",value.to_s)
|
||||
html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
|
||||
end
|
||||
end
|
||||
total_pages = data['total_pages'].to_i rescue 1
|
||||
if total_pages > 1
|
||||
html = html.gsub("{{pagination_goes_here}}",create_pagination(total_pages))
|
||||
else
|
||||
html = html.gsub("{{pagination_goes_here}}","");
|
||||
end
|
||||
html.html_safe
|
||||
else
|
||||
html = html.gsub("{{pagination_goes_here}}","");
|
||||
""
|
||||
end
|
||||
html.html_safe
|
||||
else
|
||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb")
|
||||
if File.exists?f
|
||||
|
@ -237,7 +241,7 @@ module ApplicationHelper
|
|||
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
|
||||
data = controller.send("#{params[:target_action]}")
|
||||
|
||||
if data.blank? || data.empty?
|
||||
if data.blank? || data.empty? || data.nil?
|
||||
file = File.open("#{Rails.root}/public/404.html")
|
||||
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
||||
file.close
|
||||
|
|
|
@ -63,19 +63,23 @@ module PagesHelper
|
|||
controller = "#{controller_name.capitalize.pluralize}_controller".classify.constantize.new
|
||||
OrbitHelper.set_current_widget_module controller_name
|
||||
data = controller.send("#{widget_method}")
|
||||
wrap_elements = doc.css("*[data-list][data-level='0']")
|
||||
htmls = parsing_repeats_again(wrap_elements,data,1)
|
||||
html = doc.to_s
|
||||
htmls[0].each_with_index do |h,i|
|
||||
html = html.gsub(h,htmls[1][i])
|
||||
if !data.nil?
|
||||
wrap_elements = doc.css("*[data-list][data-level='0']")
|
||||
htmls = parsing_repeats_again(wrap_elements,data,1)
|
||||
html = doc.to_s
|
||||
htmls[0].each_with_index do |h,i|
|
||||
html = html.gsub(h,htmls[1][i])
|
||||
end
|
||||
extras = data['extras'] || {}
|
||||
extras["widget-title"] = OrbitHelper.widget_title
|
||||
extras.each do |key,value|
|
||||
html = html.gsub("{{#{key}}}",value.to_s.html_safe)
|
||||
html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
|
||||
end
|
||||
html.html_safe
|
||||
else
|
||||
""
|
||||
end
|
||||
extras = data['extras'] || {}
|
||||
extras["widget-title"] = OrbitHelper.widget_title
|
||||
extras.each do |key,value|
|
||||
html = html.gsub("{{#{key}}}",value.to_s.html_safe)
|
||||
html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue