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

View File

@ -3,20 +3,20 @@ class CurationPostsController < ApplicationController
before_filter :set_I18n
def annc_depts_translations
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
AnnouncementSetting.first.annc_depts_translations rescue {}
CurationSetting.first.annc_depts_translations rescue {}
end
end
def enable_annc_dept
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
AnnouncementSetting.first.enable_annc_dept rescue false
CurationSetting.first.enable_annc_dept rescue false
end
end
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
@ -32,13 +32,13 @@ class CurationPostsController < ApplicationController
keyword = params[:keyword].to_s
if keyword.present?
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
bulletins = Bulletin.all
bulletins = CurationPost.all
end
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_id = Category.where(:title => category, :module_app_id => module_id).first.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(:approved.ne => false , :rejected.ne => true)
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)
else
bulletins = bulletins.desc( :is_top, :postdate).page(page_num).per(per_page)
@ -58,14 +58,14 @@ class CurationPostsController < ApplicationController
bulletins = bulletins.collect do |b|
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,
"url" => bl.url
}
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
{
"title" => bf.title_translations,
@ -107,9 +107,9 @@ class CurationPostsController < ApplicationController
# 計算總筆數 Start
if keyword.present?
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
bulletin_count = Bulletin.all
bulletin_count = CurationPost.all
end
bulletin_count = bulletin_count.where(:is_preview.in=>[false,nil])
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='';"
def initialize
super
@app_title = 'announcement'
@app_title = 'curation'
#self.request = OrbitHelper.request
end
def annc_depts_translations
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
AnnouncementSetting.first.annc_depts_translations rescue {}
CurationSetting.first.annc_depts_translations rescue {}
end
end
def enable_annc_dept
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
AnnouncementSetting.first.enable_annc_dept rescue false
CurationSetting.first.enable_annc_dept rescue false
end
end
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
def render_404
render(:file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => 404, :formats => [:html])
end
def comment
@bulletin = Bulletin.where(:uid=>params[:uid]).first
@bulletin = CurationPost.where(:uid=>params[:uid]).first
comment_val = params['comment']
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'
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.save
render :json => {}
@ -42,13 +42,13 @@ class CurationsController < ApplicationController
end
def index
@type = 'index'
Bulletin.remove_expired_status
CurationPost.remove_expired_status
params = @params = OrbitHelper.params
page = @page || Page.where(url: params['url']).first
@enable_search_flag = false
@image_version = 'thumb'
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
if module_app && page.respond_to?(:select_option_items)
@show_option_items = module_app.show_option_items
@ -59,17 +59,17 @@ class CurationsController < ApplicationController
case select_option_item.field_name
when @show_option_items.keys[1].to_s
value = YAML.load(select_option_item.value)
if value[:en] == t('announcement.yes')
if value[:en] == t('curation.yes')
@enable_search_flag = true
end
when @show_option_items.keys[2].to_s
value = YAML.load(select_option_item.value)
tmp = value[:en]
if tmp == t('announcement.small_size')
if tmp == t('curation.small_size')
@image_version = 'thumb'
elsif tmp == t('announcement.medium_size')
elsif tmp == t('curation.medium_size')
@image_version = 'mobile'
elsif tmp == t('announcement.orignal_size')
elsif tmp == t('curation.orignal_size')
@image_version = 'orignal'
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 []
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 = (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)
target = a.is_external_link ? "_blank" : "_self"
title = a.title_plain_text
@ -131,7 +131,7 @@ class CurationsController < ApplicationController
"target" => target,
"img_src" => image_url || DefaultImgSrc,
"img_description" => desc,
"more" => t("announcement.more"),
"more" => t("curation.more"),
"view_count" => a.view_count
}
else
@ -158,19 +158,19 @@ class CurationsController < ApplicationController
{
"announcements" => anns,
"extras" => {
"widget-title" =>t('announcement.announcement'),
"title-head" => t('announcement.table.title'),
"date-head" => t('announcement.table.date'),
"status-head" => t('announcement.table.status'),
"author-head" => t('announcement.table.author'),
"subtitle-head" => t('announcement.table.sub_title'),
"category-head" => t('announcement.table.category'),
"link-head" => t('announcement.table.link'),
"file-head" => t('announcement.table.file'),
"view-count-head" => t('announcement.table.view_count'),
"widget-title" =>t('curation.curation'),
"title-head" => t('curation.table.title'),
"date-head" => t('curation.table.date'),
"status-head" => t('curation.table.status'),
"author-head" => t('curation.table.author'),
"subtitle-head" => t('curation.table.sub_title'),
"category-head" => t('curation.table.category'),
"link-head" => t('curation.table.link'),
"file-head" => t('curation.table.file'),
"view-count-head" => t('curation.table.view_count'),
"display" => display,
"department-head" => t('announcement.table.department'),
"annc-dept-head" => t("announcement.annc_dept"),
"department-head" => t('curation.table.department'),
"annc-dept-head" => t("curation.annc_dept"),
"page-title" => @annc_page_title
},
"total_pages" => total_pages
@ -187,7 +187,7 @@ class CurationsController < ApplicationController
end
def tag_cloud
ma = ModuleApp.where(:key => "announcement").first
ma = ModuleApp.where(:key => "curation").first
temp = []
ma.tags.each do |tag|
t1 = tag.taggings.collect{|t| t.taggable_id.to_s}
@ -281,10 +281,10 @@ class CurationsController < ApplicationController
page = nil
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(: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
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
page_url = "/#{locale}#{(page.get_url rescue page.url)}"
end
@ -306,10 +306,10 @@ class CurationsController < ApplicationController
(use_tag ? tags.map.with_index{|tag,i|
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_text = I18n.t("announcement.more")
read_more_text = I18n.t("curation.more")
if tag != "all"
begin
read_more_text = I18n.t("announcement.more_") + tags_translations[tag]
read_more_text = I18n.t("curation.more_") + tags_translations[tag]
rescue
nil
end
@ -318,10 +318,10 @@ class CurationsController < ApplicationController
}.join("") : cats.map.with_index{|cat,i|
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_text = I18n.t("announcement.more")
read_more_text = I18n.t("curation.more")
if cat != "all"
begin
read_more_text = I18n.t("announcement.more_") + cats_translations[cat]
read_more_text = I18n.t("curation.more_") + cats_translations[cat]
rescue
nil
end
@ -399,10 +399,10 @@ class CurationsController < ApplicationController
</style>
'
else
read_more_text = I18n.t("announcement.more")
read_more_text = I18n.t("curation.more")
if cats.count == 1 && cats[0] != "all"
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
nil
end
@ -476,15 +476,15 @@ class CurationsController < ApplicationController
"more_url"=>read_more_url,
"main_picture" => mp,
"main_picture_description" => mpd,
"title-head" => t('announcement.table.title'),
"date-head" => t('announcement.table.date'),
"author-head" => t('announcement.table.author'),
"annc-dept-head" => t("announcement.annc_dept"),
"status-head" => t('announcement.table.status'),
"subtitle-head" => t('announcement.table.sub_title'),
"category-head" => t('announcement.table.category'),
"link-head" => t('announcement.table.link'),
"file-head" => t('announcement.table.file'),
"title-head" => t('curation.table.title'),
"date-head" => t('curation.table.date'),
"author-head" => t('curation.table.author'),
"annc-dept-head" => t("curation.annc_dept"),
"status-head" => t('curation.table.status'),
"subtitle-head" => t('curation.table.sub_title'),
"category-head" => t('curation.table.category'),
"link-head" => t('curation.table.link'),
"file-head" => t('curation.table.file'),
"read_more" => read_more_url,
"read_more_text" => "read more",
"extra_brefore_html" => extra_html,
@ -503,7 +503,7 @@ class CurationsController < ApplicationController
@image_version = 'thumb'
@show_options = nil
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
@show_options = module_app.show_options
end
@ -514,30 +514,30 @@ class CurationsController < ApplicationController
tmp = value[:en]
case select_option.field_name
when @show_options.keys[0].to_s
if tmp == t('announcement.small_size')
if tmp == t('curation.small_size')
@image_version = 'thumb'
elsif tmp == t('announcement.medium_size')
elsif tmp == t('curation.medium_size')
@image_version = 'mobile'
elsif tmp == t('announcement.orignal_size')
elsif tmp == t('curation.orignal_size')
@image_version = 'orignal'
end
when @show_options.keys[1].to_s
tab_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}")
if tmp == t("curation.#{option}")
@tab_option = i
break
end
end
when @show_options.keys[2].to_s
read_more_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}")
if tmp == t("curation.#{option}")
@read_more_option = i
break
end
end
when @show_options.keys[3].to_s
all_setting_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}")
if tmp == t("curation.#{option}")
@all_setting_option = i
break
end
@ -564,7 +564,7 @@ class CurationsController < ApplicationController
end
subpart = OrbitHelper.get_current_widget
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)
anns_cache.all_of([{:invalid_date.ne=>nil},{:invalid_date.lte => Time.now}]).destroy
count = anns_cache.count
@ -572,9 +572,9 @@ class CurationsController < ApplicationController
anns_cache.limit(count-1).destroy
end
if anns_cache.count == 0 || is_random
Bulletin.remove_expired_status
CurationPost.remove_expired_status
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
if !is_random
sorted_anns = sorted_anns.limit(widget_data_count)
@ -586,10 +586,10 @@ class CurationsController < ApplicationController
now_anns = sorted_anns.to_a
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
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
else
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'
return
end
file = BulletinFile.find(params[:id])
file = CurationPostFile.find(params[:id])
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'
return
@ -680,21 +680,21 @@ class CurationsController < ApplicationController
def show_local_announcement(uid, is_preview)
locale = OrbitHelper.get_site_locale.to_s
if is_preview
announcement = Bulletin.where(:uid => uid).first
announcement = CurationPost.where(:uid => uid).first
else
announcement = Bulletin.can_display_and_sorted.where(:uid => uid).first
announcement = CurationPost.can_display_and_sorted.where(:uid => uid).first
end
announcement = Bulletin.where(:uid => uid).first if announcement.nil?
announcement = CurationPost.where(:uid => uid).first if announcement.nil?
return nil if announcement.nil?
@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?
if !announcement.approved && (access_level != "manager" && access_level != "admin")
if AnnouncementSetting.is_pro?
if !(access_level == "sub_manager" && AnnouncementSetting.first.approvers.include?(OrbitHelper.current_user.id.to_s))
if CurationSetting.is_pro?
if !(access_level == "sub_manager" && CurationSetting.first.approvers.include?(OrbitHelper.current_user.id.to_s))
return {}
end
elsif access_level != "sub_manager"
@ -721,7 +721,7 @@ class CurationsController < ApplicationController
"alt_title" => '',
"carousel_html" => '',
"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" => [],
"show_comment_flag" => '',
@ -735,8 +735,8 @@ class CurationsController < ApplicationController
"tag" => tag.name ,
"url" => OrbitHelper.page_for_tag(tag)
} } rescue []
files = announcement.bulletin_files.to_fronted(locale)
links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
files = announcement.curation_post_files.to_fronted(locale)
links = announcement.curation_post_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
update_user = ""
if enable_annc_dept
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 ""
end
desc = announcement.image_description
desc = (desc.nil? || desc == "" ? "announcement image" : desc)
desc = (desc.nil? || desc == "" ? "curation image" : desc)
request = OrbitHelper.request
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\">
<thead><tr>
<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>
<tbody>"
sub_anncs.each do |sub_annc|
@ -813,7 +813,7 @@ class CurationsController < ApplicationController
if carousel_data["carousel_count"] != 0
carousel_image_type = announcement.carousel_image_type
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
{
"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|
if file["file_url"] =="" || file["file_url"] == nil
files.delete(file)
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"]
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 = announcement["image_description_translations"][I18n.locale] if announcement['display_img']
img_src = nil
@ -900,7 +900,7 @@ class CurationsController < ApplicationController
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"
pause_btn_title = (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause"
prev_btn_title = (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev"
@ -911,7 +911,7 @@ class CurationsController < ApplicationController
"pause_btn_title" => pause_btn_title,
"prev_btn_title" => prev_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_html = ""
if carousel_data["carousel_count"] != 0
@ -966,12 +966,12 @@ class CurationsController < ApplicationController
@categories = params[:categories]
end
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)
OrbitHelper.set_page(annc_page) if OrbitHelper.respond_to?(:set_page)
params[:url] = (annc_page ? annc_page.url : nil)
OrbitHelper.set_site_locale(I18n.locale)
OrbitHelper.set_current_widget_module("announcement")
OrbitHelper.set_current_widget_module("curation")
OrbitHelper.set_params(params,current_user)
Bulletin.remove_expired_status
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 []
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 = (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 ""
target = a.is_external_link ? "_blank" : "_self"
title = a.title_plain_text
@ -1018,7 +1018,7 @@ class CurationsController < ApplicationController
"target" => target,
"img_src" => a.image.thumb.url || DefaultImgSrc,
"img_description" => desc,
"more" => t("announcement.more"),
"more" => t("curation.more"),
"view_count" => a.view_count
}
else
@ -1036,18 +1036,18 @@ class CurationsController < ApplicationController
@data = {
"announcements" => anns,
"extras" => {
"widget-title" =>t('announcement.announcement'),
"title-head" => t('announcement.table.title'),
"date-head" => t('announcement.table.date'),
"status-head" => t('announcement.table.status'),
"author-head" => t('announcement.table.author'),
"subtitle-head" => t('announcement.table.sub_title'),
"category-head" => t('announcement.table.category'),
"link-head" => t('announcement.table.link'),
"file-head" => t('announcement.table.file'),
"view-count-head" => t('announcement.table.view_count'),
"widget-title" =>t('curation.curation'),
"title-head" => t('curation.table.title'),
"date-head" => t('curation.table.date'),
"status-head" => t('curation.table.status'),
"author-head" => t('curation.table.author'),
"subtitle-head" => t('curation.table.sub_title'),
"category-head" => t('curation.table.category'),
"link-head" => t('curation.table.link'),
"file-head" => t('curation.table.file'),
"view-count-head" => t('curation.table.view_count'),
"display" => display,
"department-head" => t('announcement.table.department')
"department-head" => t('curation.table.department')
},
"total_pages" => total_pages
}
@ -1073,17 +1073,17 @@ class CurationsController < ApplicationController
all_tags = subpart.tags
all_tags = ['all'] if all_tags.length==0
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 = read_more_url_root + "?" + {"category"=>all_cats,"tags"=> all_tags}.to_param if read_more_url != ""
else
page = Page.where(:module => "announcement").first
page = Page.where(:module => "curation").first
read_more_url_root = "/#{I18n.locale.to_s + page.url}" rescue ""
end
if params[:unix_start].present? && params[:unix_end].present?
agenda_start = Time.at(params[:unix_start].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
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true})
end
@ -1091,7 +1091,7 @@ class CurationsController < ApplicationController
def get_calendar_title(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}")
I18n.t("announcement.calendar_title",year: now_date.year,month: month_name)
month_name = I18n.locale.to_s=='zh_tw' ? now_date.month : I18n.t("curation.month_name.#{now_date.month}")
I18n.t("curation.calendar_title",year: now_date.year,month: month_name)
end
end

View File

@ -6,7 +6,7 @@ module Admin::CurationsHelper
def page_for_bulletin(bulletin)
if !bulletin.is_external_link || bulletin.external_link.blank?
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|
if page.categories.count ==1
@ -98,7 +98,7 @@ module Admin::CurationsHelper
desc_en = row.cells[17].value.split(";") rescue []
desc_zh_tw = row.cells[18].value.split(";") rescue []
links.each_with_index do |link,i|
bl = BulletinLink.new
bl = CurationPostLink.new
bl.url = link.strip
bl.title_translations = {"en" => desc_en[i], "zh_tw" => desc_zh_tw[i]}
bl.bulletin_id = anns.id
@ -111,7 +111,7 @@ module Admin::CurationsHelper
alt_en = row.cells[22].value.split(";") rescue []
alt_zh_tw = row.cells[23].value.split(";") rescue []
files.each_with_index do |file, i|
bf = BulletinFile.new
bf = CurationPostFile.new
bf.remote_file_url = file.strip rescue nil
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 "")}
@ -131,8 +131,8 @@ module Admin::CurationsHelper
if !user.nil?
email = user.member_profile.email
if !email.nil? && email != ""
url = "http://#{request.host_with_port}/admin/announcements/#{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>"
url = "http://#{request.host_with_port}/admin/curations/#{announcement.id}/edit"
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.save
mail.deliver rescue nil
@ -169,15 +169,15 @@ module Admin::CurationsHelper
end
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
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"
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
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.deliver rescue nil
end
@ -203,7 +203,7 @@ module Admin::CurationsHelper
}
end
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
if cat.nil?
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)
can_approve = false
setting = AnnouncementSetting.first
setting = CurationSetting.first
case @access_level
when "admin"
can_approve = true

