fix subtitle and image feature

This commit is contained in:
chiu 2020-07-23 21:01:31 +08:00
parent 09ee21921a
commit c3ed827184
3 changed files with 12 additions and 2 deletions

View File

@ -112,12 +112,14 @@ class AnnouncementFeedsController < ApplicationController
a["postdate"] = anns.postdate a["postdate"] = anns.postdate
a["image_description_translations"] = anns.image_description_translations a["image_description_translations"] = anns.image_description_translations
a["image"] = {} a["image"] = {}
a["display_img"] = anns.display_img
a["image"]["original"] = ("#{request.base_url}" + anns.image.url rescue "") a["image"]["original"] = ("#{request.base_url}" + anns.image.url rescue "")
a["image"]["thumb"] = ("#{request.base_url}" + anns.image.thumb.url rescue "") a["image"]["thumb"] = ("#{request.base_url}" + anns.image.thumb.url rescue "")
a["image"]["mobile"] = ("#{request.base_url}" + anns.image.mobile.url rescue "") a["image"]["mobile"] = ("#{request.base_url}" + anns.image.mobile.url rescue "")
a["tags"] = [] a["tags"] = []
a["author"] = author a["author"] = author
a["params"] = anns.to_param a["params"] = anns.to_param
a["subtitle_ann"] = anns.subtitle if anns.display_subtitle?
a["bulletin_links"] = [] a["bulletin_links"] = []
a["bulletin_files"] = [] a["bulletin_files"] = []
anns.tags.each do |tag| anns.tags.each do |tag|

View File

@ -255,6 +255,7 @@ class AnnouncementsController < ApplicationController
"image" => announcement.image.url, "image" => announcement.image.url,
"img_src" => img_src, "img_src" => img_src,
"img_description" => img_description, "img_description" => img_description,
"hide_class" => announcement.display_img? ? '' : ' hide',
"alt_title" => desc "alt_title" => desc
}, },
"impressionist" => (announcement.is_preview ? nil : announcement), "impressionist" => (announcement.is_preview ? nil : announcement),
@ -294,7 +295,11 @@ class AnnouncementsController < ApplicationController
update_user = announcement["author"] update_user = announcement["author"]
desc = announcement["image_description_translations"][locale] rescue "" desc = announcement["image_description_translations"][locale] rescue ""
desc = (desc.nil? || desc == "" ? "announcement image" : desc) desc = (desc.nil? || desc == "" ? "announcement image" : desc)
img_description = nil
img_description = announcement["image_description_translations"][I18n.locale] if announcement['display_img']
img_src = nil
img_src = (announcement['image']['thumb'] || "/assets/announcement-default.jpg") if announcement['display_img']
subtitle_ann = announcement['subtitle_ann']
request = OrbitHelper.request request = OrbitHelper.request
if announcement["subtitle_translations"].present? if announcement["subtitle_translations"].present?
meta_desc = announcement["subtitle_translations"][locale] != "" ? announcement["subtitle_translations"][locale] : announcement["text_translations"][locale][0..200] rescue "" meta_desc = announcement["subtitle_translations"][locale] != "" ? announcement["subtitle_translations"][locale] : announcement["text_translations"][locale][0..200] rescue ""
@ -312,10 +317,14 @@ class AnnouncementsController < ApplicationController
"bulletin_links" => links, "bulletin_links" => links,
"data" => { "data" => {
"title" => announcement["title_translations"][locale], "title" => announcement["title_translations"][locale],
"subtitle_ann" => subtitle_ann,
"update_user" => update_user, "update_user" => update_user,
"updated_at" => datetime.strftime('%Y-%m-%d %H:%M'), "updated_at" => datetime.strftime('%Y-%m-%d %H:%M'),
"body" => announcement["text_translations"][locale], "body" => announcement["text_translations"][locale],
"image" => announcement["image"]["original"], "image" => announcement["image"]["original"],
"img_src" => img_src,
"img_description" => img_description,
"hide_class" => announcement["display_img"] ? '' : ' hide',
"alt_title" => desc "alt_title" => desc
}, },
"impressionist" => nil, "impressionist" => nil,

View File

@ -31,7 +31,6 @@ module OrbitBackendHelper
end[0]['count'] rescue 0 end[0]['count'] rescue 0
{'_id'=>{'year'=>d_year,'month'=>d_month,'day'=>d_day},'count'=>count} {'_id'=>{'year'=>d_year,'month'=>d_month,'day'=>d_day},'count'=>count}
end end
puts ['tmp',tmp]
end end
tmp tmp
end end