forked from saurabh/orbit4-5
modified zh_cn render method. removed extra code from page_controller show method
This commit is contained in:
parent
cbf1114c4f
commit
9a4ef31352
|
@ -89,13 +89,7 @@ class PagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
impressionist(page)
|
impressionist(page)
|
||||||
final_page = render_final_page("#{module_app}/#{params[:target_action]}",page,layout)
|
render :html => render_final_page("#{module_app}/#{params[:target_action]}",page,layout).html_safe
|
||||||
if session[:zh_cn]
|
|
||||||
final_page = ZhConv.convert("zh-cn", final_page)
|
|
||||||
final_page.gsub!('/zh_tw/','/zh_cn/')
|
|
||||||
final_page.sub!('<a href="/zh_cn/news">繁体中文</a>','<a href="/zh_tw/news">繁体中文</a>')
|
|
||||||
end
|
|
||||||
render :html => final_page.html_safe
|
|
||||||
else
|
else
|
||||||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => :not_found
|
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => :not_found
|
||||||
end
|
end
|
||||||
|
@ -227,6 +221,7 @@ class PagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_final_page(original_view=get_view,page,layout)
|
def render_final_page(original_view=get_view,page,layout)
|
||||||
|
final_html_for_render = ""
|
||||||
if layout
|
if layout
|
||||||
parts = $mobile.blank? ? (page.page_parts rescue []) : (page.mobile_page_parts rescue [])
|
parts = $mobile.blank? ? (page.page_parts rescue []) : (page.mobile_page_parts rescue [])
|
||||||
|
|
||||||
|
@ -282,11 +277,13 @@ class PagesController < ApplicationController
|
||||||
end
|
end
|
||||||
link = doc.css("link")[0]
|
link = doc.css("link")[0]
|
||||||
link.attributes["href"].value = current_site.favicon.url.nil? ? "/assets/favicon.ico" : current_site.favicon.url
|
link.attributes["href"].value = current_site.favicon.url.nil? ? "/assets/favicon.ico" : current_site.favicon.url
|
||||||
doc.to_html
|
final_html_for_render = doc.to_html
|
||||||
|
|
||||||
else
|
else
|
||||||
render_to_string(original_view)
|
final_html_for_render = render_to_string(original_view)
|
||||||
end
|
end
|
||||||
|
final_html_for_render = change_to_language(final_html_for_render)
|
||||||
|
final_html_for_render
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_widget_path(widget)
|
def get_widget_path(widget)
|
||||||
|
@ -350,4 +347,14 @@ class PagesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def change_to_language(final_html)
|
||||||
|
if session[:zh_cn]
|
||||||
|
final_html = ZhConv.convert("zh-cn", final_html)
|
||||||
|
final_html.gsub!('/zh_tw/','/zh_cn/')
|
||||||
|
final_html.sub!('<a href="/zh_cn/news">繁体中文</a>','<a href="/zh_tw/news">繁体中文</a>')
|
||||||
|
end
|
||||||
|
final_html
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue