name updates

This commit is contained in:
rulingcom 2025-05-08 18:53:19 +08:00
parent f8177ac3c2
commit f2c186797a
14 changed files with 178 additions and 178 deletions

View File

@ -281,7 +281,7 @@ class Admin::CurationsController < OrbitAdminController
bulletin.notify_feed("create") bulletin.notify_feed("create")
end end
#BulletinFeed.create_feed_cache(bulletin) #BulletinFeed.create_feed_cache(bulletin)
redirect_to admin_announcements_path redirect_to admin_curations_path
end end
def approve_bulletin def approve_bulletin
@ -493,7 +493,7 @@ class Admin::CurationsController < OrbitAdminController
:mail_lang => locale, :mail_lang => locale,
:mail_to=>bulletin.email_addresses, :mail_to=>bulletin.email_addresses,
:mail_subject=>title, :mail_subject=>title,
:template=>'announcements/email', :template=>'curation/email',
:template_data=>{ :template_data=>{
"host" => request.host_with_port, "host" => request.host_with_port,
"title" => title, "title" => title,

View File

@ -3,20 +3,20 @@ class CurationPostsController < ApplicationController
before_filter :set_I18n before_filter :set_I18n
def annc_depts_translations def annc_depts_translations
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['announcement'][:annc_depts_translations] rescue AnnouncementSetting.first.annc_depts_translations OrbitHelper::SharedHash['curation'][:annc_depts_translations] rescue CurationSetting.first.annc_depts_translations
else else
AnnouncementSetting.first.annc_depts_translations rescue {} CurationSetting.first.annc_depts_translations rescue {}
end end
end end
def enable_annc_dept def enable_annc_dept
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['announcement'][:enable_annc_dept] rescue AnnouncementSetting.first.enable_annc_dept OrbitHelper::SharedHash['curation'][:enable_annc_dept] rescue CurationSetting.first.enable_annc_dept
else else
AnnouncementSetting.first.enable_annc_dept rescue false CurationSetting.first.enable_annc_dept rescue false
end end
end end
def get_bulletins def get_bulletins
page = Page.where(:module => "announcement").first rescue nil page = Page.where(:module => "curation").first rescue nil
# 頁次 # 頁次
page_num = params[:page_num].blank? ? 0 : params[:page_num].to_i page_num = params[:page_num].blank? ? 0 : params[:page_num].to_i
@ -32,13 +32,13 @@ class CurationPostsController < ApplicationController
keyword = params[:keyword].to_s keyword = params[:keyword].to_s
if keyword.present? if keyword.present?
keyword_regex = OrbitHelper.get_keyword_regex(keyword) keyword_regex = OrbitHelper.get_keyword_regex(keyword)
bulletins = Bulletin.any_of({:title=>keyword_regex},{:subtitle=>keyword_regex},{:text=>keyword_regex}) bulletins = CurationPost.any_of({:title=>keyword_regex},{:subtitle=>keyword_regex},{:text=>keyword_regex})
else else
bulletins = Bulletin.all bulletins = CurationPost.all
end end
if !params[:category].blank? if !params[:category].blank?
module_id = ModuleApp.where(:key=>"announcement").first.id module_id = ModuleApp.where(:key=>"curation").first.id
category = Regexp.new(".*"+params[:category]+".*") category = Regexp.new(".*"+params[:category]+".*")
category_id = Category.where(:title => category, :module_app_id => module_id).first.id category_id = Category.where(:title => category, :module_app_id => module_id).first.id
bulletins = bulletins.where(:category_id => category_id) bulletins = bulletins.where(:category_id => category_id)
@ -49,7 +49,7 @@ class CurationPostsController < ApplicationController
bulletins = bulletins.where(:is_preview.in=>[false,nil]) bulletins = bulletins.where(:is_preview.in=>[false,nil])
bulletins = bulletins.where(:approved.ne => false , :rejected.ne => true) bulletins = bulletins.where(:approved.ne => false , :rejected.ne => true)
bulletins = bulletins.where(:postdate.lt=>Time.now) bulletins = bulletins.where(:postdate.lt=>Time.now)
if (AnnouncementsHelper.enable_manually_sort rescue false) if (CurationsHelper.enable_manually_sort rescue false)
bulletins = bulletins.order({:is_top => -1, :sort_number => 1, :postdate => -1}).page(page_num).per(per_page) bulletins = bulletins.order({:is_top => -1, :sort_number => 1, :postdate => -1}).page(page_num).per(per_page)
else else
bulletins = bulletins.desc( :is_top, :postdate).page(page_num).per(per_page) bulletins = bulletins.desc( :is_top, :postdate).page(page_num).per(per_page)
@ -58,14 +58,14 @@ class CurationPostsController < ApplicationController
bulletins = bulletins.collect do |b| bulletins = bulletins.collect do |b|
image = request.protocol + request.host_with_port + b.image.url rescue nil image = request.protocol + request.host_with_port + b.image.url rescue nil
links = b.bulletin_links.collect do |bl| links = b.curation_post_links.collect do |bl|
{ {
"title" => bl.title_translations, "title" => bl.title_translations,
"url" => bl.url "url" => bl.url
} }
end rescue nil end rescue nil
files = b.bulletin_files.collect do |bf| files = b.curation_post_files.collect do |bf|
file = request.protocol + request.host_with_port + bf.file.url rescue nil file = request.protocol + request.host_with_port + bf.file.url rescue nil
{ {
"title" => bf.title_translations, "title" => bf.title_translations,
@ -107,9 +107,9 @@ class CurationPostsController < ApplicationController
# 計算總筆數 Start # 計算總筆數 Start
if keyword.present? if keyword.present?
keyword_regex = OrbitHelper.get_keyword_regex(keyword) keyword_regex = OrbitHelper.get_keyword_regex(keyword)
bulletin_count = Bulletin.any_of({:title=>keyword_regex},{:subtitle=>keyword_regex},{:text=>keyword_regex}) bulletin_count = CurationPost.any_of({:title=>keyword_regex},{:subtitle=>keyword_regex},{:text=>keyword_regex})
else else
bulletin_count = Bulletin.all bulletin_count = CurationPost.all
end end
bulletin_count = bulletin_count.where(:is_preview.in=>[false,nil]) bulletin_count = bulletin_count.where(:is_preview.in=>[false,nil])
bulletin_count = bulletin_count.where(:approved.ne => false , :rejected.ne => true) bulletin_count = bulletin_count.where(:approved.ne => false , :rejected.ne => true)

View File

@ -4,35 +4,35 @@ class CurationsController < ApplicationController
DefaultImgSrc = "/assets/announcement-default.jpg\" onerror=\"this.src=&quot;/assets/announcement-default-2.jpg&quot;;this.onerror='';" DefaultImgSrc = "/assets/announcement-default.jpg\" onerror=\"this.src=&quot;/assets/announcement-default-2.jpg&quot;;this.onerror='';"
def initialize def initialize
super super
@app_title = 'announcement' @app_title = 'curation'
#self.request = OrbitHelper.request #self.request = OrbitHelper.request
end end
def annc_depts_translations def annc_depts_translations
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['announcement'][:annc_depts_translations] rescue AnnouncementSetting.first.annc_depts_translations OrbitHelper::SharedHash['curation'][:annc_depts_translations] rescue CurationSetting.first.annc_depts_translations
else else
AnnouncementSetting.first.annc_depts_translations rescue {} CurationSetting.first.annc_depts_translations rescue {}
end end
end end
def enable_annc_dept def enable_annc_dept
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['announcement'][:enable_annc_dept] rescue AnnouncementSetting.first.enable_annc_dept OrbitHelper::SharedHash['curation'][:enable_annc_dept] rescue CurationSetting.first.enable_annc_dept
else else
AnnouncementSetting.first.enable_annc_dept rescue false CurationSetting.first.enable_annc_dept rescue false
end end
end end
def render_400 def render_400
render(:file => "#{ViewRootDir}/announcements/400.html", :layout => false, :status => 400, :formats => [:html]) render(:file => "#{ViewRootDir}/curations/400.html", :layout => false, :status => 400, :formats => [:html])
end end
def render_404 def render_404
render(:file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => 404, :formats => [:html]) render(:file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => 404, :formats => [:html])
end end
def comment def comment
@bulletin = Bulletin.where(:uid=>params[:uid]).first @bulletin = CurationPost.where(:uid=>params[:uid]).first
comment_val = params['comment'] comment_val = params['comment']
if !@bulletin.nil? && @bulletin.open_comment_for_user(OrbitHelper.current_user) && !comment_val.blank? if !@bulletin.nil? && @bulletin.open_comment_for_user(OrbitHelper.current_user) && !comment_val.blank?
account_id = OrbitHelper.current_user.member_profile.id.to_s rescue 'visitor' account_id = OrbitHelper.current_user.member_profile.id.to_s rescue 'visitor'
b = BulletinComment.new(ip: request.remote_ip,comment: comment_val,account_id: account_id) b = CurationPostComment.new(ip: request.remote_ip,comment: comment_val,account_id: account_id)
b.bulletin_id = @bulletin.id b.bulletin_id = @bulletin.id
b.save b.save
render :json => {} render :json => {}
@ -42,13 +42,13 @@ class CurationsController < ApplicationController
end end
def index def index
@type = 'index' @type = 'index'
Bulletin.remove_expired_status CurationPost.remove_expired_status
params = @params = OrbitHelper.params params = @params = OrbitHelper.params
page = @page || Page.where(url: params['url']).first page = @page || Page.where(url: params['url']).first
@enable_search_flag = false @enable_search_flag = false
@image_version = 'thumb' @image_version = 'thumb'
if page.respond_to?(:select_option_items) if page.respond_to?(:select_option_items)
module_app = ModuleApp.where(key: 'announcement').first module_app = ModuleApp.where(key: 'curation').first
@show_option_items = nil @show_option_items = nil
if module_app && page.respond_to?(:select_option_items) if module_app && page.respond_to?(:select_option_items)
@show_option_items = module_app.show_option_items @show_option_items = module_app.show_option_items
@ -59,17 +59,17 @@ class CurationsController < ApplicationController
case select_option_item.field_name case select_option_item.field_name
when @show_option_items.keys[1].to_s when @show_option_items.keys[1].to_s
value = YAML.load(select_option_item.value) value = YAML.load(select_option_item.value)
if value[:en] == t('announcement.yes') if value[:en] == t('curation.yes')
@enable_search_flag = true @enable_search_flag = true
end end
when @show_option_items.keys[2].to_s when @show_option_items.keys[2].to_s
value = YAML.load(select_option_item.value) value = YAML.load(select_option_item.value)
tmp = value[:en] tmp = value[:en]
if tmp == t('announcement.small_size') if tmp == t('curation.small_size')
@image_version = 'thumb' @image_version = 'thumb'
elsif tmp == t('announcement.medium_size') elsif tmp == t('curation.medium_size')
@image_version = 'mobile' @image_version = 'mobile'
elsif tmp == t('announcement.orignal_size') elsif tmp == t('curation.orignal_size')
@image_version = 'orignal' @image_version = 'orignal'
end end
end end
@ -101,7 +101,7 @@ class CurationsController < ApplicationController
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
author = tmp_enable_annc_dept ? annc_depts[a.annc_dept] : User.find(a.update_user_id).member_name rescue (User.find(a.update_user_id).member_profile.name rescue "") author = tmp_enable_annc_dept ? annc_depts[a.annc_dept] : User.find(a.update_user_id).member_name rescue (User.find(a.update_user_id).member_profile.name rescue "")
desc = a.image_description desc = a.image_description
desc = (desc.blank? ? "announcement image" : desc) desc = (desc.blank? ? "curation image" : desc)
link_to_show = a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param) link_to_show = a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)
target = a.is_external_link ? "_blank" : "_self" target = a.is_external_link ? "_blank" : "_self"
title = a.title_plain_text title = a.title_plain_text
@ -131,7 +131,7 @@ class CurationsController < ApplicationController
"target" => target, "target" => target,
"img_src" => image_url || DefaultImgSrc, "img_src" => image_url || DefaultImgSrc,
"img_description" => desc, "img_description" => desc,
"more" => t("announcement.more"), "more" => t("curation.more"),
"view_count" => a.view_count "view_count" => a.view_count
} }
else else
@ -158,19 +158,19 @@ class CurationsController < ApplicationController
{ {
"announcements" => anns, "announcements" => anns,
"extras" => { "extras" => {
"widget-title" =>t('announcement.announcement'), "widget-title" =>t('curation.curation'),
"title-head" => t('announcement.table.title'), "title-head" => t('curation.table.title'),
"date-head" => t('announcement.table.date'), "date-head" => t('curation.table.date'),
"status-head" => t('announcement.table.status'), "status-head" => t('curation.table.status'),
"author-head" => t('announcement.table.author'), "author-head" => t('curation.table.author'),
"subtitle-head" => t('announcement.table.sub_title'), "subtitle-head" => t('curation.table.sub_title'),
"category-head" => t('announcement.table.category'), "category-head" => t('curation.table.category'),
"link-head" => t('announcement.table.link'), "link-head" => t('curation.table.link'),
"file-head" => t('announcement.table.file'), "file-head" => t('curation.table.file'),
"view-count-head" => t('announcement.table.view_count'), "view-count-head" => t('curation.table.view_count'),
"display" => display, "display" => display,
"department-head" => t('announcement.table.department'), "department-head" => t('curation.table.department'),
"annc-dept-head" => t("announcement.annc_dept"), "annc-dept-head" => t("curation.annc_dept"),
"page-title" => @annc_page_title "page-title" => @annc_page_title
}, },
"total_pages" => total_pages "total_pages" => total_pages
@ -187,7 +187,7 @@ class CurationsController < ApplicationController
end end
def tag_cloud def tag_cloud
ma = ModuleApp.where(:key => "announcement").first ma = ModuleApp.where(:key => "curation").first
temp = [] temp = []
ma.tags.each do |tag| ma.tags.each do |tag|
t1 = tag.taggings.collect{|t| t.taggable_id.to_s} t1 = tag.taggings.collect{|t| t.taggable_id.to_s}
@ -281,10 +281,10 @@ class CurationsController < ApplicationController
page = nil page = nil
if home_page.respond_to?(:find_page) if home_page.respond_to?(:find_page)
page = home_page.find_page(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil page = home_page.find_page(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil
page = home_page.find_page(:module=>"announcement",:enabled_for=>locale).first rescue nil if page.nil? page = home_page.find_page(:module=>"curation",:enabled_for=>locale).first rescue nil if page.nil?
else else
page = Page.where(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil page = Page.where(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil
page = Page.where(:module=>"announcement",:enabled_for=>locale).first rescue nil if page.nil? page = Page.where(:module=>"curation",:enabled_for=>locale).first rescue nil if page.nil?
end end
page_url = "/#{locale}#{(page.get_url rescue page.url)}" page_url = "/#{locale}#{(page.get_url rescue page.url)}"
end end
@ -306,10 +306,10 @@ class CurationsController < ApplicationController
(use_tag ? tags.map.with_index{|tag,i| (use_tag ? tags.map.with_index{|tag,i|
read_more_url = "#{page_url}" rescue "" read_more_url = "#{page_url}" rescue ""
read_more_url = read_more_url + "?" + {"category"=>all_cats,"tags"=>(tag == 'all' ? all_tags : [tag])}.to_param if read_more_url != "" read_more_url = read_more_url + "?" + {"category"=>all_cats,"tags"=>(tag == 'all' ? all_tags : [tag])}.to_param if read_more_url != ""
read_more_text = I18n.t("announcement.more") read_more_text = I18n.t("curation.more")
if tag != "all" if tag != "all"
begin begin
read_more_text = I18n.t("announcement.more_") + tags_translations[tag] read_more_text = I18n.t("curation.more_") + tags_translations[tag]
rescue rescue
nil nil
end end
@ -318,10 +318,10 @@ class CurationsController < ApplicationController
}.join("") : cats.map.with_index{|cat,i| }.join("") : cats.map.with_index{|cat,i|
read_more_url = "#{page_url}" rescue "" read_more_url = "#{page_url}" rescue ""
read_more_url = read_more_url + "?" + {"category"=>(cat == 'all' ? all_cats : cat)}.to_param if read_more_url != "" read_more_url = read_more_url + "?" + {"category"=>(cat == 'all' ? all_cats : cat)}.to_param if read_more_url != ""
read_more_text = I18n.t("announcement.more") read_more_text = I18n.t("curation.more")
if cat != "all" if cat != "all"
begin begin
read_more_text = I18n.t("announcement.more_") + cats_translations[cat] read_more_text = I18n.t("curation.more_") + cats_translations[cat]
rescue rescue
nil nil
end end
@ -399,10 +399,10 @@ class CurationsController < ApplicationController
</style> </style>
' '
else else
read_more_text = I18n.t("announcement.more") read_more_text = I18n.t("curation.more")
if cats.count == 1 && cats[0] != "all" if cats.count == 1 && cats[0] != "all"
begin begin
read_more_text = I18n.t("announcement.more_") + ((all_tags.count == 1 && all_tags[0] != 'all') ? tags_translations[tags[0]] : cats_translations[cats[0]]) read_more_text = I18n.t("curation.more_") + ((all_tags.count == 1 && all_tags[0] != 'all') ? tags_translations[tags[0]] : cats_translations[cats[0]])
rescue rescue
nil nil
end end
@ -476,15 +476,15 @@ class CurationsController < ApplicationController
"more_url"=>read_more_url, "more_url"=>read_more_url,
"main_picture" => mp, "main_picture" => mp,
"main_picture_description" => mpd, "main_picture_description" => mpd,
"title-head" => t('announcement.table.title'), "title-head" => t('curation.table.title'),
"date-head" => t('announcement.table.date'), "date-head" => t('curation.table.date'),
"author-head" => t('announcement.table.author'), "author-head" => t('curation.table.author'),
"annc-dept-head" => t("announcement.annc_dept"), "annc-dept-head" => t("curation.annc_dept"),
"status-head" => t('announcement.table.status'), "status-head" => t('curation.table.status'),
"subtitle-head" => t('announcement.table.sub_title'), "subtitle-head" => t('curation.table.sub_title'),
"category-head" => t('announcement.table.category'), "category-head" => t('curation.table.category'),
"link-head" => t('announcement.table.link'), "link-head" => t('curation.table.link'),
"file-head" => t('announcement.table.file'), "file-head" => t('curation.table.file'),
"read_more" => read_more_url, "read_more" => read_more_url,
"read_more_text" => "read more", "read_more_text" => "read more",
"extra_brefore_html" => extra_html, "extra_brefore_html" => extra_html,
@ -503,7 +503,7 @@ class CurationsController < ApplicationController
@image_version = 'thumb' @image_version = 'thumb'
@show_options = nil @show_options = nil
if subpart.methods.include? 'select_options'.to_sym if subpart.methods.include? 'select_options'.to_sym
module_app = ModuleApp.where(key: 'announcement').first module_app = ModuleApp.where(key: 'curation').first
if module_app if module_app
@show_options = module_app.show_options @show_options = module_app.show_options
end end
@ -514,30 +514,30 @@ class CurationsController < ApplicationController
tmp = value[:en] tmp = value[:en]
case select_option.field_name case select_option.field_name
when @show_options.keys[0].to_s when @show_options.keys[0].to_s
if tmp == t('announcement.small_size') if tmp == t('curation.small_size')
@image_version = 'thumb' @image_version = 'thumb'
elsif tmp == t('announcement.medium_size') elsif tmp == t('curation.medium_size')
@image_version = 'mobile' @image_version = 'mobile'
elsif tmp == t('announcement.orignal_size') elsif tmp == t('curation.orignal_size')
@image_version = 'orignal' @image_version = 'orignal'
end end
when @show_options.keys[1].to_s when @show_options.keys[1].to_s
tab_options.each_with_index do |option,i| tab_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}") if tmp == t("curation.#{option}")
@tab_option = i @tab_option = i
break break
end end
end end
when @show_options.keys[2].to_s when @show_options.keys[2].to_s
read_more_options.each_with_index do |option,i| read_more_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}") if tmp == t("curation.#{option}")
@read_more_option = i @read_more_option = i
break break
end end
end end
when @show_options.keys[3].to_s when @show_options.keys[3].to_s
all_setting_options.each_with_index do |option,i| all_setting_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}") if tmp == t("curation.#{option}")
@all_setting_option = i @all_setting_option = i
break break
end end
@ -564,7 +564,7 @@ class CurationsController < ApplicationController
end end
subpart = OrbitHelper.get_current_widget subpart = OrbitHelper.get_current_widget
widget_data_count = OrbitHelper.widget_data_count widget_data_count = OrbitHelper.widget_data_count
anns_cache = AnnsCache.where(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s) anns_cache = CurationCache.where(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s)
devide_flag = (!(defined? SiteFeed).nil?) && (SiteFeed.count != 0) devide_flag = (!(defined? SiteFeed).nil?) && (SiteFeed.count != 0)
anns_cache.all_of([{:invalid_date.ne=>nil},{:invalid_date.lte => Time.now}]).destroy anns_cache.all_of([{:invalid_date.ne=>nil},{:invalid_date.lte => Time.now}]).destroy
count = anns_cache.count count = anns_cache.count
@ -572,9 +572,9 @@ class CurationsController < ApplicationController
anns_cache.limit(count-1).destroy anns_cache.limit(count-1).destroy
end end
if anns_cache.count == 0 || is_random if anns_cache.count == 0 || is_random
Bulletin.remove_expired_status CurationPost.remove_expired_status
uid = OrbitHelper.params[:uid] rescue "" uid = OrbitHelper.params[:uid] rescue ""
anns_for_locale = Bulletin.where(:title.nin => ["",nil], :uid.ne => uid).is_approved_and_show.filter_cats_and_tags(cats,tags) anns_for_locale = CurationPost.where(:title.nin => ["",nil], :uid.ne => uid).is_approved_and_show.filter_cats_and_tags(cats,tags)
sorted_anns = anns_for_locale.can_display_and_sorted sorted_anns = anns_for_locale.can_display_and_sorted
if !is_random if !is_random
sorted_anns = sorted_anns.limit(widget_data_count) sorted_anns = sorted_anns.limit(widget_data_count)
@ -586,10 +586,10 @@ class CurationsController < ApplicationController
now_anns = sorted_anns.to_a now_anns = sorted_anns.to_a
top_anns = now_anns.select{|v| v.is_top}.map{|v| data_to_human_type(v,set_tags)} top_anns = now_anns.select{|v| v.is_top}.map{|v| data_to_human_type(v,set_tags)}
not_top_anns = now_anns.select{|v| !v.is_top}.map{|v| data_to_human_type(v,set_tags)} not_top_anns = now_anns.select{|v| !v.is_top}.map{|v| data_to_human_type(v,set_tags)}
AnnsCache.create(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s,filter_result: {top: top_anns,not_top: not_top_anns},invalid_date: invalid_date) CurationCache.create(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s,filter_result: {top: top_anns,not_top: not_top_anns},invalid_date: invalid_date)
else else
anns = sorted_anns.map{|v| data_to_human_type(v,set_tags)} anns = sorted_anns.map{|v| data_to_human_type(v,set_tags)}
AnnsCache.create(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s,filter_result: anns,invalid_date: invalid_date) CurationCache.create(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s,filter_result: anns,invalid_date: invalid_date)
end end
else else
invalid_date = Time.now + 3.second invalid_date = Time.now + 3.second
@ -643,7 +643,7 @@ class CurationsController < ApplicationController
render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html' render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html'
return return
end end
file = BulletinFile.find(params[:id]) file = CurationPostFile.find(params[:id])
if File.basename(file.file.path) != URI.decode(params[:f_name]) if File.basename(file.file.path) != URI.decode(params[:f_name])
render :file => "#{Rails.root}/app/views/errors/403.html", :layout => false, :status => :not_found, :content_type => 'text/html' render :file => "#{Rails.root}/app/views/errors/403.html", :layout => false, :status => :not_found, :content_type => 'text/html'
return return
@ -680,21 +680,21 @@ class CurationsController < ApplicationController
def show_local_announcement(uid, is_preview) def show_local_announcement(uid, is_preview)
locale = OrbitHelper.get_site_locale.to_s locale = OrbitHelper.get_site_locale.to_s
if is_preview if is_preview
announcement = Bulletin.where(:uid => uid).first announcement = CurationPost.where(:uid => uid).first
else else
announcement = Bulletin.can_display_and_sorted.where(:uid => uid).first announcement = CurationPost.can_display_and_sorted.where(:uid => uid).first
end end
announcement = Bulletin.where(:uid => uid).first if announcement.nil? announcement = CurationPost.where(:uid => uid).first if announcement.nil?
return nil if announcement.nil? return nil if announcement.nil?
@bulletin = announcement @bulletin = announcement
url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/announcements/#{announcement.id.to_s}/edit" : "" url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/curations/#{announcement.id.to_s}/edit" : ""
access_level = OrbitHelper.user_access_level? access_level = OrbitHelper.user_access_level?
if !announcement.approved && (access_level != "manager" && access_level != "admin") if !announcement.approved && (access_level != "manager" && access_level != "admin")
if AnnouncementSetting.is_pro? if CurationSetting.is_pro?
if !(access_level == "sub_manager" && AnnouncementSetting.first.approvers.include?(OrbitHelper.current_user.id.to_s)) if !(access_level == "sub_manager" && CurationSetting.first.approvers.include?(OrbitHelper.current_user.id.to_s))
return {} return {}
end end
elsif access_level != "sub_manager" elsif access_level != "sub_manager"
@ -721,7 +721,7 @@ class CurationsController < ApplicationController
"alt_title" => '', "alt_title" => '',
"carousel_html" => '', "carousel_html" => '',
"sub_anncs_text" => '', "sub_anncs_text" => '',
"body" => "<b class='announcement_expired'>#{I18n.t('announcement.expired')}</b><br><a class='announcement_go_back_list' href='./' title='#{I18n.t('announcement.go_back')}'>#{I18n.t('announcement.go_back')}</a>".html_safe "body" => "<b class='announcement_expired'>#{I18n.t('curation.expired')}</b><br><a class='announcement_go_back_list' href='./' title='#{I18n.t('curation.go_back')}'>#{I18n.t('curation.go_back')}</a>".html_safe
}, },
"comments" => [], "comments" => [],
"show_comment_flag" => '', "show_comment_flag" => '',
@ -735,8 +735,8 @@ class CurationsController < ApplicationController
"tag" => tag.name , "tag" => tag.name ,
"url" => OrbitHelper.page_for_tag(tag) "url" => OrbitHelper.page_for_tag(tag)
} } rescue [] } } rescue []
files = announcement.bulletin_files.to_fronted(locale) files = announcement.curation_post_files.to_fronted(locale)
links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] links = announcement.curation_post_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
update_user = "" update_user = ""
if enable_annc_dept if enable_annc_dept
update_user = annc_depts_translations[locale][announcement.annc_dept] rescue "" update_user = annc_depts_translations[locale][announcement.annc_dept] rescue ""
@ -744,7 +744,7 @@ class CurationsController < ApplicationController
update_user = announcement.update_user.member_profile.name rescue "" update_user = announcement.update_user.member_profile.name rescue ""
end end
desc = announcement.image_description desc = announcement.image_description
desc = (desc.nil? || desc == "" ? "announcement image" : desc) desc = (desc.nil? || desc == "" ? "curation image" : desc)
request = OrbitHelper.request request = OrbitHelper.request
meta_desc = announcement.subtitle.nil? || announcement.subtitle == "" ? announcement.text.to_s[0..200] : announcement.subtitle meta_desc = announcement.subtitle.nil? || announcement.subtitle == "" ? announcement.text.to_s[0..200] : announcement.subtitle
@ -788,7 +788,7 @@ class CurationsController < ApplicationController
sub_anncs_text += "<div class=\"i-annc\"><table class=\"sub_anncs_table i-annc__table table table-striped\"> sub_anncs_text += "<div class=\"i-annc\"><table class=\"sub_anncs_table i-annc__table table table-striped\">
<thead><tr> <thead><tr>
<th class=\"i-annc__th i-annc__th--title\">#{announcement.get_sub_annc_title_trans}</th> <th class=\"i-annc__th i-annc__th--title\">#{announcement.get_sub_annc_title_trans}</th>
#{display_sub_annc_date ? "<th class=\"i-annc__th i-annc__th--date\">#{I18n.t("announcement.table.date")}</th>" : ''} #{display_sub_annc_date ? "<th class=\"i-annc__th i-annc__th--date\">#{I18n.t("curation.table.date")}</th>" : ''}
</tr></thead> </tr></thead>
<tbody>" <tbody>"
sub_anncs.each do |sub_annc| sub_anncs.each do |sub_annc|
@ -813,7 +813,7 @@ class CurationsController < ApplicationController
if carousel_data["carousel_count"] != 0 if carousel_data["carousel_count"] != 0
carousel_image_type = announcement.carousel_image_type carousel_image_type = announcement.carousel_image_type
ac = ActionController::Base.new() ac = ActionController::Base.new()
carousel_html = ac.render_to_string(:partial=>'announcements/bulletin_carousels',:locals=>{:data=>carousel_data,:carousel_image_type=>carousel_image_type}) carousel_html = ac.render_to_string(:partial=>'curations/bulletin_carousels',:locals=>{:data=>carousel_data,:carousel_image_type=>carousel_image_type})
end end
{ {
"tags" => tags, "tags" => tags,
@ -861,18 +861,18 @@ class CurationsController < ApplicationController
} }
} }
files = announcement["bulletin_files"].map{|file| { "file_url" => file["url"], "file_title" => (file["title_translations"][locale] == "" ? URI.unescape(File.basename(file["url"])) : file["title_translations"][locale] rescue '') } } rescue [] files = announcement["curation_post_files"].map{|file| { "file_url" => file["url"], "file_title" => (file["title_translations"][locale] == "" ? URI.unescape(File.basename(file["url"])) : file["title_translations"][locale] rescue '') } } rescue []
files.each do |file| files.each do |file|
if file["file_url"] =="" || file["file_url"] == nil if file["file_url"] =="" || file["file_url"] == nil
files.delete(file) files.delete(file)
end end
end end
links = announcement["bulletin_links"].map{|link| { "link_url" => link["url"], "link_title" => (link["title_translations"][locale] == "" ? link["url"] : link["title_translations"][locale]) } } rescue [] links = announcement["curation_post_links"].map{|link| { "link_url" => link["url"], "link_title" => (link["title_translations"][locale] == "" ? link["url"] : link["title_translations"][locale]) } } rescue []
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 == "" ? "curation image" : desc)
img_description = nil img_description = nil
img_description = announcement["image_description_translations"][I18n.locale] if announcement['display_img'] img_description = announcement["image_description_translations"][I18n.locale] if announcement['display_img']
img_src = nil img_src = nil
@ -900,7 +900,7 @@ class CurationsController < ApplicationController
datetime = announcement["postdate"] ? DateTime.parse(announcement["postdate"]) : nil datetime = announcement["postdate"] ? DateTime.parse(announcement["postdate"]) : nil
bulletin_carousel_images = Array(announcement["bulletin_carousel_images"]) bulletin_carousel_images = Array(announcement["curation_post_carousel_images"])
resume_btn_title = (I18n.locale.to_s =="zh_tw") ? "繼續播放" : "resume" resume_btn_title = (I18n.locale.to_s =="zh_tw") ? "繼續播放" : "resume"
pause_btn_title = (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause" pause_btn_title = (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause"
prev_btn_title = (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev" prev_btn_title = (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev"
@ -911,7 +911,7 @@ class CurationsController < ApplicationController
"pause_btn_title" => pause_btn_title, "pause_btn_title" => pause_btn_title,
"prev_btn_title" => prev_btn_title, "prev_btn_title" => prev_btn_title,
"next_btn_title" => next_btn_title, "next_btn_title" => next_btn_title,
"carousel_display_style" => (bulletin_carousel_images.count == 0 ? 'display: none' : "width: #{AnnouncementSetting.last.carousel_image_width};margin: auto;"), "carousel_display_style" => (bulletin_carousel_images.count == 0 ? 'display: none' : "width: #{CurationSetting.last.carousel_image_width};margin: auto;"),
"carousel_count" => bulletin_carousel_images.count} "carousel_count" => bulletin_carousel_images.count}
carousel_html = "" carousel_html = ""
if carousel_data["carousel_count"] != 0 if carousel_data["carousel_count"] != 0
@ -966,12 +966,12 @@ class CurationsController < ApplicationController
@categories = params[:categories] @categories = params[:categories]
end end
root_page = Page.root root_page = Page.root
annc_params = {:module=>"announcement", :enabled_for=>I18n.locale.to_s} annc_params = {:module=>"curation", :enabled_for=>I18n.locale.to_s}
annc_page = (root_page.respond_to?(:find_page) ? root_page.find_page(annc_params).first : Page.where(annc_params).first) annc_page = (root_page.respond_to?(:find_page) ? root_page.find_page(annc_params).first : Page.where(annc_params).first)
OrbitHelper.set_page(annc_page) if OrbitHelper.respond_to?(:set_page) OrbitHelper.set_page(annc_page) if OrbitHelper.respond_to?(:set_page)
params[:url] = (annc_page ? annc_page.url : nil) params[:url] = (annc_page ? annc_page.url : nil)
OrbitHelper.set_site_locale(I18n.locale) OrbitHelper.set_site_locale(I18n.locale)
OrbitHelper.set_current_widget_module("announcement") OrbitHelper.set_current_widget_module("curation")
OrbitHelper.set_params(params,current_user) OrbitHelper.set_params(params,current_user)
Bulletin.remove_expired_status Bulletin.remove_expired_status
OrbitHelper.set_page_number(params[:page_no].to_i) OrbitHelper.set_page_number(params[:page_no].to_i)
@ -995,7 +995,7 @@ class CurationsController < ApplicationController
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
author = tmp_enable_annc_dept ? annc_depts[a.annc_dept] : User.find(a.update_user_id).member_profile.name rescue "" author = tmp_enable_annc_dept ? annc_depts[a.annc_dept] : User.find(a.update_user_id).member_profile.name rescue ""
desc = a.image_description desc = a.image_description
desc = (desc.blank? ? "announcement image" : desc) desc = (desc.blank? ? "curation image" : desc)
link_to_show = (a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)) rescue "" link_to_show = (a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)) rescue ""
target = a.is_external_link ? "_blank" : "_self" target = a.is_external_link ? "_blank" : "_self"
title = a.title_plain_text title = a.title_plain_text
@ -1018,7 +1018,7 @@ class CurationsController < ApplicationController
"target" => target, "target" => target,
"img_src" => a.image.thumb.url || DefaultImgSrc, "img_src" => a.image.thumb.url || DefaultImgSrc,
"img_description" => desc, "img_description" => desc,
"more" => t("announcement.more"), "more" => t("curation.more"),
"view_count" => a.view_count "view_count" => a.view_count
} }
else else
@ -1036,18 +1036,18 @@ class CurationsController < ApplicationController
@data = { @data = {
"announcements" => anns, "announcements" => anns,
"extras" => { "extras" => {
"widget-title" =>t('announcement.announcement'), "widget-title" =>t('curation.curation'),
"title-head" => t('announcement.table.title'), "title-head" => t('curation.table.title'),
"date-head" => t('announcement.table.date'), "date-head" => t('curation.table.date'),
"status-head" => t('announcement.table.status'), "status-head" => t('curation.table.status'),
"author-head" => t('announcement.table.author'), "author-head" => t('curation.table.author'),
"subtitle-head" => t('announcement.table.sub_title'), "subtitle-head" => t('curation.table.sub_title'),
"category-head" => t('announcement.table.category'), "category-head" => t('curation.table.category'),
"link-head" => t('announcement.table.link'), "link-head" => t('curation.table.link'),
"file-head" => t('announcement.table.file'), "file-head" => t('curation.table.file'),
"view-count-head" => t('announcement.table.view_count'), "view-count-head" => t('curation.table.view_count'),
"display" => display, "display" => display,
"department-head" => t('announcement.table.department') "department-head" => t('curation.table.department')
}, },
"total_pages" => total_pages "total_pages" => total_pages
} }
@ -1073,17 +1073,17 @@ class CurationsController < ApplicationController
all_tags = subpart.tags all_tags = subpart.tags
all_tags = ['all'] if all_tags.length==0 all_tags = ['all'] if all_tags.length==0
page = Page.where(:page_id=> subpart.read_more_page_id).first rescue nil page = Page.where(:page_id=> subpart.read_more_page_id).first rescue nil
page = Page.where(:module => "announcement").first rescue nil if page.nil? page = Page.where(:module => "curation").first rescue nil if page.nil?
read_more_url_root = "/#{I18n.locale.to_s + page.url}" rescue "" read_more_url_root = "/#{I18n.locale.to_s + page.url}" rescue ""
read_more_url = read_more_url_root + "?" + {"category"=>all_cats,"tags"=> all_tags}.to_param if read_more_url != "" read_more_url = read_more_url_root + "?" + {"category"=>all_cats,"tags"=> all_tags}.to_param if read_more_url != ""
else else
page = Page.where(:module => "announcement").first page = Page.where(:module => "curation").first
read_more_url_root = "/#{I18n.locale.to_s + page.url}" rescue "" read_more_url_root = "/#{I18n.locale.to_s + page.url}" rescue ""
end end
if params[:unix_start].present? && params[:unix_end].present? if params[:unix_start].present? && params[:unix_end].present?
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
events = Bulletin.agenda_events(agenda_start,agenda_end,read_more_url_root) events = CurationPost.agenda_events(agenda_start,agenda_end,read_more_url_root)
end end
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true}) render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true})
end end
@ -1091,7 +1091,7 @@ class CurationsController < ApplicationController
def get_calendar_title(now_date=nil) def get_calendar_title(now_date=nil)
now_date = Time.now.utc if now_date.nil? now_date = Time.now.utc if now_date.nil?
month_name = I18n.locale.to_s=='zh_tw' ? now_date.month : I18n.t("announcement.month_name.#{now_date.month}") month_name = I18n.locale.to_s=='zh_tw' ? now_date.month : I18n.t("curation.month_name.#{now_date.month}")
I18n.t("announcement.calendar_title",year: now_date.year,month: month_name) I18n.t("curation.calendar_title",year: now_date.year,month: month_name)
end end
end end

