Fix event_news iframe bugs.

This commit is contained in:
BoHung Chiu 2020-08-03 17:11:57 +08:00
parent d97ea7e255
commit 0f70ab18b5
3 changed files with 14 additions and 9 deletions

View File

@ -369,6 +369,7 @@ class EventNewsController < ApplicationController
else else
@categories = params[:categories] @categories = params[:categories]
end end
OrbitHelper.set_site_locale(I18n.locale)
OrbitHelper.set_current_widget_module("event_news") OrbitHelper.set_current_widget_module("event_news")
OrbitHelper.set_params(params,current_user) OrbitHelper.set_params(params,current_user)
EventNews.remove_expired_status EventNews.remove_expired_status
@ -413,7 +414,7 @@ class EventNewsController < ApplicationController
"is_top" => (a.is_top? ? 1 : 0), "is_top" => (a.is_top? ? 1 : 0),
"link_to_show" => link_to_show+"\" title=\"#{title}\"", "link_to_show" => link_to_show+"\" title=\"#{title}\"",
"target" => target, "target" => target,
"img_src" => a.image.thumb.url || "/assets/event_news-default.jpg", "img_src" => a.image.thumb.url || "/assets/announcement-default.jpg",
"img_description" => desc, "img_description" => desc,
"more" => t(:more_plus), "more" => t(:more_plus),
"view_count" => a.view_count "view_count" => a.view_count

View File

@ -248,7 +248,7 @@ module EventNewsHelper
total_pages = page_data_count == 0 ? 1 : (annc_count.to_f / page_data_count).ceil total_pages = page_data_count == 0 ? 1 : (annc_count.to_f / page_data_count).ceil
[sorted,total_pages] [sorted,total_pages]
end end
def render_view_for_annc(overridehtml=nil) def render_view_for_event_news(overridehtml=nil)
@key = Site.first.template @key = Site.first.template
def render_link_to_edit(html, url_to_edit) def render_link_to_edit(html, url_to_edit)
if html.scan("{{link_to_edit}}").length == 0 if html.scan("{{link_to_edit}}").length == 0
@ -307,7 +307,7 @@ module EventNewsHelper
file = File.open(f) file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8") doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close file.close
controller = EventNewsModuleController.new controller = EventNewsController.new
begin begin
data = @data# rescue nil data = @data# rescue nil
rescue Exception => e rescue Exception => e
@ -344,7 +344,7 @@ module EventNewsHelper
file = File.open(f) file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8") doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close file.close
controller = EventNewsModuleController.new controller = EventNewsController.new
begin begin
data = @data# rescue nil data = @data# rescue nil
rescue Exception => e rescue Exception => e
@ -416,13 +416,17 @@ module EventNewsHelper
end end
end end
html = Nokogiri::HTML.parse(html) html = Nokogiri::HTML.parse(html)
html.css('.i-annc__page-title').remove html.css('.i-event_news__page-title').remove
dates = html.css("*[date-format]") dates = html.css("*[date-format]")
if !dates.blank? if !dates.blank?
dates.each do |d| dates.each do |d|
begin
format = d.attributes["date-format"].value format = d.attributes["date-format"].value
date = DateTime.parse(d.inner_text) date = DateTime.parse(d.inner_text)
d.inner_html = d.inner_html.gsub(d.inner_text.strip, " " + date.strftime(format)) d.inner_html = d.inner_html.gsub(d.inner_text.strip, " " + date.strftime(format))
rescue
next
end
end end
end end
html.css("body").to_html.html_safe html.css("body").to_html.html_safe

View File

@ -10,6 +10,6 @@
</head> </head>
<body> <body>
<% @target_action = "show_widget" %> <% @target_action = "show_widget" %>
<%=render_view_for_annc((!params[:layout_type].blank? ? params[:layout_type] : 'annc_index1'))%> <%=render_view_for_event_news((!params[:layout_type].blank? ? params[:layout_type] : 'event_news_index1'))%>
</body> </body>
</html> </html>