From 79cff193d012684a8d16c3eb16069000adc04225 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 3 Jul 2008 19:40:22 +0000 Subject: [PATCH] Pass path param as an array. git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1617 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- rails-2.1/app/helpers/repositories_helper.rb | 4 ++++ rails-2.1/app/views/repositories/_dir_list_content.rhtml | 6 +++--- rails-2.1/app/views/repositories/_navigation.rhtml | 4 ++-- rails-2.1/app/views/repositories/_revisions.rhtml | 2 +- rails-2.1/app/views/repositories/changes.rhtml | 6 +++--- rails-2.1/app/views/repositories/revision.rhtml | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/rails-2.1/app/helpers/repositories_helper.rb b/rails-2.1/app/helpers/repositories_helper.rb index 22bdec9df..4db3b2057 100644 --- a/rails-2.1/app/helpers/repositories_helper.rb +++ b/rails-2.1/app/helpers/repositories_helper.rb @@ -29,6 +29,10 @@ module RepositoriesHelper txt.to_s[0,8] end + def to_path_param(path) + path.to_s.split(%r{[/\\]}).select {|p| !p.blank?} + end + def to_utf8(str) return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip) diff --git a/rails-2.1/app/views/repositories/_dir_list_content.rhtml b/rails-2.1/app/views/repositories/_dir_list_content.rhtml index 3564e52ab..0a5c68d54 100644 --- a/rails-2.1/app/views/repositories/_dir_list_content.rhtml +++ b/rails-2.1/app/views/repositories/_dir_list_content.rhtml @@ -5,19 +5,19 @@ <%= if entry.is_dir? link_to_remote h(entry.name), - {:url => {:action => 'browse', :id => @project, :path => entry.path, :rev => @rev, :depth => (depth + 1), :parent_id => tr_id}, + {:url => {:action => 'browse', :id => @project, :path => to_path_param(entry.path), :rev => @rev, :depth => (depth + 1), :parent_id => tr_id}, :update => { :success => tr_id }, :position => :after, :success => "scmEntryLoaded('#{tr_id}')", :condition => "scmEntryClick('#{tr_id}')" }, - {:href => url_for({:action => 'browse', :id => @project, :path => entry.path, :rev => @rev}), + {:href => url_for({:action => 'browse', :id => @project, :path => to_path_param(entry.path), :rev => @rev}), :class => ('icon icon-folder'), :style => "margin-left: #{18 * depth}px;" } else link_to h(entry.name), - {:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => entry.path, :rev => @rev}, + {:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev}, :class => 'icon icon-file', :style => "margin-left: #{18 * depth}px;" end %> diff --git a/rails-2.1/app/views/repositories/_navigation.rhtml b/rails-2.1/app/views/repositories/_navigation.rhtml index b7ac989bc..25a15f496 100644 --- a/rails-2.1/app/views/repositories/_navigation.rhtml +++ b/rails-2.1/app/views/repositories/_navigation.rhtml @@ -10,10 +10,10 @@ dirs.each do |dir| link_path << '/' unless link_path.empty? link_path << "#{dir}" %> - / <%= link_to h(dir), :action => 'browse', :id => @project, :path => link_path, :rev => @rev %> + / <%= link_to h(dir), :action => 'browse', :id => @project, :path => to_path_param(link_path), :rev => @rev %> <% end %> <% if filename %> - / <%= link_to h(filename), :action => 'changes', :id => @project, :path => "#{link_path}/#{filename}", :rev => @rev %> + / <%= link_to h(filename), :action => 'changes', :id => @project, :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev %> <% end %> <%= "@ #{revision}" if revision %> diff --git a/rails-2.1/app/views/repositories/_revisions.rhtml b/rails-2.1/app/views/repositories/_revisions.rhtml index 1bcf0208c..a938fecb8 100644 --- a/rails-2.1/app/views/repositories/_revisions.rhtml +++ b/rails-2.1/app/views/repositories/_revisions.rhtml @@ -1,4 +1,4 @@ -<% form_tag({:controller => 'repositories', :action => 'diff', :id => @project, :path => path}, :method => :get) do %> +<% form_tag({:controller => 'repositories', :action => 'diff', :id => @project, :path => to_path_param(path)}, :method => :get) do %> diff --git a/rails-2.1/app/views/repositories/changes.rhtml b/rails-2.1/app/views/repositories/changes.rhtml index 2d7462b29..90bee6ef9 100644 --- a/rails-2.1/app/views/repositories/changes.rhtml +++ b/rails-2.1/app/views/repositories/changes.rhtml @@ -4,12 +4,12 @@

<% if @repository.supports_cat? %> - <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => @path, :rev => @rev } %> | + <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev } %> | <% end %> <% if @repository.supports_annotate? %> - <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => @path, :rev => @rev } %> | + <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => to_path_param(@path), :rev => @rev } %> | <% end %> -<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %> +<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %> <%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>

diff --git a/rails-2.1/app/views/repositories/revision.rhtml b/rails-2.1/app/views/repositories/revision.rhtml index 2fdf58faf..bff60ec83 100644 --- a/rails-2.1/app/views/repositories/revision.rhtml +++ b/rails-2.1/app/views/repositories/revision.rhtml @@ -49,7 +49,7 @@
#
<%= change.path %> <%= "(#{change.revision})" unless change.revision.blank? %>
<% if change.action == "M" %> -<%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => without_leading_slash(change.relative_path), :rev => @changeset.revision %> +<%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => to_path_param(change.relative_path), :rev => @changeset.revision %> <% end %>