From ed06f3e8911e303df7d65f1dbe870bf27a35d8fa Mon Sep 17 00:00:00 2001 From: bohung Date: Mon, 3 Aug 2020 17:11:20 +0800 Subject: [PATCH] Fix announcement iframe bug. --- app/controllers/announcements_controller.rb | 1 + app/helpers/announcements_helper.rb | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index e1a5f14..d6314ae 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -371,6 +371,7 @@ class AnnouncementsController < ApplicationController else @categories = params[:categories] end + OrbitHelper.set_site_locale(I18n.locale) OrbitHelper.set_current_widget_module("announcement") OrbitHelper.set_params(params,current_user) Bulletin.remove_expired_status diff --git a/app/helpers/announcements_helper.rb b/app/helpers/announcements_helper.rb index 38b0252..77fbcfa 100644 --- a/app/helpers/announcements_helper.rb +++ b/app/helpers/announcements_helper.rb @@ -426,9 +426,13 @@ module AnnouncementsHelper 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