2020-04-05 14:36:09 +00:00
|
|
|
class SiteFeedAnnc
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
2021-12-30 09:46:30 +00:00
|
|
|
UseSourceUrl = SiteFeedSetting.first.use_source_url rescue false
|
2020-04-05 14:36:09 +00:00
|
|
|
field :top_list,type: Array,default: []
|
|
|
|
field :hot_list,type: Array,default: []
|
|
|
|
field :all_contents_for_feed
|
|
|
|
field :channel_key
|
|
|
|
field :feed_id
|
|
|
|
field :feed_name
|
|
|
|
field :category_title
|
|
|
|
field :hidden_annc,type: Array,default: []
|
|
|
|
field :merge_with_category
|
|
|
|
field :remote_site_url
|
|
|
|
field :channel_title
|
2022-05-22 10:36:26 +00:00
|
|
|
field :feeds_model
|
|
|
|
field :feeds_model
|
|
|
|
field :feeds_uid_field
|
|
|
|
field :feeds_update_callback
|
|
|
|
field :feeds_time_field, type: String, default: "postdate"
|
|
|
|
field :feeds_finish_callback
|
|
|
|
field :feeds_update_statuses_callback
|
2021-11-09 14:19:55 +00:00
|
|
|
#I18n.available_locales.each do |locale|
|
|
|
|
# index({ "all_contents_for_feed.#{locale}.is_hidden"=> -1,
|
|
|
|
# "all_contents_for_feed.#{locale}.is_top"=> -1,
|
2022-05-22 10:36:26 +00:00
|
|
|
# "all_contents_for_feed.#{locale}.#{self.feeds_time_field}"=> -1}, { unique: false, background: true, name: "cache_#{locale}" })
|
2021-11-09 14:19:55 +00:00
|
|
|
#end
|
2020-04-05 14:36:09 +00:00
|
|
|
def get_annc(annc_uid)
|
2022-01-06 04:07:18 +00:00
|
|
|
Array(self[:all_contents_for_feed][I18n.locale.to_s]).select{|v| v['id']==annc_uid}[0] rescue {}
|
2020-04-05 14:36:09 +00:00
|
|
|
end
|
2021-11-09 10:11:11 +00:00
|
|
|
before_save do
|
2022-05-09 12:10:29 +00:00
|
|
|
unless @skip_callback
|
|
|
|
if self.top_list_changed? || self.hot_list_changed? || self.hidden_annc_changed? || self.category_title_changed?
|
|
|
|
self[:all_contents_for_feed] = self.cache_annc
|
|
|
|
end
|
2021-11-09 10:11:11 +00:00
|
|
|
end
|
|
|
|
end
|
2022-06-21 10:10:50 +00:00
|
|
|
def update_remote_site_url
|
|
|
|
update_fields = ['source_url','source-site']
|
|
|
|
tmp_url = self.remote_site_url
|
|
|
|
self.all_contents_for_feed_will_change!
|
|
|
|
locales = Site.first.in_use_locales rescue I18n.available_locales
|
|
|
|
locales.each do |l|
|
|
|
|
anns = self[:all_contents_for_feed][l.to_s]
|
|
|
|
if anns
|
|
|
|
(0...anns.count).each do |i|
|
|
|
|
a = anns[i]
|
|
|
|
update_fields.each do |f|
|
|
|
|
a[f] = tmp_url
|
|
|
|
end
|
|
|
|
a['statuses'] = []
|
|
|
|
if a[:is_top]
|
|
|
|
a['statuses'] << {
|
|
|
|
"status" => trans[locale]['top'],
|
|
|
|
"status-class" => "status-top"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if a[:is_hot]
|
|
|
|
a['statuses'] << {
|
|
|
|
"status" => trans[locale]['hot'],
|
|
|
|
"status-class" => "status-hot"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if !a["source-site-title"].blank?
|
|
|
|
a['statuses'] << {
|
|
|
|
"status" => "<a href=\"#{a["source_url"]}\" target=\"_blank\" class=\"feed-source\">#{a["source-site-title"]}</a>",
|
|
|
|
"status-class" => "status-source"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
self.save
|
|
|
|
end
|
|
|
|
def update_channel_title(update_url=false) #update_url=true will also fix remote_site_url in data
|
|
|
|
update_fields = []
|
|
|
|
if update_url
|
|
|
|
update_fields = ['source_url','source-site']
|
|
|
|
end
|
|
|
|
tmp_url = self.remote_site_url
|
|
|
|
self.all_contents_for_feed_will_change!
|
|
|
|
locales = Site.first.in_use_locales rescue I18n.available_locales
|
|
|
|
trans = {}
|
|
|
|
locales.each do |locale|
|
|
|
|
locale = locale.to_s
|
|
|
|
trans[locale] = {}
|
|
|
|
I18n.with_locale(locale) do
|
|
|
|
trans[locale]['top'] = I18n.t(:top)
|
|
|
|
trans[locale]['hot'] = I18n.t(:hot)
|
|
|
|
trans[locale]['more_plus'] = I18n.t("feed.more")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
locales.each do |locale|
|
|
|
|
source_site_title = (self[:channel_title][locale] rescue "")
|
|
|
|
anns = self[:all_contents_for_feed][locale.to_s]
|
|
|
|
if anns
|
|
|
|
(0...anns.count).each do |i|
|
|
|
|
a = anns[i]
|
|
|
|
a["source-site-title"] = source_site_title
|
|
|
|
update_fields.each do |f|
|
|
|
|
a[f] = tmp_url
|
|
|
|
end
|
|
|
|
a['statuses'] = []
|
|
|
|
if a[:is_top]
|
|
|
|
a['statuses'] << {
|
|
|
|
"status" => trans[locale]['top'],
|
|
|
|
"status-class" => "status-top"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if a[:is_hot]
|
|
|
|
a['statuses'] << {
|
|
|
|
"status" => trans[locale]['hot'],
|
|
|
|
"status-class" => "status-hot"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if !a["source-site-title"].blank?
|
|
|
|
a['statuses'] << {
|
|
|
|
"status" => "<a href=\"#{a["source_url"]}\" target=\"_blank\" class=\"feed-source\">#{a["source-site-title"]}</a>",
|
|
|
|
"status-class" => "status-source"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
self.save
|
|
|
|
end
|
2022-05-09 12:10:29 +00:00
|
|
|
def process_tmp(a, locale=nil, trans=nil, site_root_url=nil)
|
|
|
|
cat = self[:category_title]
|
|
|
|
locale = I18n.locale.to_s if locale.nil?
|
|
|
|
if trans.nil?
|
|
|
|
trans = {}
|
|
|
|
locales.each do |locale|
|
|
|
|
locale = locale.to_s
|
|
|
|
trans[locale] = {}
|
|
|
|
I18n.with_locale(locale) do
|
|
|
|
trans[locale]['top'] = I18n.t(:top)
|
|
|
|
trans[locale]['hot'] = I18n.t(:hot)
|
|
|
|
trans[locale]['more_plus'] = I18n.t("feed.more")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if site_root_url.nil?
|
|
|
|
site_root_url = Site.first.root_url rescue ""
|
|
|
|
end
|
|
|
|
tmp = a.deep_dup
|
|
|
|
tmp[:is_hidden] = self.hidden_annc.include?(tmp['id'])
|
|
|
|
if self.channel_key == "announcement"
|
|
|
|
tmp['statuses'] = []
|
|
|
|
if self[:top_list].count == 0 || self[:top_list].exclude?(tmp['id'])
|
|
|
|
tmp[:is_top] = false
|
|
|
|
else
|
|
|
|
tmp[:is_top] = true
|
|
|
|
tmp['statuses'] << {
|
|
|
|
"status" => trans[locale]['top'],
|
|
|
|
"status-class" => "status-top"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if self[:hot_list].count == 0 || self[:top_list].exclude?(tmp['id'])
|
|
|
|
tmp[:is_hot] = false
|
|
|
|
else
|
|
|
|
tmp[:is_hot] = true
|
|
|
|
tmp['statuses'] << {
|
|
|
|
"status" => trans[locale]['hot'],
|
|
|
|
"status-class" => "status-hot"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
tmp["category"] = cat
|
|
|
|
tmp["source_url"] = self.remote_site_url
|
|
|
|
tmp["source-site"] = self.remote_site_url
|
|
|
|
tmp["source-site-title"] = (self[:channel_title][locale] rescue "")
|
|
|
|
tmp["params"] = tmp["params"].to_s + "_" + self.feed_id.to_s + "h"
|
|
|
|
if !tmp["source-site-title"].blank?
|
|
|
|
tmp['statuses'] << {
|
2022-06-21 10:10:50 +00:00
|
|
|
"status" => "<a href=\"#{tmp["source-site"]}\" target=\"_blank\" class=\"feed-source\">#{tmp["source-site-title"]}</a>",
|
2022-05-09 12:10:29 +00:00
|
|
|
"status-class" => "status-source"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
files = tmp["bulletin_files"].collect{|bf| { "file_url" => bf["url"], "file_title" => (bf["title_translations"][locale].blank? ? File.basename(bf["url"]) : bf["title_translations"][locale] rescue '') }} rescue []
|
|
|
|
links = tmp["bulletin_links"].map{|link| { "link_url" => link["url"], "link_title" => (link["title_translations"][locale].blank? ? link["url"] : link["title_translations"][locale]) } } rescue []
|
|
|
|
tmp["bulletin_links"] = links
|
|
|
|
tmp["bulletin_files"] = files
|
|
|
|
tmp["title"] = tmp["title_translations"][locale]
|
|
|
|
tmp["subtitle"] = tmp["subtitle_translations"][locale]
|
2023-12-30 03:15:42 +00:00
|
|
|
if tmp["text_translations"].present?
|
|
|
|
tmp["text_translations"].each do |l, text|
|
|
|
|
doc = Nokogiri::HTML.fragment(text)
|
|
|
|
doc.css('[src]').each do |src_el|
|
|
|
|
src = (src_el.attributes["src"].value rescue "")
|
|
|
|
if src.present? && src.match(/^\/[^\/]+/)
|
|
|
|
src_el.attributes["src"].value = self.remote_site_url + src
|
|
|
|
end
|
|
|
|
end
|
|
|
|
doc.css('[href]').each do |href_el|
|
|
|
|
href = href_el.attribute('href').value rescue ""
|
|
|
|
if href.present? && href.match(/^\/[^\/]+/)
|
|
|
|
href.attributes["href"].value = self.remote_site_url + href
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tmp["text_translations"][l] = doc.to_html
|
|
|
|
end
|
|
|
|
end
|
2022-05-09 12:10:29 +00:00
|
|
|
tmp["source-site-link"] = tmp["source-site"]
|
2022-06-21 10:10:50 +00:00
|
|
|
tmp["source-site"] = "<a href=\"#{tmp["source-site"]}\" target=\"_blank\" class=\"feed-source\">#{tmp["source-site-title"]}</a>"
|
2022-05-09 12:10:29 +00:00
|
|
|
tmp["link_to_show"] = !tmp["external_link"].blank? ? tmp["external_link"] : nil
|
|
|
|
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_src"] = "/assets/announcement-default.jpg" if tmp["img_src"] == ""
|
|
|
|
tmp["img_description"] = tmp["image_description_translations"][locale]
|
|
|
|
tmp["more"] = trans[locale]['more_plus']
|
|
|
|
tmp["view_count"] = ""
|
|
|
|
else
|
2022-05-22 10:36:26 +00:00
|
|
|
new_tmp = {}
|
|
|
|
tmp.each do |key,value|
|
|
|
|
key = key.to_s
|
|
|
|
if key.include? "_translations"
|
|
|
|
new_tmp[key] = value
|
|
|
|
new_tmp[key.sub("_translations","")] = value[locale].to_s rescue ""
|
|
|
|
elsif key.include?("date") || key.include?("Date")
|
|
|
|
new_tmp[key] = DateTime.parse(value) rescue nil
|
|
|
|
else
|
|
|
|
if value.class == Hash
|
|
|
|
new_tmp[key] = {}
|
|
|
|
value.each do |sub_k,sub_v|
|
|
|
|
if sub_k.include? "_translations"
|
|
|
|
new_tmp[key][sub_k] = sub_v
|
|
|
|
new_tmp[key][sub_k.sub("_translations","")] = sub_v[locale].to_s rescue ""
|
|
|
|
else
|
|
|
|
new_tmp[key][sub_k] = sub_v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
new_tmp[key] = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tmp = BSON::Document.new(new_tmp)
|
2022-05-09 12:10:29 +00:00
|
|
|
tmp['statuses'] = []
|
|
|
|
if self[:top_list].count == 0 || self[:top_list].exclude?(tmp['id'])
|
|
|
|
tmp[:is_top] = false
|
|
|
|
else
|
|
|
|
tmp[:is_top] = true
|
|
|
|
tmp['statuses'] << {
|
|
|
|
"status" => trans[locale]['top'],
|
|
|
|
"status-class" => "status-top"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if self[:hot_list].count == 0 || self[:top_list].exclude?(tmp['id'])
|
|
|
|
tmp[:is_hot] = false
|
|
|
|
else
|
|
|
|
tmp[:is_hot] = true
|
|
|
|
tmp['statuses'] << {
|
|
|
|
"status" => trans[locale]['hot'],
|
|
|
|
"status-class" => "status-hot"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
tmp["category"] = cat
|
2022-06-21 10:10:50 +00:00
|
|
|
tmp["source_url"] = self.remote_site_url
|
2022-05-09 12:10:29 +00:00
|
|
|
tmp["source-site"] = self.remote_site_url
|
|
|
|
tmp["source-site-title"] = (self[:channel_title][locale] rescue "")
|
|
|
|
tmp["params"] = tmp["params"].to_s + "_" + self.feed_id.to_s + "h"
|
|
|
|
tmp['statuses'] << {
|
2022-06-21 10:10:50 +00:00
|
|
|
"status" => "<a href=\"#{tmp["source-site"]}\" target=\"_blank\" class=\"feed-source\">#{tmp["source-site-title"]}</a>",
|
2022-05-09 12:10:29 +00:00
|
|
|
"status-class" => "status-source"
|
|
|
|
}
|
|
|
|
tmp["source-site-link"] = tmp["source-site"]
|
2022-06-21 10:10:50 +00:00
|
|
|
tmp["source-site"] = "<a href=\"#{tmp["source-site"]}\" target=\"_blank\" class=\"feed-source\">#{tmp["source-site-title"]}</a>"
|
2022-05-09 12:10:29 +00:00
|
|
|
tmp["target"] = "_self"
|
|
|
|
tmp["more"] = trans[locale]['more_plus']
|
|
|
|
tmp["view_count"] = ""
|
2022-05-22 10:36:26 +00:00
|
|
|
end
|
|
|
|
feeds_time_field = self.feeds_time_field
|
2022-05-24 09:57:55 +00:00
|
|
|
feeds_time_field = 'postdate' if feeds_time_field.nil?
|
|
|
|
time_field_value = tmp[feeds_time_field]
|
|
|
|
tmp[feeds_time_field] = (time_field_value.blank? ? nil : time_field_value.to_time rescue time_field_value)
|
|
|
|
tmp[feeds_time_field] = time_field_value if tmp[feeds_time_field].nil?
|
2022-05-09 12:10:29 +00:00
|
|
|
return tmp
|
|
|
|
end
|
2021-11-09 10:34:07 +00:00
|
|
|
def cache_annc(force_refresh=false,locales=nil,trans=nil)
|
2021-11-09 10:11:11 +00:00
|
|
|
feed = SiteFeed.find(self.feed_id)
|
|
|
|
anns = feed.get_annc(force_refresh)
|
2021-12-30 10:24:21 +00:00
|
|
|
cat = self[:category_title]
|
2022-05-22 10:36:26 +00:00
|
|
|
feeds_time_field = self.feeds_time_field
|
2021-11-09 10:34:07 +00:00
|
|
|
if locales.nil?
|
|
|
|
locales = Site.first.in_use_locales rescue I18n.available_locales
|
|
|
|
end
|
|
|
|
if trans.nil?
|
|
|
|
trans = {}
|
|
|
|
locales.each do |locale|
|
2021-11-10 01:51:22 +00:00
|
|
|
locale = locale.to_s
|
2021-11-09 10:34:07 +00:00
|
|
|
trans[locale] = {}
|
|
|
|
I18n.with_locale(locale) do
|
|
|
|
trans[locale]['top'] = I18n.t(:top)
|
|
|
|
trans[locale]['hot'] = I18n.t(:hot)
|
2022-01-21 02:15:28 +00:00
|
|
|
trans[locale]['more_plus'] = I18n.t("feed.more")
|
2021-11-09 10:34:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-11-09 10:11:11 +00:00
|
|
|
cache_data = {}
|
2022-01-03 14:09:11 +00:00
|
|
|
site_root_url = Site.first.root_url rescue ""
|
2021-11-09 10:11:11 +00:00
|
|
|
locales.each do |locale|
|
|
|
|
locale = locale.to_s
|
2021-11-09 10:34:07 +00:00
|
|
|
data_for_locale = anns.collect do |a|
|
2022-05-09 12:10:29 +00:00
|
|
|
tmp = process_tmp(a, locale, trans, site_root_url)
|
2021-11-09 10:11:11 +00:00
|
|
|
end
|
|
|
|
cache_data[locale.to_s] = data_for_locale
|
|
|
|
end
|
|
|
|
cache_data
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.get_feed_cache(channel_key,merge_with_category=nil,site_source=nil,locale=I18n.locale.to_s,is_widget=false,max_len=nil)
|
2021-12-30 10:24:21 +00:00
|
|
|
locale = I18n.locale.to_s
|
2021-11-10 07:27:06 +00:00
|
|
|
max_len = ((max_len.to_i < 0 rescue true) ? 0 : max_len.to_i)
|
|
|
|
if max_len > 0
|
2022-05-22 10:36:26 +00:00
|
|
|
module_app = ModuleApp.where(:key=>channel_key).first
|
|
|
|
feeds_time_field = module_app.feeds_time_field rescue nil
|
|
|
|
if feeds_time_field.nil?
|
|
|
|
feeds_time_field = 'postdate'
|
|
|
|
end
|
2021-11-10 07:27:06 +00:00
|
|
|
match_cond = {"channel_key"=>channel_key}
|
|
|
|
if !merge_with_category.blank? && merge_with_category.exclude?('all')
|
|
|
|
match_cond["merge_with_category"] = {"$in"=>merge_with_category}
|
|
|
|
end
|
|
|
|
if site_source
|
|
|
|
match_cond["channel_title.#{locale}"] = site_source
|
|
|
|
end
|
|
|
|
pipeline = [
|
|
|
|
{"$match"=>match_cond},
|
|
|
|
{"$project"=>{"data"=>"$all_contents_for_feed.#{locale}"}},
|
|
|
|
{"$unwind"=>"$data"},
|
2022-05-22 10:36:26 +00:00
|
|
|
{"$sort"=>{"data.is_hidden"=>-1,"data.is_top"=>-1,"data.#{feeds_time_field}"=>-1}},
|
2021-11-10 07:27:06 +00:00
|
|
|
{"$match"=>{"data.is_hidden"=>{"$ne"=>true},
|
|
|
|
"data.postdate"=>{"$lte"=>Time.now},
|
|
|
|
"data.title" => {"$gt"=>""}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
if max_len
|
|
|
|
pipeline << {"$limit"=> max_len}
|
|
|
|
end
|
|
|
|
self.collection.aggregate(pipeline).collect do |data|
|
|
|
|
tmp = data['data']
|
2023-09-13 04:16:38 +00:00
|
|
|
if !(tmp['category'].is_a? String)
|
|
|
|
tmp['category'] = tmp['category'][locale]
|
|
|
|
end
|
2022-02-27 04:20:59 +00:00
|
|
|
if @image_version != 'thumb' && !@image_version.nil?
|
|
|
|
if @image_version == 'mobile'
|
|
|
|
tmp["img_src"] = tmp["image"]["mobile"]
|
|
|
|
else
|
|
|
|
tmp["img_src"] = tmp["image"]["original"]
|
|
|
|
end
|
|
|
|
tmp["img_src"] = tmp["img_src"] || "/assets/announcement-default.jpg"
|
|
|
|
end
|
2021-11-10 07:27:06 +00:00
|
|
|
if tmp["link_to_show"].nil?
|
|
|
|
if !is_widget
|
2022-09-28 00:27:07 +00:00
|
|
|
tmp["link_to_show"] = UseSourceUrl && tmp["show_url"] ? URI.join("#{tmp["source_url"]}/#{locale}",URI.encode("#{tmp["show_url"]}")).to_s : OrbitHelper.url_to_show(tmp["params"]) rescue ''
|
2021-11-10 07:27:06 +00:00
|
|
|
else
|
2022-09-28 00:27:07 +00:00
|
|
|
tmp["link_to_show"] = UseSourceUrl && tmp["show_url"] ? URI.join("#{tmp["source_url"]}/#{locale}",URI.encode("#{tmp["show_url"]}")).to_s : OrbitHelper.widget_item_url(tmp["params"]) rescue ''
|
2021-11-10 07:27:06 +00:00
|
|
|
end
|
2021-11-09 10:11:11 +00:00
|
|
|
end
|
2021-11-10 07:27:06 +00:00
|
|
|
tmp
|
2021-11-09 10:11:11 +00:00
|
|
|
end
|
2021-11-10 07:27:06 +00:00
|
|
|
else
|
|
|
|
[]
|
2021-11-09 10:11:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def all_contents_for_feed(site_source=nil,locale=I18n.locale.to_s,is_widget=false)
|
|
|
|
if !site_source.nil? && site_source != self[:channel_title][locale]
|
|
|
|
return []
|
|
|
|
end
|
|
|
|
time_now = Time.now
|
|
|
|
Array(self[:all_contents_for_feed][locale.to_s]).collect do |v|
|
|
|
|
tmp = v
|
|
|
|
next if tmp["is_hidden"] || (!tmp["postdate"].nil? && tmp["postdate"]<Time.now) || tmp['title'].blank?
|
2021-12-30 10:24:21 +00:00
|
|
|
tmp['category'] = tmp['category'][locale]
|
2022-02-27 04:20:59 +00:00
|
|
|
if @image_version != 'thumb' && !@image_version.nil?
|
|
|
|
if @image_version == 'mobile'
|
|
|
|
tmp["img_src"] = tmp["image"]["mobile"]
|
|
|
|
else
|
|
|
|
tmp["img_src"] = tmp["image"]["original"]
|
|
|
|
end
|
|
|
|
tmp["img_src"] = tmp["img_src"] || "/assets/announcement-default.jpg"
|
|
|
|
end
|
2021-11-09 10:11:11 +00:00
|
|
|
if tmp["link_to_show"].nil?
|
|
|
|
if !is_widget
|
2022-02-23 08:07:23 +00:00
|
|
|
tmp["link_to_show"] = UseSourceUrl && tmp["show_url"] ? "#{tmp["source_url"]}/#{locale}#{tmp["show_url"]}" : OrbitHelper.url_to_show(tmp["params"]) rescue ''
|
2021-11-09 10:11:11 +00:00
|
|
|
else
|
2022-02-23 08:07:23 +00:00
|
|
|
tmp["link_to_show"] = UseSourceUrl && tmp["show_url"] ? "#{tmp["source_url"]}/#{locale}#{tmp["show_url"]}" : OrbitHelper.widget_item_url(tmp["params"]) rescue ''
|
2020-04-05 14:36:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
tmp
|
|
|
|
end.compact
|
|
|
|
end
|
|
|
|
def channel_title(locale=I18n.locale)
|
2020-06-03 12:05:07 +00:00
|
|
|
self[:channel_title][locale] rescue self[:channel_title]
|
2020-04-05 14:36:09 +00:00
|
|
|
end
|
|
|
|
def category
|
|
|
|
Category.find(self.merge_with_category) rescue nil
|
|
|
|
end
|
|
|
|
def category_title
|
2021-12-30 10:24:21 +00:00
|
|
|
self[:category_title][I18n.locale.to_s]
|
2020-04-05 14:36:09 +00:00
|
|
|
end
|
2022-09-28 00:27:07 +00:00
|
|
|
end
|