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
|
file.close
|
||||||
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
|
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
|
||||||
data = controller.send("#{params[:target_action]}")
|
data = controller.send("#{params[:target_action]}")
|
||||||
wrap_elements = doc.css("*[data-list][data-level='0']")
|
if !data.nil?
|
||||||
htmls = parsing_repeats_again(wrap_elements,data,1)
|
wrap_elements = doc.css("*[data-list][data-level='0']")
|
||||||
html = doc.to_s
|
htmls = parsing_repeats_again(wrap_elements,data,1)
|
||||||
htmls[0].each_with_index do |h,i|
|
html = doc.to_s
|
||||||
html = html.gsub(h,htmls[1][i])
|
htmls[0].each_with_index do |h,i|
|
||||||
end
|
html = html.gsub(h,htmls[1][i])
|
||||||
|
|
||||||
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
|
||||||
end
|
|
||||||
total_pages = data['total_pages'].to_i rescue 1
|
if data["extras"]
|
||||||
if total_pages > 1
|
data["extras"].each do |key,value|
|
||||||
html = html.gsub("{{pagination_goes_here}}",create_pagination(total_pages))
|
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
|
else
|
||||||
html = html.gsub("{{pagination_goes_here}}","");
|
""
|
||||||
end
|
end
|
||||||
html.html_safe
|
|
||||||
else
|
else
|
||||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb")
|
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb")
|
||||||
if File.exists?f
|
if File.exists?f
|
||||||
|
@ -237,7 +241,7 @@ module ApplicationHelper
|
||||||
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
|
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
|
||||||
data = controller.send("#{params[:target_action]}")
|
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")
|
file = File.open("#{Rails.root}/public/404.html")
|
||||||
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
||||||
file.close
|
file.close
|
||||||
|
|
|
@ -63,19 +63,23 @@ module PagesHelper
|
||||||
controller = "#{controller_name.capitalize.pluralize}_controller".classify.constantize.new
|
controller = "#{controller_name.capitalize.pluralize}_controller".classify.constantize.new
|
||||||
OrbitHelper.set_current_widget_module controller_name
|
OrbitHelper.set_current_widget_module controller_name
|
||||||
data = controller.send("#{widget_method}")
|
data = controller.send("#{widget_method}")
|
||||||
wrap_elements = doc.css("*[data-list][data-level='0']")
|
if !data.nil?
|
||||||
htmls = parsing_repeats_again(wrap_elements,data,1)
|
wrap_elements = doc.css("*[data-list][data-level='0']")
|
||||||
html = doc.to_s
|
htmls = parsing_repeats_again(wrap_elements,data,1)
|
||||||
htmls[0].each_with_index do |h,i|
|
html = doc.to_s
|
||||||
html = html.gsub(h,htmls[1][i])
|
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
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue