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-03-23 10:09:39 +00:00
|
|
|
check_files = ["archive_index7.html.erb","archive_index8.html.erb"]
|
2021-03-23 09:50:53 +00:00
|
|
|
file_infos = [
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
]
|
|
|
|
flags = []
|
|
|
|
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
|
|
|
|
info_json["frontend"].push(file_infos[i])
|
|
|
|
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
|
|
|
|
File.open(info_json_file,"w+"){|f| f.write(info_json.to_json)}
|
|
|
|
end
|
|
|
|
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
|