Compare commits
2 Commits
081ffbca24
...
a55848b554
Author | SHA1 | Date |
---|---|---|
邱博亞 | a55848b554 | |
邱博亞 | dfdefa3032 |
|
@ -468,7 +468,7 @@ class Admin::EventNewsController < OrbitAdminController
|
|||
content = "UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s USR2 $UNICORN_PID ; n=20; while (kill -0 $UNICORN_PID > /dev/null 2>&1) && test $n -ge 0; do printf '.' && sleep 1 && n=$(( $n - 1 )); done ; if test $n -lt 0; then kill -s TERM $UNICORN_PID; sleep 3; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{Rails.env}; else kill -s QUIT $UNICORN_PID; fi"
|
||||
system(content)
|
||||
end
|
||||
redirect_to action: :index
|
||||
redirect_to admin_event_news_index_path
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -42,6 +42,8 @@ class EventNewsModsController < ApplicationController
|
|||
"statuses" => statuses,
|
||||
"category" => (a.category.title rescue ""),
|
||||
"postdate" => event_time,
|
||||
"event_start_date" => a.event_date_frontend,
|
||||
"event_end_date" => a.event_end_date_frontend,
|
||||
"event-time-formated" => event_time_formated,
|
||||
"event-time-css" => (event_time_formated.blank? ? "display: none;" : ""),
|
||||
"author" => author,
|
||||
|
@ -69,6 +71,7 @@ class EventNewsModsController < ApplicationController
|
|||
"event_news" => event_news,
|
||||
"extras" => {
|
||||
"widget-title" =>t('event_news.event_news'),
|
||||
"category-head" => EventNewsCustomTitle.get_trans('category'),
|
||||
"title-head" => EventNewsCustomTitle.get_trans('title'),
|
||||
"speaker-head" => EventNewsCustomTitle.get_trans('speaker'),
|
||||
"place-head" => EventNewsCustomTitle.get_trans('place'),
|
||||
|
@ -76,10 +79,11 @@ class EventNewsModsController < ApplicationController
|
|||
"notes-head" => EventNewsCustomTitle.get_trans('notes'),
|
||||
"event_date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
||||
"date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
||||
"event_start_date-head" => EventNewsCustomTitle.get_trans('start_date'),
|
||||
"event_end_date-head" => EventNewsCustomTitle.get_trans('end_date'),
|
||||
"status-head" => t('event_news.table.status'),
|
||||
"author-head" => t('event_news.table.author'),
|
||||
"subtitle-head" => t('event_news.table.sub_title'),
|
||||
"category-head" => t('event_news.table.category'),
|
||||
"link-head" => t('event_news.table.link'),
|
||||
"file-head" => t('event_news.table.file'),
|
||||
"view-count-head" => t('event_news.table.view_count'),
|
||||
|
@ -376,6 +380,7 @@ class EventNewsModsController < ApplicationController
|
|||
"more_url"=>OrbitHelper.widget_more_url,
|
||||
"main_picture" => mp,
|
||||
"main_picture_description" => mpd,
|
||||
"category-head" => EventNewsCustomTitle.get_trans('category'),
|
||||
"title-head" => EventNewsCustomTitle.get_trans('title'),
|
||||
"speaker-head" => EventNewsCustomTitle.get_trans('speaker'),
|
||||
"place-head" => EventNewsCustomTitle.get_trans('place'),
|
||||
|
@ -383,10 +388,11 @@ class EventNewsModsController < ApplicationController
|
|||
"notes-head" => EventNewsCustomTitle.get_trans('notes'),
|
||||
"event_date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
||||
"date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
||||
"event_start_date-head" => EventNewsCustomTitle.get_trans('start_date'),
|
||||
"event_end_date-head" => EventNewsCustomTitle.get_trans('end_date'),
|
||||
"author-head" => t('event_news.table.author'),
|
||||
"status-head" => t('event_news.table.status'),
|
||||
"subtitle-head" => t('event_news.table.sub_title'),
|
||||
"category-head" => t('event_news.table.category'),
|
||||
"link-head" => t('event_news.table.link'),
|
||||
"file-head" => t('event_news.table.file'),
|
||||
"read_more" => read_more_url,
|
||||
|
@ -836,6 +842,8 @@ class EventNewsModsController < ApplicationController
|
|||
"statuses" => statuses,
|
||||
"category" => (a.category.title rescue ""),
|
||||
"postdate" => event_time,
|
||||
"event_start_date" => a.event_date_frontend,
|
||||
"event_end_date" => a.event_end_date_frontend,
|
||||
"author" => author,
|
||||
"is_top" => (a.is_top? ? 1 : 0),
|
||||
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
|
||||
|
@ -861,6 +869,7 @@ class EventNewsModsController < ApplicationController
|
|||
"event_news" => event_news,
|
||||
"extras" => {
|
||||
"widget-title" =>t('event_news.event_news'),
|
||||
"category-head" => EventNewsCustomTitle.get_trans('category'),
|
||||
"title-head" => EventNewsCustomTitle.get_trans('title'),
|
||||
"speaker-head" => EventNewsCustomTitle.get_trans('speaker'),
|
||||
"place-head" => EventNewsCustomTitle.get_trans('place'),
|
||||
|
@ -868,10 +877,11 @@ class EventNewsModsController < ApplicationController
|
|||
"notes-head" => EventNewsCustomTitle.get_trans('notes'),
|
||||
"event_date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
||||
"date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
||||
"event_start_date-head" => EventNewsCustomTitle.get_trans('start_date'),
|
||||
"event_end_date-head" => EventNewsCustomTitle.get_trans('end_date'),
|
||||
"status-head" => t('event_news.table.status'),
|
||||
"author-head" => t('event_news.table.author'),
|
||||
"subtitle-head" => t('event_news.table.sub_title'),
|
||||
"category-head" => t('event_news.table.category'),
|
||||
"link-head" => t('event_news.table.link'),
|
||||
"file-head" => t('event_news.table.file'),
|
||||
"view-count-head" => t('event_news.table.view_count'),
|
||||
|
|
|
@ -65,6 +65,8 @@ module EventNewsHelper
|
|||
"category" => (a.category.title rescue ""),
|
||||
"tag_ids" => (set_tag_ids.nil? ? (a.tag_ids.map{|id| id.to_s}.to_s.gsub('"',"'") rescue '[]') : set_tag_ids),
|
||||
"postdate" => event_time_formated,
|
||||
"event_start_date" => a.event_date_frontend,
|
||||
"event_end_date" => a.event_end_date_frontend,
|
||||
"event_date" => event_time_formated,
|
||||
"author" => author,
|
||||
"link_to_show" => link_to_show,
|
||||
|
|
|
@ -161,6 +161,24 @@ class EventNews
|
|||
"#{st} ~ #{ed}"
|
||||
end
|
||||
end
|
||||
def event_date_frontend
|
||||
s = self.event_date.in_time_zone(Time.zone.utc_offset / 3600) rescue nil
|
||||
if s.blank?
|
||||
""
|
||||
else
|
||||
parse_format = self.date_parse_format
|
||||
custom_strftime(s, self.date_parse_format)
|
||||
end
|
||||
end
|
||||
def event_end_date_frontend
|
||||
e = self.event_end_date.in_time_zone(Time.zone.utc_offset / 3600) rescue nil
|
||||
if e.blank?
|
||||
""
|
||||
else
|
||||
parse_format = self.date_parse_format
|
||||
custom_strftime(e, self.date_parse_format)
|
||||
end
|
||||
end
|
||||
def event_time_formated
|
||||
s = self.event_date.in_time_zone(Time.zone.utc_offset / 3600) rescue nil
|
||||
e = self.event_end_date.in_time_zone(Time.zone.utc_offset / 3600) rescue nil
|
||||
|
|
|
@ -3,7 +3,7 @@ class EventNewsCustomTitle
|
|||
include Mongoid::Timestamps
|
||||
field :key
|
||||
field :title, type: String, localize: true
|
||||
KEYS = ['title','speaker','host','event_date','place','notes']
|
||||
KEYS = ['category', 'title','speaker','host','event_date','place','notes']
|
||||
def self.get_map
|
||||
KEYS.map do |k|
|
||||
s = self.where(key: k).first || self.create(key: k,title_translations: I18n.available_locales.map{|l| [l,I18n.with_locale(l){I18n.t("event_news.#{k}")}]}.to_h)
|
||||
|
|
|
@ -4,6 +4,7 @@ en:
|
|||
event_news_mod:
|
||||
event_news_mod: Event News
|
||||
event_news:
|
||||
category: Category
|
||||
event_date_setting: "Event date setting"
|
||||
event_date_use_default_setting: "Event date use default setting"
|
||||
including_day_of_the_week: "Including day of the week"
|
||||
|
@ -37,6 +38,8 @@ en:
|
|||
notes: Notes
|
||||
speaker: Speaker
|
||||
host: Host
|
||||
unit: Unit
|
||||
employer: Employer
|
||||
event_date: Event Date
|
||||
event_end_date: Event End Date
|
||||
start_date: Start date
|
||||
|
|
|
@ -4,6 +4,7 @@ zh_tw:
|
|||
event_news_mod:
|
||||
event_news_mod: 活動公告
|
||||
event_news:
|
||||
category: 類別
|
||||
event_date_setting: "事件日期設定"
|
||||
event_date_use_default_setting: "使用預設的事件日期設定"
|
||||
including_day_of_the_week: "包含星期幾"
|
||||
|
@ -37,10 +38,12 @@ zh_tw:
|
|||
notes: 備註
|
||||
speaker: 演講者
|
||||
host: 主持人
|
||||
unit: 公告單位
|
||||
employer: 徵求單位
|
||||
event_date: 事件日期
|
||||
event_end_date: 事件結束日期
|
||||
start_date: 公告日期
|
||||
end_date: 下架日期
|
||||
end_date: 截止日期
|
||||
add_to_calendar: 加入行事曆
|
||||
blank_to_set: (留白則使用公告設定)
|
||||
stime: 開始時間
|
||||
|
|
|
@ -3,6 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|||
|
||||
# Maintain your gem's version:
|
||||
require "event_news_mod/version"
|
||||
require "json"
|
||||
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
||||
if bundle_update_flag
|
||||
require File.expand_path("../update_event_news", __FILE__)
|
||||
|
@ -24,7 +25,9 @@ if bundle_update_flag
|
|||
app_path = File.expand_path(__dir__)
|
||||
template_path = env_pwd + '/app/templates'
|
||||
all_template = Dir.glob(template_path+'/*/')
|
||||
default_event_news_widget_info = JSON.parse(File.read("#{app_path}/modules/event_news_mod/info.json"))["widgets"].sort_by{|h| h["filename"].to_i} rescue []
|
||||
default_info_contents = JSON.parse(File.read("#{app_path}/modules/event_news_mod/info.json")) rescue {}
|
||||
default_event_news_index_info = default_info_contents["frontend"].sort_by{|h| h["filename"].to_f} rescue []
|
||||
default_event_news_widget_info = default_info_contents["widgets"].sort_by{|h| h["filename"].to_f} rescue []
|
||||
all_template.each do |folder|
|
||||
if !folder.include?('mobile')
|
||||
if Dir.exist?("#{folder}modules/event_news")
|
||||
|
@ -44,6 +47,41 @@ if bundle_update_flag
|
|||
info = JSON.parse(encode_file_text) rescue {}
|
||||
flag = (info.count != 0 rescue false)
|
||||
if flag
|
||||
puts "Checking event_news index"
|
||||
index_info = info["frontend"].sort_by{|h| h["filename"].to_i} rescue []
|
||||
update_flag = false
|
||||
last_index = index_info.collect{|v| v["filename"].to_s.scan(/\d+/).collect{|v1| v1.to_i}}.flatten.sort[-1] rescue nil
|
||||
if !last_index.nil?
|
||||
idx_regex = /^(\d+[\. \t]*)|[ \t]+$/
|
||||
default_event_news_index_info.each do |h|
|
||||
name_without_index = h["name"]["zh_tw"].gsub(idx_regex,'')
|
||||
index_info_index = (index_info.index{|hh| hh["name"]["zh_tw"].gsub(idx_regex,'') == name_without_index}||-1 rescue -1)
|
||||
if index_info_index == -1
|
||||
update_flag = true
|
||||
copy_h = h.dup
|
||||
h.delete("force_cover")
|
||||
last_index = last_index + 1
|
||||
copy_h["filename"] = copy_h["filename"].sub(/\d+/){|ff| last_index.to_s}
|
||||
copy_h["name"].keys.each do |locale|
|
||||
copy_h["name"][locale] = copy_h["name"][locale].sub(/\d+/){|ff| last_index.to_s}
|
||||
end
|
||||
index_info << copy_h
|
||||
bundler_with_clean_env{%x[cp -f #{app_path}/modules/event_news_mod/#{h["filename"]}.html.erb #{folder}modules/event_news_mod/#{copy_h["filename"]}.html.erb]}
|
||||
elsif h["force_cover"] == "true"
|
||||
bundler_with_clean_env{%x[cp -f #{app_path}/modules/event_news_mod/#{h["filename"]}.html.erb #{folder}modules/event_news_mod/#{index_info[index_info_index]["filename"]}.html.erb]}
|
||||
end
|
||||
end
|
||||
if update_flag
|
||||
info["frontend"] = index_info
|
||||
puts "Writing json #{info["frontend"].count} in #{info_json_file}"
|
||||
begin
|
||||
info_json = JSON.pretty_generate(info).gsub(":[",":[\n").gsub(":{",":{\n")
|
||||
rescue
|
||||
info_json = info.to_s.gsub("=>",": \n")
|
||||
end
|
||||
File.open(info_json_file,"w+"){|f| f.write(info_json)}
|
||||
end
|
||||
end
|
||||
puts "Checking event_news widgets"
|
||||
widget_info = info["widgets"].sort_by{|h| h["filename"].to_i} rescue []
|
||||
update_flag = false
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<div class="i-annc index-announcement-12s w-annc widget-announcement-19">
|
||||
<h3 class="w-annc__widget-title">
|
||||
<span>{{widget-title}}</span>
|
||||
</h3>
|
||||
<table class="i-annc__table table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="i-annc__th i-annc__th--category">{{category-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--speaker">{{speaker-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--event_start_date">{{event_start_date-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--title">{{title-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--event_end_date">{{event_end_date-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--view-count">{{view-count-head}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-level="0" data-list="event_news">
|
||||
<tr>
|
||||
<td class="i-annc__category">{{category}}</td>
|
||||
<td class="i-annc__speaker">{{speaker}}</td>
|
||||
<td class="i-annc__event_start_date"><span class="i-annc__event_start_date-content" date-format="%Y-%m-%d">{{event_start_date}}</span></td>
|
||||
<td class="i-annc__content">
|
||||
<span class="i-annc__status-wrap" data-list="statuses" data-level="1">
|
||||
<span class="i-annc__status label status {{status-class}}">{{status}}</span>
|
||||
</span>
|
||||
<a class="i-annc__title" href="{{link_to_show}}">{{title}}</a>
|
||||
</td>
|
||||
<td class="i-annc__event_end_date"><span class="i-annc__event_end_date-content" date-format="%Y-%m-%d">{{event_end_date}}</span></td>
|
||||
<td class="i-annc__view-count">{{view_count}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{pagination_goes_here}}
|
|
@ -0,0 +1,29 @@
|
|||
<div class="i-annc index-announcement-12s index-announcement-19 {{display}}">
|
||||
<h1 class="i-annc__page-title">{{page-title}}</h1>
|
||||
<table class="i-annc__table table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="i-annc__th i-annc__th--category">{{category-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--event_date">{{event_date-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--speaker">{{speaker-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--title">{{title-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--view-count">{{view-count-head}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-level="0" data-list="event_news">
|
||||
<tr>
|
||||
<td class="i-annc__category">{{category}}</td>
|
||||
<td class="i-annc__postdate"><span class="i-annc__postdate-content" date-format="%Y-%m-%d">{{postdate}}</span></td>
|
||||
<td class="i-annc__speaker">{{speaker}}</td>
|
||||
<td class="i-annc__content">
|
||||
<span class="i-annc__status-wrap" data-list="statuses" data-level="1">
|
||||
<span class="i-annc__status label status {{status-class}}">{{status}}</span>
|
||||
</span>
|
||||
<a class="i-annc__title" href="{{link_to_show}}">{{title}}</a>
|
||||
</td>
|
||||
<td class="i-annc__view-count">{{view_count}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{pagination_goes_here}}
|
|
@ -0,0 +1,31 @@
|
|||
<div class="i-annc index-announcement-12s index-announcement-20 {{display}}">
|
||||
<h1 class="i-annc__page-title">{{page-title}}</h1>
|
||||
<table class="i-annc__table table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="i-annc__th i-annc__th--category">{{category-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--speaker">{{speaker-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--event_start_date">{{event_start_date-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--title">{{title-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--event_end_date">{{event_end_date-head}}</th>
|
||||
<th class="i-annc__th i-annc__th--view-count">{{view-count-head}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-level="0" data-list="event_news">
|
||||
<tr>
|
||||
<td class="i-annc__category">{{category}}</td>
|
||||
<td class="i-annc__speaker">{{speaker}}</td>
|
||||
<td class="i-annc__event_start_date"><span class="i-annc__event_start_date-content" date-format="%Y-%m-%d">{{event_start_date}}</span></td>
|
||||
<td class="i-annc__content">
|
||||
<span class="i-annc__status-wrap" data-list="statuses" data-level="1">
|
||||
<span class="i-annc__status label status {{status-class}}">{{status}}</span>
|
||||
</span>
|
||||
<a class="i-annc__title" href="{{link_to_show}}">{{title}}</a>
|
||||
</td>
|
||||
<td class="i-annc__event_end_date"><span class="i-annc__event_end_date-content" date-format="%Y-%m-%d">{{event_end_date}}</span></td>
|
||||
<td class="i-annc__view-count">{{view_count}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{pagination_goes_here}}
|
|
@ -143,6 +143,22 @@
|
|||
"en" : "18. Standard Title List-2 ( EventDate, speaker, status, title, host, notes)"
|
||||
},
|
||||
"thumbnail" : "event_news_index1_thumbs.png"
|
||||
},
|
||||
{
|
||||
"filename" : "event_news_index19",
|
||||
"name" : {
|
||||
"zh_tw" : "19. 標準標題列表-3 ( 類別, 日期, 演講者, 狀態, 標題, 瀏覽人次 )",
|
||||
"en" : "19. Standard Title List-3 ( category, EventDate, speaker, status, title, view-count)"
|
||||
},
|
||||
"thumbnail" : "event_news_index1_thumbs.png"
|
||||
},
|
||||
{
|
||||
"filename" : "event_news_index20",
|
||||
"name" : {
|
||||
"zh_tw" : "20. 標準標題列表-4 ( 類別, 演講者, 事件日期, 狀態, 標題, 截止日期, 瀏覽人次 )",
|
||||
"en" : "20. Standard Title List-4 ( category, EventDate, speaker, EventDate, status, title, EndDate, view-count)"
|
||||
},
|
||||
"thumbnail" : "event_news_index1_thumbs.png"
|
||||
}
|
||||
],
|
||||
"widgets" : [
|
||||
|
@ -292,6 +308,14 @@
|
|||
},
|
||||
"force_cover" : "true",
|
||||
"thumbnail" : "event_news_widget13_thumbs.png"
|
||||
},
|
||||
{
|
||||
"filename" : "event_news_widget19",
|
||||
"name" : {
|
||||
"zh_tw" : "19. 標準標題列表-3 ( 類別, 演講者, 事件日期, 狀態, 標題, 截止日期, 瀏覽人次 )",
|
||||
"en" : "19. Standard Title List-3 ( category, EventDate, speaker, EventDate, status, title, EndDate, view-count)"
|
||||
},
|
||||
"thumbnail" : "event_news_widget7_thumbs.png"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -47,7 +47,7 @@ def add_css_style_for_block(c,head_key,value_key,css_key)
|
|||
[flag,c_tp]
|
||||
end
|
||||
def update_event_news_template(folder)
|
||||
Dir["#{folder}modules/event_news/*.html.erb"].each do |f|
|
||||
Dir["#{folder}modules/event_news_mod/*.html.erb"].each do |f|
|
||||
c = File.open(f,'r'){|f1| f1.read}.encode("UTF-8", "UTF-8", invalid: :replace, replace: "???")
|
||||
next if (c.include?("???") rescue true)
|
||||
flag1,c = add_css_style_for_block(c,'speaker-head','speaker','speaker-css')
|
||||
|
|
Loading…
Reference in New Issue