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'
|
2021-03-23 09:50:53 +00:00
|
|
|
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))
|
2021-09-22 04:27:02 +00:00
|
|
|
check_files = ["archive_index7.html.erb","archive_index8.html.erb","archive_index9.html.erb"]
|
|
|
|
old_file_infos = [
|
2021-03-23 09:50:53 +00:00
|
|
|
{
|
2021-03-23 09:52:43 +00:00
|
|
|
"filename" => "archive_index7",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "7. 表格列表 ( 模組標題, 類別標題, 檔案名稱, 檔案簡介, 下載連結 )",
|
|
|
|
"en" => "7. Table list (widget-title, category, filename, download link)"
|
2021-03-23 09:50:53 +00:00
|
|
|
},
|
2021-03-23 09:52:43 +00:00
|
|
|
"thumbnail" => "ar5.png"
|
2021-03-23 09:50:53 +00:00
|
|
|
},
|
|
|
|
{
|
2021-03-23 09:52:43 +00:00
|
|
|
"filename" => "archive_index8",
|
|
|
|
"name" => {
|
|
|
|
"zh_tw" => "8. 表格列表 ( 模組標題, 檔案名稱, 檔案簡介, 下載連結 )",
|
|
|
|
"en" => "8. Table list (widget-title, filename, download link)"
|
2021-03-23 09:50:53 +00:00
|
|
|
},
|
2021-03-23 09:52:43 +00:00
|
|
|
"thumbnail" => "ar5.png"
|
2021-03-23 09:50:53 +00:00
|
|
|
}
|
|
|
|
]
|
2021-09-22 04:27:02 +00:00
|
|
|
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)"
|
|
|
|
},
|
2021-09-29 14:06:59 +00:00
|
|
|
"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)"
|
|
|
|
},
|
2021-09-22 04:27:02 +00:00
|
|
|
"thumbnail" => "ar9.png"
|
|
|
|
}
|
|
|
|
]
|
2021-03-23 09:50:53 +00:00
|
|
|
flags = []
|
2021-09-22 04:27:02 +00:00
|
|
|
all_frontend_names = info_json["frontend"].map{|h| h["name"]}
|
2021-03-23 09:50:53 +00:00
|
|
|
check_files.each_with_index do |check_file,i|
|
2021-03-23 10:09:39 +00:00
|
|
|
flag = (info_json["frontend"].select{|h| h["filename"] == check_file.split(".").first}.count == 0 rescue false)
|
2021-03-23 09:50:53 +00:00
|
|
|
if flag
|
2021-09-22 04:27:02 +00:00
|
|
|
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
|
|
|
|
end
|
2021-03-23 09:50:53 +00:00
|
|
|
end
|
|
|
|
flags << flag
|
|
|
|
end
|
|
|
|
if flags.select{|flag| flag }.count != 0
|
|
|
|
puts "updating archive index page"
|
|
|
|
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
|
|
|
|
end
|
2021-09-22 04:27:02 +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
|
2021-09-22 04:27:02 +00:00
|
|
|
Bundler.with_clean_env{%x[cp -rn #{app_path}/modules/archive/thumbs/* #{folder}modules/archive/thumbs/.]}
|
2021-03-23 09:50:53 +00:00
|
|
|
rescue
|
|
|
|
puts "There has some error when updating archive index page."
|
|
|
|
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
|