forked from saurabh/orbit4-5
made frontend kernel more stable .. now should not break in any case
This commit is contained in:
parent
9b42eb4e8b
commit
32c6975f76
|
@ -40,6 +40,9 @@ module ApplicationHelper
|
||||||
temp_title = params[:slug].sub("-#{params[:uid]}","")
|
temp_title = params[:slug].sub("-#{params[:uid]}","")
|
||||||
temp_title = temp_title.gsub("-"," ")
|
temp_title = temp_title.gsub("-"," ")
|
||||||
title = "#{temp_title} | #{title}"
|
title = "#{temp_title} | #{title}"
|
||||||
|
elsif params[:target_action] == "index"
|
||||||
|
temp_title = Page.find_by(:page_id => params[:page_id]).name
|
||||||
|
title = "#{temp_title} | #{title}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
title
|
title
|
||||||
|
@ -201,6 +204,9 @@ module ApplicationHelper
|
||||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:layout_type]}.html.erb")
|
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:layout_type]}.html.erb")
|
||||||
if !File.exists?f
|
if !File.exists?f
|
||||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "index.html.erb")
|
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "index.html.erb")
|
||||||
|
if !File.exists?f
|
||||||
|
return "<div class='well'>Maybe the administrator has changed the theme, please select the index page design again from the page settings.</div>".html_safe
|
||||||
|
end
|
||||||
end
|
end
|
||||||
file = File.open(f)
|
file = File.open(f)
|
||||||
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
||||||
|
@ -214,14 +220,14 @@ module ApplicationHelper
|
||||||
htmls[0].each_with_index do |h,i|
|
htmls[0].each_with_index do |h,i|
|
||||||
html = html.gsub(h,htmls[1][i])
|
html = html.gsub(h,htmls[1][i])
|
||||||
end
|
end
|
||||||
|
extras = data["extras"] || {}
|
||||||
if data["extras"]
|
extras["page-title"] = Page.find_by(:page_id => params[:page_id]).name rescue "" if !extras["page-title"]
|
||||||
data["extras"].each do |key,value|
|
extras.each do |key,value|
|
||||||
value = value.nil? ? "" : value
|
value = value.nil? ? "" : value
|
||||||
html = html.gsub("{{#{key}}}",value.to_s)
|
html = html.gsub("{{#{key}}}",value.to_s)
|
||||||
html = html.gsub("%7B%7B#{key}%7D%7D",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
|
total_pages = data['total_pages'].to_i rescue 1
|
||||||
if total_pages > 1
|
if total_pages > 1
|
||||||
html = html.gsub("{{pagination_goes_here}}",create_pagination(total_pages))
|
html = html.gsub("{{pagination_goes_here}}",create_pagination(total_pages))
|
||||||
|
@ -230,7 +236,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
html.html_safe
|
html.html_safe
|
||||||
else
|
else
|
||||||
return "<div>It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible, Sorry for the inconvenience!! :( </div>".html_safe
|
return "<div class='well'>It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible. Sorry for the inconvenience!! :( </div>".html_safe
|
||||||
end
|
end
|
||||||
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")
|
||||||
|
@ -241,7 +247,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]}") rescue nil
|
data = controller.send("#{params[:target_action]}") rescue nil
|
||||||
if data.nil?
|
if data.nil?
|
||||||
return "<div>It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible, Sorry for the inconvenience!! :( </div>".html_safe
|
return "<div class='well'>It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible. Sorry for the inconvenience!! :( </div>".html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.blank? || data.empty?
|
if data.blank? || data.empty?
|
||||||
|
@ -285,17 +291,18 @@ module ApplicationHelper
|
||||||
htmls[0].each_with_index do |h,i|
|
htmls[0].each_with_index do |h,i|
|
||||||
html = html.gsub(h,htmls[1][i])
|
html = html.gsub(h,htmls[1][i])
|
||||||
end
|
end
|
||||||
if data["#{not_array_key}"]
|
extras = data["#{not_array_key}"] || {}
|
||||||
data["#{not_array_key}"].each do |key,value|
|
extras.each do |key,value|
|
||||||
next if key.eql? 'impressionist'
|
next if key.eql? 'impressionist'
|
||||||
value = value.nil? ? "" : value
|
value = value.nil? ? "" : value
|
||||||
html = html.gsub("{{#{key}}}",value.to_s)
|
html = html.gsub("{{#{key}}}",value.to_s)
|
||||||
html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
|
html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
return "<div class='well'>There is a problem with the design. We will try to fix it as soon as possible. Sorry for the inconvenience!! :(</div>".html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,7 +50,12 @@ module PagesHelper
|
||||||
if !File.exists?f
|
if !File.exists?f
|
||||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'widgets', "#{controller_name}", "_#{widget_file}.html.erb");
|
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'widgets', "#{controller_name}", "_#{widget_file}.html.erb");
|
||||||
if !File.exists?f
|
if !File.exists?f
|
||||||
f = File.join('../templates', "#{@key}", 'modules', "#{controller_name}", "_widget.html.erb");
|
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', "#{controller_name}", "_widget.html.erb");
|
||||||
|
if File.exists?f
|
||||||
|
f = File.join('../templates', "#{@key}", 'modules', "#{controller_name}", "_widget.html.erb");
|
||||||
|
else
|
||||||
|
return "<div class='well'>Maybe the administrator has changed the theme, please select the widget design again from the page settings.</div>".html_safe
|
||||||
|
end
|
||||||
else
|
else
|
||||||
f = File.join('../templates', "#{@key}", 'widgets', "#{controller_name}", "_#{widget_file}.html.erb");
|
f = File.join('../templates', "#{@key}", 'widgets', "#{controller_name}", "_#{widget_file}.html.erb");
|
||||||
end
|
end
|
||||||
|
@ -78,7 +83,7 @@ module PagesHelper
|
||||||
end
|
end
|
||||||
html.html_safe
|
html.html_safe
|
||||||
else
|
else
|
||||||
return "<div>It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible, Sorry for the inconvenience!! :( </div>".html_safe
|
return "<div class='well'>It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible. Sorry for the inconvenience!! :( </div>".html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue