From c9c6ccde73964b22289890f27c59f8800a0a425a Mon Sep 17 00:00:00 2001 From: Bohung Date: Mon, 3 Jan 2022 22:09:11 +0800 Subject: [PATCH] Fix bug. --- app/models/site_feed_annc.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/site_feed_annc.rb b/app/models/site_feed_annc.rb index d149db7..c29d281 100644 --- a/app/models/site_feed_annc.rb +++ b/app/models/site_feed_annc.rb @@ -46,6 +46,7 @@ class SiteFeedAnnc end end cache_data = {} + site_root_url = Site.first.root_url rescue "" locales.each do |locale| locale = locale.to_s data_for_locale = anns.collect do |a| @@ -94,7 +95,7 @@ class SiteFeedAnnc tmp["source-site-link"] = tmp["source-site"] tmp["source-site"] = "#{tmp["source-site-title"]}" tmp["link_to_show"] = !tmp["external_link"].blank? ? tmp["external_link"] : nil - tmp["target"] = "_self" + tmp["target"] = (site_root_url.blank? || tmp["link_to_show"].blank?) ? '_blank' : (tmp["link_to_show"].include?(site_root_url) ? '_self' : '_blank') tmp["img_src"] = tmp["image"]["thumb"] || "/assets/announcement-default.jpg" tmp["img_description"] = tmp["image_description_translations"][locale] tmp["more"] = trans[locale]['more_plus']