From 094641e318606da4182dd1a6fc56d21210313852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Fri, 3 Apr 2015 13:14:47 +0200 Subject: [PATCH] Cannot open files in utf-8 folders via webdav #299 --- lib/redmine_dmsf/webdav/base_resource.rb | 22 ++++++++++++++------- lib/redmine_dmsf/webdav/dmsf_resource.rb | 4 ++-- lib/redmine_dmsf/webdav/project_resource.rb | 8 +++++--- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/redmine_dmsf/webdav/base_resource.rb b/lib/redmine_dmsf/webdav/base_resource.rb index fb2a1437..7b5bf7ae 100644 --- a/lib/redmine_dmsf/webdav/base_resource.rb +++ b/lib/redmine_dmsf/webdav/base_resource.rb @@ -1,7 +1,9 @@ +# encoding: utf-8 +# # Redmine plugin for Document Management System "Features" # # Copyright (C) 2012 Daniel Munn -# Copyright (C) 2011-15 Karel Picman +# Copyright (C) 2011-15 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -59,7 +61,7 @@ module RedmineDmsf #Generate HTML for Get requests def html_display - @response.body = "" + @response.body = '' Confict unless collection? entities = children.map{|child| DIR_FILE % [ @@ -76,18 +78,24 @@ module RedmineDmsf '-', '', '', - ] + entities unless parent.nil? + ] + entities if parent? @response.body << index_page % [ path.empty? ? '/' : path, path.empty? ? '/' : path , entities ] end - #Run method through proxy class - ensuring always compatible child is generated - def child(name, options = nil) - @__proxy.child(name) + # Run method through proxy class - ensuring always compatible child is generated + def child(name) + new_public = public_path.dup + new_public = new_public + '/' unless new_public[-1,1] == '/' + new_public = '/' + new_public unless new_public[0,1] == '/' + new_path = path.dup + new_path = new_path + '/' unless new_path[-1,1] == '/' + new_path = '/' + new_path unless new_path[0,1] == '/' + @__proxy.class.new("#{new_public}#{name}", "#{new_path}#{name}", request, response, options.merge(:user => @user)) end def parent p = @__proxy.parent - return nil if p.nil? + return nil unless p return p.resource.nil? ? p : p.resource end diff --git a/lib/redmine_dmsf/webdav/dmsf_resource.rb b/lib/redmine_dmsf/webdav/dmsf_resource.rb index cff5ad3e..0d3488b1 100644 --- a/lib/redmine_dmsf/webdav/dmsf_resource.rb +++ b/lib/redmine_dmsf/webdav/dmsf_resource.rb @@ -55,10 +55,10 @@ module RedmineDmsf @children = [] return [] unless collection? folder.subfolders.map do |p| - @children.push child(p.title, p) + @children.push child(p.title) end folder.files.visible.map do |p| - @children.push child(p.name, p) + @children.push child(p.name) end @children end diff --git a/lib/redmine_dmsf/webdav/project_resource.rb b/lib/redmine_dmsf/webdav/project_resource.rb index 9639b0c3..d068e035 100644 --- a/lib/redmine_dmsf/webdav/project_resource.rb +++ b/lib/redmine_dmsf/webdav/project_resource.rb @@ -1,7 +1,9 @@ +# encoding: utf-8 +# # Redmine plugin for Document Management System "Features" # # Copyright (C) 2012 Daniel Munn -# Copyright (C) 2011-14 Karel Picman +# Copyright (C) 2011-14 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -31,10 +33,10 @@ module RedmineDmsf return [] if project.nil? || project.id.nil? @children = [] project.dmsf_folders.visible.map do |p| - @children.push child(p.title, p) + @children.push child(p.title) end project.dmsf_files.visible.map do |p| - @children.push child(p.name, p) + @children.push child(p.name) end @children end