return subtitle_ann / img_src when they are displayable

This commit is contained in:
EricTYL 2020-01-13 15:16:46 +08:00
parent 2501d578bd
commit 0cba386e89
1 changed files with 7 additions and 2 deletions

View File

@ -336,18 +336,23 @@ class AnnouncementsController < ApplicationController
meta_desc = announcement.subtitle.nil? || announcement.subtitle == "" ? announcement.text[0..200] : announcement.subtitle
OrbitHelper.render_meta_tags([{"property" => "og:title", "content" => announcement.title},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url.split("?").first},{"property" => "og:description", "content" => meta_desc},{"property" => "og:image", "content" => "#{request.base_url}#{announcement.image.url}"},{"property" => "og:type", "content" => "Article"}])
subtitle_ann = nil
img_src = nil
subtitle_ann = announcement.subtitle if announcement.display_subtitle?
img_src = (announcement.image.thumb.url || "/assets/announcement-default.jpg") if announcement.display_img?
{
"tags" => tags,
"bulletin_files" => files,
"bulletin_links" => links,
"data" => {
"title" => announcement.title,
"subtitle_ann" => announcement.subtitle,
"subtitle_ann" => subtitle_ann,
"update_user" => update_user,
"updated_at" => announcement.postdate.strftime('%Y-%m-%d %H:%M'),
"body" =>announcement.text,
"image" => announcement.image.url,
"img_src" => announcement.image.thumb.url || "/assets/announcement-default.jpg",
"img_src" => img_src,
"alt_title" => desc
},
"impressionist" => (announcement.is_preview ? nil : announcement),