fix news image description

This commit is contained in:
nccu 2015-01-12 14:40:36 +08:00
parent 3c435f0f91
commit b303e8256a
4 changed files with 26 additions and 2 deletions

View File

@ -61,6 +61,12 @@ class NewsController < ApplicationController
} }
end end
anns = news.collect do |a| anns = news.collect do |a|
if a.image_description.nil?
image_description = "裝飾性圖片"
else
image_description = a.image_description
end
statuses = a.statuses_with_classname.collect do |status| statuses = a.statuses_with_classname.collect do |status|
{ {
"status" => status["name"], "status" => status["name"],
@ -75,6 +81,7 @@ class NewsController < ApplicationController
"postdate" => a.postdate.strftime('%Y-%m-%d'), "postdate" => a.postdate.strftime('%Y-%m-%d'),
"link_to_show" => OrbitHelper.url_to_show(a.to_param), "link_to_show" => OrbitHelper.url_to_show(a.to_param),
"img_src" => a.image.thumb.url || "/assets/news_default_image.jpg", "img_src" => a.image.thumb.url || "/assets/news_default_image.jpg",
"img_description" => image_description,
"more" => t(:more_plus) "more" => t(:more_plus)
} }
end end
@ -114,6 +121,12 @@ class NewsController < ApplicationController
categories.unshift({"name" => t("news.all"), "category-link" => "/#{I18n.locale.to_s + page.url}/"}) categories.unshift({"name" => t("news.all"), "category-link" => "/#{I18n.locale.to_s + page.url}/"})
anns = news.collect do |a| anns = news.collect do |a|
if a.image_description.nil?
image_description = "裝飾性圖片"
else
image_description = a.image_description
end
statuses = a.statuses_with_classname.collect do |status| statuses = a.statuses_with_classname.collect do |status|
{ {
"status" => status["name"], "status" => status["name"],
@ -128,6 +141,7 @@ class NewsController < ApplicationController
"postdate" => a.postdate, "postdate" => a.postdate,
"link_to_show" => OrbitHelper.widget_item_url(a.to_param), "link_to_show" => OrbitHelper.widget_item_url(a.to_param),
"img_src" => a.image.thumb.url || "/assets/news_default_image.jpg", "img_src" => a.image.thumb.url || "/assets/news_default_image.jpg",
"img_description" => image_description
} }
end end
{ {

View File

@ -24,6 +24,7 @@ class NewsBulletin
field :rejected, :type => Boolean, :default => false field :rejected, :type => Boolean, :default => false
field :rejection_reason field :rejection_reason
field :is_preview, :type => Boolean, :default => false field :is_preview, :type => Boolean, :default => false
field :image_description, localize: true
field :email_id field :email_id
field :email_sent, :type => Boolean, :default => false field :email_sent, :type => Boolean, :default => false

View File

@ -165,9 +165,17 @@
<label class="checkbox inline muted"> <%= t('news_bulletin.user_default_image')%></label> <label class="checkbox inline muted"> <%= t('news_bulletin.user_default_image')%></label>
</div> </div>
</div> </div>
<% @site_in_use_locales.each do |locale| %>
<%= f.fields_for :image_description_translations do |f| %>
<div class="control-group">
<label class="control-label muted" for="image_description_<%= locale.to_s %>"><%= t(:description) + " (#{t(locale.to_s)})" %></label>
<div class="controls">
<%= f.text_field locale, value: (@news_bulletin.image_description_translations[locale.to_s] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div> </div>
</div> </div>
<!-- Language Tabs --> <!-- Language Tabs -->

View File

@ -89,3 +89,4 @@ zh_tw:
mail_source: 來源 mail_source: 來源
mail_time: 時間 mail_time: 時間
image_upload_size_note: 建議檔案小於%{image_upload_size} image_upload_size_note: 建議檔案小於%{image_upload_size}
image_description: 圖片描述