2014-05-08 06:03:33 +00:00
|
|
|
$:.push File.expand_path("../lib", __FILE__)
|
|
|
|
|
|
|
|
# Maintain your gem's version:
|
|
|
|
require "archive/version"
|
2021-03-23 10:09:39 +00:00
|
|
|
require 'json'
|
2022-04-08 03:20:21 +00:00
|
|
|
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
|
|
|
if bundle_update_flag
|
|
|
|
env_pwd = ENV['PWD']
|
|
|
|
app_path = File.expand_path(__dir__)
|
|
|
|
template_path = env_pwd + '/app/templates'
|
|
|
|
all_template = Dir.glob(template_path+'/*/')
|
|
|
|
all_template.each do |folder|
|
|
|
|
if !folder.include?('mobile')
|
|
|
|
begin
|
|
|
|
next unless File.exist?("#{folder}modules/archive/info.json")
|
|
|
|
info_json_file = "#{folder}modules/archive/info.json"
|
|
|
|
info_json = JSON.parse(File.read(info_json_file))
|
2022-05-22 11:07:23 +00:00
|
|
|
check_files = ["archive_index7.html.erb","archive_index8.html.erb","archive_index9.html.erb","archive_index10.html.erb","archive_index11.html.erb","archive_index12.html.erb","archive_index13.html.erb"]
|
2022-04-08 03:20:21 +00:00
|
|
|
old_file_infos = [
|
|
|
|
{
|
|
|
|
"filename" => "archive_index7",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "7. 表格列表 ( 模組標題, 類別標題, 檔案名稱, 檔案簡介, 下載連結 )",
|
|
|
|
"en" => "7. Table list (widget-title, category, filename, download link)"
|
|
|
|
},
|
|
|
|
"thumbnail" => "ar5.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"filename" => "archive_index8",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "8. 表格列表 ( 模組標題, 檔案名稱, 檔案簡介, 下載連結 )",
|
|
|
|
"en" => "8. Table list (widget-title, filename, download link)"
|
|
|
|
},
|
|
|
|
"thumbnail" => "ar5.png"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
new_file_infos = [
|
|
|
|
{
|
|
|
|
"filename" => "archive_index7",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "7. 表格列表 ( 模組標題, 類別標題, 上傳日期, 檔案名稱, 檔案簡介, 下載連結 )",
|
|
|
|
"en" => "7. Table list (widget-title, category, Updated At, filename, download link)"
|
|
|
|
},
|
|
|
|
"thumbnail" => "ar5.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"filename" => "archive_index8",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "8. 表格列表 ( 模組標題, 上傳日期, 檔案名稱, 檔案簡介, 下載連結 )",
|
|
|
|
"en" => "8. Table list (widget-title, Updated At, filename, download link)"
|
|
|
|
},
|
|
|
|
"thumbnail" => "ar5.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"filename" => "archive_index9",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "9. 表格列表 - 簡約 ( 模組標題, 檔案名稱, 下載連結 )",
|
|
|
|
"en" => "9. Table list - Simple (widget-title, download link)"
|
|
|
|
},
|
|
|
|
"thumbnail" => "ar9.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"filename" => "archive_index10",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "10. 表格列表 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
|
|
|
|
"en" => "10. Table list (widget-title, category, Serial Number, filename, download link)"
|
|
|
|
},
|
|
|
|
"thumbnail" => "ar5.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"filename" => "archive_index11",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "11. 表格列表 - 簡約 - 展開檔案 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
|
|
|
|
"en" => "11. Table list - Simple - Unfold Files (widget-title, category, Serial Number, filename, download link)"
|
|
|
|
},
|
|
|
|
"thumbnail" => "ar9.png"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"filename" => "archive_index12",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "12. 手風琴式列表 - 有下拉 ( 模組標題, 類別標題, 檔案名稱, 下載連結 )",
|
|
|
|
"en" => "12. Accordion list - with drop down (widget-title, category, filename, download link)"
|
|
|
|
},
|
|
|
|
"thumbnail" => "ar2.png"
|
2022-05-22 10:32:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"filename" => "archive_index13",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "13. 頁籤式 ( 模組標題, 類別標題, 標題, 檔案名稱, 下載連結, 描述 )",
|
|
|
|
"en" => "13. Tab list (widget-title, category, title, filename, download link, description)"
|
|
|
|
},
|
|
|
|
"thumbnail" => "ar-tab1.png"
|
2022-04-08 03:20:21 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
flags = []
|
|
|
|
all_frontend_names = info_json["frontend"].map{|h| h["name"]}
|
|
|
|
check_files.each_with_index do |check_file,i|
|
|
|
|
flag = (info_json["frontend"].select{|h| h["filename"] == check_file.split(".").first}.count == 0 rescue false)
|
|
|
|
if flag
|
|
|
|
info_json["frontend"].push(new_file_infos[i])
|
|
|
|
end
|
|
|
|
if !flag
|
|
|
|
old_file_info = old_file_infos[i]
|
|
|
|
if old_file_info
|
|
|
|
idx = all_frontend_names.index(old_file_info["name"])
|
|
|
|
if idx && idx != -1
|
|
|
|
info_json["frontend"][idx] = new_file_infos[i]
|
|
|
|
flag = true
|
|
|
|
end
|
2021-09-22 04:27:02 +00:00
|
|
|
end
|
|
|
|
end
|
2022-04-08 03:20:21 +00:00
|
|
|
flags << flag
|
2021-03-23 09:50:53 +00:00
|
|
|
end
|
2022-05-22 10:32:22 +00:00
|
|
|
force_update_files = ["archive_index1.html.erb","archive_index3.html.erb","archive_index12.html.erb","archive_index13.html.erb"]
|
2022-04-08 03:20:21 +00:00
|
|
|
puts "updating archive index page"
|
|
|
|
if flags.select{|flag| flag }.count != 0
|
|
|
|
flags.each_with_index do |flag,i|
|
|
|
|
if flag
|
|
|
|
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{check_files[i]} #{folder}modules/archive/#{check_files[i]}]}
|
|
|
|
end
|
2021-03-23 09:50:53 +00:00
|
|
|
end
|
2022-04-08 03:20:21 +00:00
|
|
|
begin
|
|
|
|
info_json = JSON.pretty_generate(info_json).gsub(":[",":[\n").gsub(":{",":{\n")
|
|
|
|
rescue
|
|
|
|
info_json = info_json.to_s.gsub("=>",": \n")
|
|
|
|
end
|
|
|
|
File.open(info_json_file,"w+"){|f| f.write(info_json)}
|
2021-03-23 09:50:53 +00:00
|
|
|
end
|
2022-04-08 03:20:21 +00:00
|
|
|
force_update_files.each do |update_file|
|
|
|
|
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{update_file} #{folder}modules/archive/#{update_file}]}
|
2021-09-22 04:27:02 +00:00
|
|
|
end
|
2022-04-08 03:20:21 +00:00
|
|
|
Bundler.with_clean_env{%x[cp -rn #{app_path}/modules/archive/thumbs/* #{folder}modules/archive/thumbs/.]}
|
|
|
|
rescue
|
|
|
|
puts "There has some error when updating archive index page."
|
2021-10-20 03:28:18 +00:00
|
|
|
end
|
2021-03-23 09:50:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-05-08 06:03:33 +00:00
|
|
|
# Describe your gem and declare its dependencies:
|
|
|
|
Gem::Specification.new do |s|
|
|
|
|
s.name = "archive"
|
|
|
|
s.version = Archive::VERSION
|
|
|
|
s.authors = ["Ruling Digital"]
|
|
|
|
s.email = ["orbit@rulingcom.com"]
|
|
|
|
s.homepage = "http://www.rulingcom.com"
|
|
|
|
s.summary = "Archive module for Orbit."
|
|
|
|
s.description = "Archive module for Orbit"
|
|
|
|
s.license = "MIT"
|
|
|
|
|
|
|
|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
|
|
|
s.test_files = Dir["test/**/*"]
|
|
|
|
end
|