View File

@ -6,7 +6,7 @@ module Admin::CurationsHelper
def page_for_bulletin(bulletin) def page_for_bulletin(bulletin)
if !bulletin.is_external_link || bulletin.external_link.blank? if !bulletin.is_external_link || bulletin.external_link.blank?
ann_page = nil ann_page = nil
pages = Page.where(:module=>'announcement').select{|page| page.enabled_for.include?(I18n.locale.to_s)} pages = Page.where(:module=>'curation').select{|page| page.enabled_for.include?(I18n.locale.to_s)}
pages.each do |page| pages.each do |page|
if page.categories.count ==1 if page.categories.count ==1
@ -98,7 +98,7 @@ module Admin::CurationsHelper
desc_en = row.cells[17].value.split(";") rescue [] desc_en = row.cells[17].value.split(";") rescue []
desc_zh_tw = row.cells[18].value.split(";") rescue [] desc_zh_tw = row.cells[18].value.split(";") rescue []
links.each_with_index do |link,i| links.each_with_index do |link,i|
bl = BulletinLink.new bl = CurationPostLink.new
bl.url = link.strip bl.url = link.strip
bl.title_translations = {"en" => desc_en[i], "zh_tw" => desc_zh_tw[i]} bl.title_translations = {"en" => desc_en[i], "zh_tw" => desc_zh_tw[i]}
bl.bulletin_id = anns.id bl.bulletin_id = anns.id
@ -111,7 +111,7 @@ module Admin::CurationsHelper
alt_en = row.cells[22].value.split(";") rescue [] alt_en = row.cells[22].value.split(";") rescue []
alt_zh_tw = row.cells[23].value.split(";") rescue [] alt_zh_tw = row.cells[23].value.split(";") rescue []
files.each_with_index do |file, i| files.each_with_index do |file, i|
bf = BulletinFile.new bf = CurationPostFile.new
bf.remote_file_url = file.strip rescue nil bf.remote_file_url = file.strip rescue nil
bf.title_translations = {"en" => (alt_en[i] rescue ""), "zh_tw" => (alt_zh_tw[i] rescue "")} bf.title_translations = {"en" => (alt_en[i] rescue ""), "zh_tw" => (alt_zh_tw[i] rescue "")}
bf.description_translations = {"en" => (desc_en[i] rescue ""), "zh_tw" => (desc_zh_tw[i] rescue "")} bf.description_translations = {"en" => (desc_en[i] rescue ""), "zh_tw" => (desc_zh_tw[i] rescue "")}
@ -131,8 +131,8 @@ module Admin::CurationsHelper
if !user.nil? if !user.nil?
email = user.member_profile.email email = user.member_profile.email
if !email.nil? && email != "" if !email.nil? && email != ""
url = "http://#{request.host_with_port}/admin/announcements/#{announcement.id}/edit" url = "http://#{request.host_with_port}/admin/curations/#{announcement.id}/edit"
datatosend = "<h3>Hello #{user.name},</h3><p>#{current_user.name} #{t("announcement.rejected_annoucement")} : #{announcement.rejection_reason} <a href='#{url}'> #{t("announcement.click_here_to_see")}</a></p>" datatosend = "<h3>Hello #{user.name},</h3><p>#{current_user.name} #{t("curations.rejected_annoucement")} : #{announcement.rejection_reason} <a href='#{url}'> #{t("curations.click_here_to_see")}</a></p>"
mail = Email.new(:mail_to => email, :mail_subject => "Announcement rejected公告未通過 : #{announcement.title_translations[locale]}.", :template => "email/announcement_email.html.erb", :template_data => {"html" => datatosend}) mail = Email.new(:mail_to => email, :mail_subject => "Announcement rejected公告未通過 : #{announcement.title_translations[locale]}.", :template => "email/announcement_email.html.erb", :template_data => {"html" => datatosend})
mail.save mail.save
mail.deliver rescue nil mail.deliver rescue nil
@ -169,15 +169,15 @@ module Admin::CurationsHelper
end end
def send_email(name, useremail, announcement, type, locale) def send_email(name, useremail, announcement, type, locale)
url = "http://#{request.host_with_port}/admin/announcements?url=#{page_for_bulletin(announcement).sub("http://" + request.host_with_port, "")}&id=#{announcement.id}" url = "http://#{request.host_with_port}/admin/curations?url=#{page_for_bulletin(announcement).sub("http://" + request.host_with_port, "")}&id=#{announcement.id}"
case type case type
when "approval" when "approval"
datatosend = "<h3>#{t("announcement.approval_mail_hi", :name => name)},</h3><p>#{t("announcement.submitted_new_announcement", :poster => current_user.name)}<br /><br />#{t("announcement.approval_announcement_title")} : #{announcement.title_translations[locale]} <br /> #{t("announcement.click_here_to_see")} : <a href='#{url}'> #{url} </a></p>" datatosend = "<h3>#{t("curation.approval_mail_hi", :name => name)},</h3><p>#{t("curation.submitted_new_announcement", :poster => current_user.name)}<br /><br />#{t("curation.approval_announcement_title")} : #{announcement.title_translations[locale]} <br /> #{t("curation.click_here_to_see")} : <a href='#{url}'> #{url} </a></p>"
when "reapproval" when "reapproval"
datatosend = "<h3>#{t("announcement.approval_mail_hi", :name => name)},</h3><p>#{t("announcement.updated_annoucement", :poster => current_user.name)}<br /><br />#{t("announcement.approval_announcement_title")} : #{announcement.title_translations[locale]} <br /> #{t("announcement.click_here_to_see")} : <a href='#{url}'> #{url} </a></p>" datatosend = "<h3>#{t("curation.approval_mail_hi", :name => name)},</h3><p>#{t("curation.updated_annoucement", :poster => current_user.name)}<br /><br />#{t("curation.approval_announcement_title")} : #{announcement.title_translations[locale]} <br /> #{t("curation.click_here_to_see")} : <a href='#{url}'> #{url} </a></p>"
end end
email = Email.new(:mail_to => useremail, :mail_subject => " #{t("announcement.announcement_subject")} : #{announcement.title_translations[locale]}.", :template => "email/announcement_email.html.erb", :template_data => {"html" => datatosend}) email = Email.new(:mail_to => useremail, :mail_subject => " #{t("curation.announcement_subject")} : #{announcement.title_translations[locale]}.", :template => "email/announcement_email.html.erb", :template_data => {"html" => datatosend})
email.save email.save
email.deliver rescue nil email.deliver rescue nil
end end
@ -203,7 +203,7 @@ module Admin::CurationsHelper
} }
end end
announcements.each do |anns| announcements.each do |anns|
ma = ModuleApp.where(:key => "announcement").first ma = ModuleApp.where(:key => "curation").first
cat = Category.where(:title => anns[:category]).first rescue nil cat = Category.where(:title => anns[:category]).first rescue nil
if cat.nil? if cat.nil?
cat = Category.create(:title_translations => {"en" => anns[:category], "zh_tw" => anns[:category]}, :module_app_id => ma.id) cat = Category.create(:title_translations => {"en" => anns[:category], "zh_tw" => anns[:category]}, :module_app_id => ma.id)
@ -281,7 +281,7 @@ module Admin::CurationsHelper
def user_can_approve?(anns=nil) def user_can_approve?(anns=nil)
can_approve = false can_approve = false
setting = AnnouncementSetting.first setting = CurationSetting.first
case @access_level case @access_level
when "admin" when "admin"
can_approve = true can_approve = true

