Merge branch 'master' into 'master'

add checkbox for displaying img / subtitle

add checkbox for displaying img / subtitle

See merge request !6
This commit is contained in:
EricTYL 2020-01-13 15:39:23 +08:00
commit 285eef9f8e
3 changed files with 32 additions and 3 deletions

View File

@ -336,18 +336,23 @@ class AnnouncementsController < ApplicationController
meta_desc = announcement.subtitle.nil? || announcement.subtitle == "" ? announcement.text[0..200] : announcement.subtitle 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"}]) 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, "tags" => tags,
"bulletin_files" => files, "bulletin_files" => files,
"bulletin_links" => links, "bulletin_links" => links,
"data" => { "data" => {
"title" => announcement.title, "title" => announcement.title,
"subtitle_ann" => announcement.subtitle, "subtitle_ann" => subtitle_ann,
"update_user" => update_user, "update_user" => update_user,
"updated_at" => announcement.postdate.strftime('%Y-%m-%d %H:%M'), "updated_at" => announcement.postdate.strftime('%Y-%m-%d %H:%M'),
"body" =>announcement.text, "body" =>announcement.text,
"image" => announcement.image.url, "image" => announcement.image.url,
"img_src" => announcement.image.thumb.url || "/assets/announcement-default.jpg", "img_src" => img_src,
"alt_title" => desc "alt_title" => desc
}, },
"impressionist" => (announcement.is_preview ? nil : announcement), "impressionist" => (announcement.is_preview ? nil : announcement),

View File

@ -26,6 +26,8 @@ class Bulletin
field :rejection_reason field :rejection_reason
field :is_external_link, :type => Boolean, :default => false field :is_external_link, :type => Boolean, :default => false
field :external_link field :external_link
field :display_subtitle, :type => Boolean, :default => false
field :display_img, :type => Boolean, :default => false
field :email_id field :email_id
field :email_sent, :type => Boolean, :default => false field :email_sent, :type => Boolean, :default => false
@ -94,4 +96,11 @@ class Bulletin
end end
end end
def display_subtitle?
self.display_subtitle rescue false
end
def display_img?
self.display_img rescue false
end
end end

View File

@ -67,6 +67,21 @@
</div> </div>
</div> </div>
<!-- display subtitle -->
<div class="control-group">
<%= f.label :display_subtitle, 'display subtitle', :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :display_subtitle %>
</div>
</div>
<!-- display img src -->
<div class="control-group">
<%= f.label :display_img, 'display img src', :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :display_img %>
</div>
</div>
</div> </div>
<!-- Status Module --> <!-- Status Module -->
@ -469,4 +484,4 @@
}); });
</script> </script>
<% end %> <% end %>