Merge branch 'develop' of 10.0.47.245:/home/trustie2 into develop

This commit is contained in:
Wen 2014-04-16 08:37:25 +08:00
commit f1bbee7e35
3 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,8 @@
source 'https://rubygems.org'
gem 'rubyzip'
gem 'zip-zip'
gem 'iconv'
gem "rails", "3.2.13"
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"

View File

@ -15,6 +15,8 @@ class TestController < ApplicationController
zipfile = ziping homeworks_attach_path
send_file zipfile, :filename => bid.name,
:type => detect_content_type(zipfile)
rescue Errno::ENOENT => e
logger.error "[Errno::ENOENT] ===> #{e}"
end
@ -23,14 +25,15 @@ class TestController < ApplicationController
end
def ziping files_path
ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE')
folder = "#{Rails.root}/files"
input_filename = files_path
zipfile_name = "#{Rails.root}/tmp/archiveZip/archive_#{Time.now.to_i}.zip"
Rails.logger.info "================================================================================================================================================================================================================================================================================================================================================================================================#{zipfile_name}"
Dir.mkdir(File.dirname(zipfile_name)) if File.exist?(File.dirname(zipfile_name))
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
input_filename.each do |filename|
zipfile.add(File.basename(filename), folder + '/' + filename)
zipfile.add(ic.iconv(filename_to_real(File.basename(filename))), folder + '/' + filename)
end
zipfile.get_output_stream("ReadMe"){ |os|
os.write "Homeworks"
@ -43,4 +46,11 @@ class TestController < ApplicationController
content_type = Redmine::MimeType.of(name)
content_type.to_s
end
def filename_to_real name
attach = Attachment.find_by_disk_filename(name)
attach.filename
end
end

View File

@ -456,6 +456,7 @@ ul.projects li.root
width:auto;
float:center;
min-height:800px;
border: 1px solid #ffffff;
}
/*by huang*/