View File

@ -10,12 +10,12 @@ module CurationsHelper
"status-class" => "status-#{status['classname']}" "status-class" => "status-#{status['classname']}"
} }
end end
files = a.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } if file.enabled_for?(locale) } rescue [] files = a.curation_post_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } if file.enabled_for?(locale) } rescue []
files.delete(nil) files.delete(nil)
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] links = a.curation_post_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
author = tmp_enable_annc_dept ? annc_depts[a.annc_dept] : User.find(a.update_user_id).member_profile.name rescue "" author = tmp_enable_annc_dept ? annc_depts[a.annc_dept] : User.find(a.update_user_id).member_profile.name rescue ""
desc = a.image_description desc = a.image_description
desc = (desc.nil? || desc == "" ? "announcement image" : desc) desc = (desc.nil? || desc == "" ? "curation image" : desc)
link_to_show = (a.is_external_link? ? a.external_link : OrbitHelper.widget_item_url(a.to_param)) rescue "" link_to_show = (a.is_external_link? ? a.external_link : OrbitHelper.widget_item_url(a.to_param)) rescue ""
target = a.is_external_link ? "_blank" : "_self" target = a.is_external_link ? "_blank" : "_self"
if @image_version == 'thumb' if @image_version == 'thumb'
@ -44,12 +44,12 @@ module CurationsHelper
"author" => author, "author" => author,
"link_to_show" => link_to_show+"\" #{(link_to_show[0] == '/' rescue true) ? '' : 'target="_blank"'} title=\"#{title}", "link_to_show" => link_to_show+"\" #{(link_to_show[0] == '/' rescue true) ? '' : 'target="_blank"'} title=\"#{title}",
"target" => target, "target" => target,
"img_src" => image_url || AnnouncementsController::DefaultImgSrc, "img_src" => image_url || CurationsController::DefaultImgSrc,
"img_description" => desc "img_description" => desc
} }
end end
def get_feed_annc(type,site_source,locale,categories=nil,max_len=nil,sort_maps=nil,extra_match_cond=nil) def get_feed_annc(type,site_source,locale,categories=nil,max_len=nil,sort_maps=nil,extra_match_cond=nil)
ma_key = 'announcement' ma_key = 'curation'
if categories.nil? if categories.nil?
if type == "index" if type == "index"
categories = Array(OrbitHelper.page_categories) categories = Array(OrbitHelper.page_categories)
@ -140,7 +140,7 @@ module CurationsHelper
} }
end end
if !params["source"].present? if !params["source"].present?
announcements = Bulletin.can_display_and_sorted announcements = CurationPost.can_display_and_sorted
.filter_by_categories(categories, false).filter_by_tags(tags) .filter_by_categories(categories, false).filter_by_tags(tags)
.where(:title.nin => ["",nil]) .where(:title.nin => ["",nil])
if !extra_match_cond.empty? if !extra_match_cond.empty?
@ -243,9 +243,9 @@ module CurationsHelper
if @target_action == "index" if @target_action == "index"
filename = File.basename(overridehtml.nil? ? params[:layout_type] : overridehtml) filename = File.basename(overridehtml.nil? ? params[:layout_type] : overridehtml)
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "#{filename}.html.erb") f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'curation', "#{filename}.html.erb")
if !File.exist?f if !File.exist?f
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "index.html.erb") f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'curation', "index.html.erb")
if !File.exist?f if !File.exist?f
return "<div class='well'>Maybe the administrator has changed the theme, please select the index page design again from the page settings.</div>".html_safe return "<div class='well'>Maybe the administrator has changed the theme, please select the index page design again from the page settings.</div>".html_safe
end end
@ -253,11 +253,11 @@ module CurationsHelper
file = File.open(f) file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8") doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close file.close
controller = AnnouncementsController.new controller = CurationsController.new
begin begin
data = @data# rescue nil data = @data# rescue nil
rescue Exception => e rescue Exception => e
write_debug_file(e,'announcements',@target_action) if Site::DEBUG write_debug_file(e,'curations',@target_action) if Site::DEBUG
end end
if !data.nil? if !data.nil?
wrap_elements = doc.css("*[data-list][data-level='0']") wrap_elements = doc.css("*[data-list][data-level='0']")
@ -285,16 +285,16 @@ module CurationsHelper
end end
else else
filename = overridehtml.nil? ? @target_action : overridehtml filename = overridehtml.nil? ? @target_action : overridehtml
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "#{filename}.html.erb") f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'curation', "#{filename}.html.erb")
if File.exist?f if File.exist?f
file = File.open(f) file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8") doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close file.close
controller = AnnouncementsController.new controller = CurationsController.new
begin begin
data = @data# rescue nil data = @data# rescue nil
rescue Exception => e rescue Exception => e
write_debug_file(e,'announcements',@target_action) if Site::DEBUG write_debug_file(e,'curations',@target_action) if Site::DEBUG
end end
if data.nil? if data.nil?
return "<div class='well'> No content to show. </div>".html_safe return "<div class='well'> No content to show. </div>".html_safe
@ -310,7 +310,7 @@ module CurationsHelper
Thread.new do Thread.new do
impression = data['impressionist'].impressions.create impression = data['impressionist'].impressions.create
impression.user_id = request.session['user_id'] impression.user_id = request.session['user_id']
impression.controller_name = 'announcements' impression.controller_name = 'curationsements'
impression.action_name = @target_action impression.action_name = @target_action
impression.ip_address = request.remote_ip impression.ip_address = request.remote_ip
impression.session_hash = request.session.id impression.session_hash = request.session.id
@ -487,9 +487,9 @@ module CurationsHelper
def enable_manually_sort def enable_manually_sort
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['announcement'][:enable_manually_sort] OrbitHelper::SharedHash['curation'][:enable_manually_sort]
else else
AnnouncementSetting.first.enable_manually_sort rescue false CurationSetting.first.enable_manually_sort rescue false
end end
end end
end end

