added subtitle to toics

This commit is contained in:
Harry Bomrah 2017-08-07 17:53:17 +08:00
parent 81870c9412
commit 02bd07d62b
4 changed files with 16 additions and 4 deletions

View File

@ -52,7 +52,7 @@ class Admin::EPapersController < OrbitAdminController
def show def show
@paper = Paper.find(params[:id]) @paper = Paper.find(params[:id])
@table_fields = [t('e_paper.title'),t('e_paper.topic_name'),t('e_paper.publish_date')] @table_fields = [t('e_paper.title'),t('e_paper.topic_name'),t('e_paper.publish_date')]
@topics = @paper.topics.all @topics = @paper.topics.asc(:created_at)
end end
def send_email_to_subscribers def send_email_to_subscribers

View File

@ -52,14 +52,13 @@ class EPapersController < ApplicationController
paper_thumb = !paper.image.nil? && !paper.image.url.nil? ? paper.image.thumb.url : "http://www.placehold.it/400x400/EFEFEF/AAAAAA" paper_thumb = !paper.image.nil? && !paper.image.url.nil? ? paper.image.thumb.url : "http://www.placehold.it/400x400/EFEFEF/AAAAAA"
paper_full = !paper.image.nil? && !paper.image.url.nil? ? paper.image.url : "http://www.placehold.it/1000x1000/EFEFEF/AAAAAA" paper_full = !paper.image.nil? && !paper.image.url.nil? ? paper.image.url : "http://www.placehold.it/1000x1000/EFEFEF/AAAAAA"
topics = paper.topics.asc(:created_at).collect do |topic| topics = paper.topics.asc(:created_at).collect do |topic|
desc = ActionView::Base.full_sanitizer.sanitize(topic.content)
timg = !topic.image.nil? && !topic.image.url.nil? ? topic.image.thumb.url : "http://www.placehold.it/400x400/EFEFEF/AAAAAA" timg = !topic.image.nil? && !topic.image.url.nil? ? topic.image.thumb.url : "http://www.placehold.it/400x400/EFEFEF/AAAAAA"
fimg = !topic.image.nil? && !topic.image.url.nil? ? topic.image.url : "http://www.placehold.it/1000x1000/EFEFEF/AAAAAA" fimg = !topic.image.nil? && !topic.image.url.nil? ? topic.image.url : "http://www.placehold.it/1000x1000/EFEFEF/AAAAAA"
{ {
"link_to_show" => OrbitHelper.url_to_show(topic.to_param) + "?method=showtopic", "link_to_show" => OrbitHelper.url_to_show(topic.to_param) + "?method=showtopic",
"episode" => topic.episode, "episode" => topic.episode,
"content" => topic.content, "content" => topic.content,
"description" => desc[0..100], "description" => topic.description,
"publish_date" => topic.created_at, "publish_date" => topic.created_at,
"image_thumb" => timg, "image_thumb" => timg,
"image_full" => fimg "image_full" => fimg

View File

@ -7,6 +7,7 @@ class Topic
field :episode,as: :slug_title, localize: true field :episode,as: :slug_title, localize: true
field :content, localize: true field :content, localize: true
field :description, localize: true
belongs_to :paper belongs_to :paper

View File

@ -76,7 +76,19 @@
<%= f.text_field locale, :class=>'input-block-level', :value => (@topic.episode_translations[locale.to_s] rescue nil) %> <%= f.text_field locale, :class=>'input-block-level', :value => (@topic.episode_translations[locale.to_s] rescue nil) %>
<% end %> <% end %>
</div> </div>
</div> </div>
<!-- Sub Title -->
<div class="control-group input-subtitle">
<label class="control-label muted"><%= t(:subtitle) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :subtitle_translations do |f| %>
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@topic.subtitle_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<!-- Content --> <!-- Content -->
<div class="control-group input-content"> <div class="control-group input-content">