* finished Issue 65: download via Zip with national alphabet in filename

git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@119 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
vit.jonas@gmail.com 2011-06-02 08:41:23 +00:00
parent d0a89f7001
commit 9064f0ea9e
12 changed files with 41 additions and 2 deletions

View File

@ -66,7 +66,7 @@ class DmsfController < ApplicationController
if selected_folders.nil? && selected_files.nil? if selected_folders.nil? && selected_files.nil?
flash[:warning] = l(:warning_no_entries_selected) flash[:warning] = l(:warning_no_entries_selected)
redirect_to :action => "index", :id => @project, :folder_id => @folder redirect_to :action => "show", :id => @project, :folder_id => @folder
return return
end end

View File

@ -18,6 +18,7 @@
require 'zip/zip' require 'zip/zip'
require 'zip/zipfilesystem' require 'zip/zipfilesystem'
require 'iconv'
class DmsfZip class DmsfZip
@ -42,6 +43,11 @@ class DmsfZip
def add_file(file) def add_file(file)
string_path = file.folder.nil? ? "" : file.folder.dmsf_path_str + "/" string_path = file.folder.nil? ? "" : file.folder.dmsf_path_str + "/"
string_path += file.name string_path += file.name
#TODO: somewhat ugly conversion problems handling bellow
begin
string_path = Iconv.conv(Setting.plugin_redmine_dmsf["dmsf_zip_encoding"], "utf-8", string_path)
rescue
end
@zip_file.put_next_entry(string_path) @zip_file.put_next_entry(string_path)
File.open(file.last_revision.disk_file, "rb") do |f| File.open(file.last_revision.disk_file, "rb") do |f|
buffer = "" buffer = ""
@ -53,7 +59,13 @@ class DmsfZip
end end
def add_folder(folder) def add_folder(folder)
@zip_file.put_next_entry(folder.dmsf_path_str + "/") string_path = folder.dmsf_path_str + "/"
#TODO: somewhat ugly conversion problems handling bellow
begin
string_path = Iconv.conv(Setting.plugin_redmine_dmsf["dmsf_zip_encoding"], "utf-8", string_path)
rescue
end
@zip_file.put_next_entry(string_path)
folder.subfolders.each { |subfolder| self.add_folder(subfolder) } folder.subfolders.each { |subfolder| self.add_folder(subfolder) }
folder.files.each { |file| self.add_file(file) } folder.files.each { |file| self.add_file(file) }
end end

View File

@ -29,6 +29,15 @@
:selected => @settings["dmsf_default_notifications"])) %><br/> :selected => @settings["dmsf_default_notifications"])) %><br/>
(<%=l(:label_default)%>: <%=l(:select_option_deactivated)%>) (<%=l(:label_default)%>: <%=l(:select_option_deactivated)%>)
</p> </p>
<p>
<%=content_tag(:label, l(:label_zip_names_encoding) + ":") %>
<%=text_field_tag "settings[dmsf_zip_encoding]", @settings["dmsf_zip_encoding"], :size=>50 %><br/>
(<%=l(:label_default)%>: utf-8)
<br/>
<%= l(:note_zip_names_encoding_iconv) %>
</p>
<hr /> <hr />
<p> <p>
<%=content_tag(:label, l(:label_index_database) + ":") %> <%=content_tag(:label, l(:label_index_database) + ":") %>

View File

@ -151,4 +151,6 @@ cs:
:title_filename_for_download: "Filename used for download or in Zip archive" :title_filename_for_download: "Filename used for download or in Zip archive"
:label_number_of_folders: "Folders" :label_number_of_folders: "Folders"
:label_number_of_documents: "Documents" :label_number_of_documents: "Documents"
:label_zip_names_encoding: "Zip names encoding"
:note_zip_names_encoding_iconv: "Iconv is used for charset conversion from utf-8 to target encoding"

View File

@ -147,4 +147,6 @@ de:
:title_filename_for_download: "Filename used for download or in Zip archive" :title_filename_for_download: "Filename used for download or in Zip archive"
:label_number_of_folders: "Folders" :label_number_of_folders: "Folders"
:label_number_of_documents: "Documents" :label_number_of_documents: "Documents"
:label_zip_names_encoding: "Zip names encoding"
:note_zip_names_encoding_iconv: "Iconv is used for charset conversion from utf-8 to target encoding"