View File

@ -3,53 +3,53 @@ Rails.application.routes.draw do
scope "(:locale)", locale: Regexp.new(locales.join("|")) do scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do namespace :admin do
get "announcement/get_all_anncs_without_subannc", to: "announcements#get_all_anncs_without_subannc" get "curation/get_all_anncs_without_subannc", to: "curations#get_all_anncs_without_subannc"
post 'announcement/get_preview_action', to: 'announcements#get_preview_action' post 'curation/get_preview_action', to: 'curations#get_preview_action'
post 'announcement/preview', to: 'announcements#preview' post 'curation/preview', to: 'curations#preview'
post 'announcement/createfeed', to: 'announcements#createfeed' post 'curation/createfeed', to: 'curations#createfeed'
post 'announcement/importanns', to: 'announcements#importanns' post 'curation/importanns', to: 'curations#importanns'
post 'announcement/import_from_xml', to: 'announcements#import_from_xml' post 'curation/import_from_xml', to: 'curations#import_from_xml'
get 'announcement/excel_format', to: 'announcements#excel_format' get 'curation/excel_format', to: 'curations#excel_format'
get 'announcement/export_excel', to: 'announcements#export_excel' get 'curation/export_excel', to: 'curations#export_excel'
patch 'announcement/updatefeed', to: 'announcements#updatefeed' patch 'curation/updatefeed', to: 'curations#updatefeed'
delete 'announcement/deletefeed', to: 'announcements#deletefeed' delete 'curation/deletefeed', to: 'curations#deletefeed'
get 'announcement/destroy_preview/:slug_title-:uid', to: 'announcements#destroy_preview' get 'curation/destroy_preview/:slug_title-:uid', to: 'curations#destroy_preview'
post 'announcement/approve_bulletin', to: 'announcements#approve_bulletin' post 'curation/approve_bulletin', to: 'curations#approve_bulletin'
get 'announcement/feed', to: 'announcements#feed' get 'curation/feed', to: 'curations#feed'
get 'announcements/feedform', to: 'announcements#feedform' get 'curations/feedform', to: 'curations#feedform'
get 'announcement/settings', to: 'announcements#settings' get 'curation/settings', to: 'curations#settings'
get 'announcement/import', to: 'announcements#import' get 'curation/import', to: 'curations#import'
get 'announcement/download_file_from_thread', to: 'announcements#download_file_from_thread' get 'curation/download_file_from_thread', to: 'curations#download_file_from_thread'
post 'announcement/createsettings', to: 'announcements#createsettings' post 'curation/createsettings', to: 'curations#createsettings'
patch 'announcement/updatesettings', to: 'announcements#updatesettings' patch 'curation/updatesettings', to: 'curations#updatesettings'
post 'announcement/import_from_wp', to: 'announcements#import_from_wp' post 'curation/import_from_wp', to: 'curations#import_from_wp'
post 'announcement/generate_iframe_url' => 'announcements#generate_iframe_url' post 'curation/generate_iframe_url' => 'curations#generate_iframe_url'
delete 'announcements/delete', to: 'announcements#delete' delete 'curations/delete', to: 'curations#delete'
resources :announcements resources :curations
get 'announcements/:id/comment'=> 'announcements#comment' get 'curations/:id/comment'=> 'curations#comment'
get 'annc-comment-hidden/:id' => 'announcements#comment_hidden' get 'annc-comment-hidden/:id' => 'curations#comment_hidden'
resource :announcement,:only => [] do resource :curation,:only => [] do
collection do collection do
get "edit_sort" get "edit_sort"
post "update_sort_setting", to: 'announcements#update_sort_setting' post "update_sort_setting", to: 'curations#update_sort_setting'
post "update_sort", to: 'announcements#update_sort' post "update_sort", to: 'curations#update_sort'
end end
end end
end end
resources :announcements do resources :curations do
collection do collection do
get ':slug_title-:uid', to: 'announcements#show', as: :display get ':slug_title-:uid', to: 'curations#show', as: :display
end end
end end
post "/xhr/announcements/feed_add_remote/:uid" => "announcement_feeds#feed_add_remote" post "/xhr/curations/feed_add_remote/:uid" => "curation_feeds#feed_add_remote"
post "/xhr/announcements/feed_remove_remote/:uid" => "announcement_feeds#feed_remove_remote" post "/xhr/curations/feed_remove_remote/:uid" => "curation_feeds#feed_remove_remote"
get "/xhr/announcements/feed/:uid" => "announcement_feeds#feed" get "/xhr/curations/feed/:uid" => "curation_feeds#feed"
get "/xhr/announcements/rssfeed/:uid" => "announcement_feeds#rssfeed" get "/xhr/curations/rssfeed/:uid" => "curation_feeds#rssfeed"
get "/xhr/announcements/feeds" => "announcement_feeds#feeds" get "/xhr/curations/feeds" => "curation_feeds#feeds"
get '/xhr/announcements/announcement.json', to: 'bulletins#get_bulletins' get '/xhr/curations/curation.json', to: 'bulletins#get_bulletins'
get '/xhr/panel/announcement/widget/sync_data' => 'announcements#show_widget' get '/xhr/panel/curation/widget/sync_data' => 'curations#show_widget'
get '/xhr/announcements/:slug_title-:uid/comment', to: 'announcements#comment' get '/xhr/curations/:slug_title-:uid/comment', to: 'curations#comment'
get '/xhr/announcements/file/:id/*f_name', to: 'announcements#get_file', format: false get '/xhr/curations/file/:id/*f_name', to: 'curations#get_file', format: false
end end
end end