From: Eric Davis Date: Wed, 27 Oct 2010 16:27:06 +0000 (+0000) Subject: Refactor: use :id instead of :page when linking to Wiki Pages X-Git-Tag: 1.1.0~239 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e9efa5b9814bbeddd9956b8478ed26af02b0eeca;p=redmine.git Refactor: use :id instead of :page when linking to Wiki Pages git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4296 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 4f15d35a0..39786341b 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -49,7 +49,7 @@ class WikiController < ApplicationController # display a page (in editing mode if it doesn't exist) def show - page_title = params[:page] + page_title = params[:id] @page = @wiki.find_or_new_page(page_title) if @page.new_record? if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? @@ -82,7 +82,7 @@ class WikiController < ApplicationController # edit an existing page or a new one def edit - @page = @wiki.find_or_new_page(params[:page]) + @page = @wiki.find_or_new_page(params[:id]) return render_403 unless editable? @page.content = WikiContent.new(:page => @page) if @page.new_record? @@ -101,7 +101,7 @@ class WikiController < ApplicationController verify :method => :post, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } # Creates a new page or updates an existing one def update - @page = @wiki.find_or_new_page(params[:page]) + @page = @wiki.find_or_new_page(params[:id]) return render_403 unless editable? @page.content = WikiContent.new(:page => @page) if @page.new_record? @@ -114,7 +114,7 @@ class WikiController < ApplicationController attachments = Attachment.attach_files(@page, params[:attachments]) render_attachment_warning_if_needed(@page) # don't save if text wasn't changed - redirect_to :action => 'show', :project_id => @project, :page => @page.title + redirect_to :action => 'show', :project_id => @project, :id => @page.title return end @content.attributes = params[:content] @@ -124,7 +124,7 @@ class WikiController < ApplicationController attachments = Attachment.attach_files(@page, params[:attachments]) render_attachment_warning_if_needed(@page) call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page}) - redirect_to :action => 'show', :project_id => @project, :page => @page.title + redirect_to :action => 'show', :project_id => @project, :id => @page.title end rescue ActiveRecord::StaleObjectError @@ -140,13 +140,13 @@ class WikiController < ApplicationController @original_title = @page.pretty_title if request.post? && @page.update_attributes(params[:wiki_page]) flash[:notice] = l(:notice_successful_update) - redirect_to :action => 'show', :project_id => @project, :page => @page.title + redirect_to :action => 'show', :project_id => @project, :id => @page.title end end def protect @page.update_attribute :protected, params[:protected] - redirect_to :action => 'show', :project_id => @project, :page => @page.title + redirect_to :action => 'show', :project_id => @project, :id => @page.title end # show page history @@ -210,7 +210,7 @@ class WikiController < ApplicationController export = render_to_string :action => 'export_multiple', :layout => false send_data(export, :type => 'text/html', :filename => "wiki.html") else - redirect_to :action => 'show', :project_id => @project, :page => nil + redirect_to :action => 'show', :project_id => @project, :id => nil end end @@ -219,7 +219,7 @@ class WikiController < ApplicationController end def preview - page = @wiki.find_page(params[:page]) + page = @wiki.find_page(params[:id]) # page is nil when previewing a new page return render_403 unless page.nil? || editable?(page) if page @@ -234,7 +234,7 @@ class WikiController < ApplicationController return render_403 unless editable? attachments = Attachment.attach_files(@page, params[:attachments]) render_attachment_warning_if_needed(@page) - redirect_to :action => 'show', :page => @page.title + redirect_to :action => 'show', :id => @page.title end private @@ -249,7 +249,7 @@ private # Finds the requested page and returns a 404 error if it doesn't exist def find_existing_page - @page = @wiki.find_page(params[:page]) + @page = @wiki.find_page(params[:id]) render_404 if @page.nil? end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 38d43e5b8..12f4b6e5e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -177,7 +177,7 @@ module ApplicationHelper content << "