View File

@ -147,4 +147,6 @@ en-GB:
:title_filename_for_download: "Filename used for download or in Zip archive" :title_filename_for_download: "Filename used for download or in Zip archive"
:label_number_of_folders: "Folders" :label_number_of_folders: "Folders"
:label_number_of_documents: "Documents" :label_number_of_documents: "Documents"
:label_zip_names_encoding: "Zip names encoding"
:note_zip_names_encoding_iconv: "Iconv is used for charset conversion from utf-8 to target encoding"

View File

@ -151,4 +151,7 @@ en:
:title_filename_for_download: "Filename used for download or in Zip archive" :title_filename_for_download: "Filename used for download or in Zip archive"
:label_number_of_folders: "Folders" :label_number_of_folders: "Folders"
:label_number_of_documents: "Documents" :label_number_of_documents: "Documents"
:label_zip_names_encoding: "Zip names encoding"
:note_zip_names_encoding_iconv: "Iconv is used for charset conversion from utf-8 to target encoding"

View File

@ -149,4 +149,6 @@ es:
:title_filename_for_download: "Filename used for download or in Zip archive" :title_filename_for_download: "Filename used for download or in Zip archive"
:label_number_of_folders: "Folders" :label_number_of_folders: "Folders"
:label_number_of_documents: "Documents" :label_number_of_documents: "Documents"
:label_zip_names_encoding: "Zip names encoding"
:note_zip_names_encoding_iconv: "Iconv is used for charset conversion from utf-8 to target encoding"

View File

@ -147,4 +147,6 @@ fr:
:title_filename_for_download: "Filename used for download or in Zip archive" :title_filename_for_download: "Filename used for download or in Zip archive"
:label_number_of_folders: "Folders" :label_number_of_folders: "Folders"
:label_number_of_documents: "Documents" :label_number_of_documents: "Documents"
:label_zip_names_encoding: "Zip names encoding"
:note_zip_names_encoding_iconv: "Iconv is used for charset conversion from utf-8 to target encoding"

View File

@ -151,4 +151,6 @@ en:
:title_filename_for_download: "Filename used for download or in Zip archive" :title_filename_for_download: "Filename used for download or in Zip archive"
:label_number_of_folders: "Folders" :label_number_of_folders: "Folders"
:label_number_of_documents: "Documents" :label_number_of_documents: "Documents"
:label_zip_names_encoding: "Zip names encoding"
:note_zip_names_encoding_iconv: "Iconv is used for charset conversion from utf-8 to target encoding"

View File

@ -147,4 +147,6 @@ ru:
:title_filename_for_download: "Filename used for download or in Zip archive" :title_filename_for_download: "Filename used for download or in Zip archive"
:label_number_of_folders: "Folders" :label_number_of_folders: "Folders"
:label_number_of_documents: "Documents" :label_number_of_documents: "Documents"
:label_zip_names_encoding: "Zip names encoding"
:note_zip_names_encoding_iconv: "Iconv is used for charset conversion from utf-8 to target encoding"

View File

@ -40,6 +40,7 @@ Redmine::Plugin.register :redmine_dmsf do
"dmsf_max_file_upload" => "0", "dmsf_max_file_upload" => "0",
"dmsf_max_file_download" => "0", "dmsf_max_file_download" => "0",
"dmsf_storage_directory" => "#{RAILS_ROOT}/files/dmsf", "dmsf_storage_directory" => "#{RAILS_ROOT}/files/dmsf",
"dmsf_zip_encoding" => "utf-8",
"dmsf_index_database" => "#{RAILS_ROOT}/files/dmsf_index", "dmsf_index_database" => "#{RAILS_ROOT}/files/dmsf_index",
"dmsf_stemming_lang" => "english", "dmsf_stemming_lang" => "english",
"dmsf_stemming_strategy" => "STEM_NONE" "dmsf_stemming_strategy" => "STEM_NONE"