View File

@ -10,12 +10,12 @@ module CurationsHelper
"status-class" => "status-#{status['classname']}"
}
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)
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 ""
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 ""
target = a.is_external_link ? "_blank" : "_self"
if @image_version == 'thumb'
@ -44,12 +44,12 @@ module CurationsHelper
"author" => author,
"link_to_show" => link_to_show+"\" #{(link_to_show[0] == '/' rescue true) ? '' : 'target="_blank"'} title=\"#{title}",
"target" => target,
"img_src" => image_url || AnnouncementsController::DefaultImgSrc,
"img_src" => image_url || CurationsController::DefaultImgSrc,
"img_description" => desc
}
end
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 type == "index"
categories = Array(OrbitHelper.page_categories)
@ -140,7 +140,7 @@ module CurationsHelper
}
end
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)
.where(:title.nin => ["",nil])
if !extra_match_cond.empty?
@ -243,9 +243,9 @@ module CurationsHelper
if @target_action == "index"
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
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
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
@ -253,11 +253,11 @@ module CurationsHelper
file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
controller = AnnouncementsController.new
controller = CurationsController.new
begin
data = @data# rescue nil
rescue Exception => e
write_debug_file(e,'announcements',@target_action) if Site::DEBUG
write_debug_file(e,'curations',@target_action) if Site::DEBUG
end
if !data.nil?
wrap_elements = doc.css("*[data-list][data-level='0']")
@ -285,16 +285,16 @@ module CurationsHelper
end
else
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
file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
controller = AnnouncementsController.new
controller = CurationsController.new
begin
data = @data# rescue nil
rescue Exception => e
write_debug_file(e,'announcements',@target_action) if Site::DEBUG
write_debug_file(e,'curations',@target_action) if Site::DEBUG
end
if data.nil?
return "<div class='well'> No content to show. </div>".html_safe
@ -310,7 +310,7 @@ module CurationsHelper
Thread.new do
impression = data['impressionist'].impressions.create
impression.user_id = request.session['user_id']
impression.controller_name = 'announcements'
impression.controller_name = 'curationsements'
impression.action_name = @target_action
impression.ip_address = request.remote_ip
impression.session_hash = request.session.id
@ -487,9 +487,9 @@ module CurationsHelper
def enable_manually_sort
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['announcement'][:enable_manually_sort]
OrbitHelper::SharedHash['curation'][:enable_manually_sort]
else
AnnouncementSetting.first.enable_manually_sort rescue false
CurationSetting.first.enable_manually_sort rescue false
end
end
end

View File

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