Redmine にテーマの適用をしてみる。
wget -O farend_fancy.zip https://github.com/farend/redmine_theme_farend_fancy/archive/master.zip
unzip farend_fancy.zip
sudo mv redmine_theme_farend_fancy-master /usr/share/redmine/public/themes/farend_fancy
def zip_entries(zip, selected_folders, selected_files) + # set encoding by UserAgent 2014/12/17 by windmesser.cc + # Windows in Japanese => sjis , else => utf-8 + encoding = "utf-8" + encoding = "sjis" if request.env["HTTP_USER_AGENT"] =~ /Windows/ && request.env["HTTP_ACCEPT_LANGUAGE"] =~ /^ja/ if selected_folders && selected_folders.is_a?(Array) selected_folders.each do |selected_folder_id| folder = DmsfFolder.visible.find_by_id selected_folder_id if folder + # add param encoding 2014/12/17 by windmesser.cc - zip.add_folder(folder, (@folder.dmsf_path_str if @folder)) + zip.add_folder(folder, (@folder.dmsf_path_str if @folder), encoding) else raise FileNotFound end end end if selected_files && selected_files.is_a?(Array) selected_files.each do |selected_file_id| file = DmsfFile.visible.find_by_id selected_file_id if file && file.last_revision && File.exists?(file.last_revision.disk_file) + # add param encoding 2014/12/17 by windmesser.cc - zip.add_file(file, (@folder.dmsf_path_str if @folder)) if file + zip.add_file(file, (@folder.dmsf_path_str if @folder), encoding) if file else raise FileNotFound end end end max_files = Setting.plugin_redmine_dmsf['dmsf_max_file_download'].to_i if max_files > 0 && zip.files.length > max_files raise ZipMaxFilesError, zip.files.length end zip endlib/dmsf_zip.rb ※変更箇所一部抜粋
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require 'zip' + require 'kconv' # add lib 2014/12/17 by windmesser.cc class DmsfZip :
+ # set encoding by UserAgent 2014/12/17 by windmesser.cc + # add param encoding - def add_file(file, root_path = nil) + def add_file(file, root_path = nil, encoding = "utf8") string_path = file.folder.nil? ? '' : "#{file.folder.dmsf_path_str}/" string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path string_path += file.name + # add start 2014/12/17 by windmesser.cc + if encoding == "sjis" + string_path = string_path.tosjis() + end + # add end @zip_file.put_next_entry(string_path) File.open(file.last_revision.disk_file, 'rb') do |f| while (buffer = f.read(8192)) @zip_file.write(buffer) end end @files << file end + # set encoding by UserAgent 2014/12/17 by windmesser.cc + # add param encoding - def add_folder(folder, root_path = nil) + def add_folder(folder, root_path = nil, encoding = "utf8") string_path = "#{folder.dmsf_path_str}/" string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path + # add start 2014/12/17 by windmesser.cc + if encoding == "sjis" + string_path = string_path.tosjis() + end + # add end @zip_file.put_next_entry(string_path) + # add param encoding - folder.subfolders.visible.each { |subfolder| self.add_folder(subfolder, root_path) } - folder.files.visible.each { |file| self.add_file(file, root_path) } + folder.subfolders.visible.each { |subfolder| self.add_folder(subfolder, root_path, encoding) } + folder.files.visible.each { |file| self.add_file(file, root_path, encoding) } end