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
@categories = params[:categories]
end
OrbitHelper.set_site_locale(I18n.locale)
OrbitHelper.set_current_widget_module("event_news")
OrbitHelper.set_params(params,current_user)
EventNews.remove_expired_status
@ -413,7 +414,7 @@ class EventNewsController < ApplicationController
"is_top" => (a.is_top? ? 1 : 0),
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
"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,
"more" => t(:more_plus),
"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
[sorted,total_pages]
end
def render_view_for_annc(overridehtml=nil)
def render_view_for_event_news(overridehtml=nil)
@key = Site.first.template
def render_link_to_edit(html, url_to_edit)
if html.scan("{{link_to_edit}}").length == 0
@ -307,7 +307,7 @@ module EventNewsHelper
file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
controller = EventNewsModuleController.new
controller = EventNewsController.new
begin
data = @data# rescue nil
rescue Exception => e
@ -344,7 +344,7 @@ module EventNewsHelper
file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
controller = EventNewsModuleController.new
controller = EventNewsController.new
begin
data = @data# rescue nil
rescue Exception => e
@ -416,13 +416,17 @@ module EventNewsHelper
end
end
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]")
if !dates.blank?
dates.each do |d|
format = d.attributes["date-format"].value
date = DateTime.parse(d.inner_text)
d.inner_html = d.inner_html.gsub(d.inner_text.strip, " " + date.strftime(format))
begin
format = d.attributes["date-format"].value
date = DateTime.parse(d.inner_text)
d.inner_html = d.inner_html.gsub(d.inner_text.strip, " " + date.strftime(format))
rescue
next
end
end
end
html.css("body").to_html.html_safe

View File

@ -10,6 +10,6 @@
</head>
<body>
<% @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>
</html>