diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-04-11 19:04:39 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-04-11 19:04:39 +0000 |
commit | 6db0e8dcef0bf1e4ece02641b51b9df38dae31dc (patch) | |
tree | 71669a9ad2f8da66247626ce6cfced281750b018 /app/controllers/wiki_controller.rb | |
parent | ae16fb3e5f4f4e2033b708193b4ae7008e870d75 (diff) | |
download | redmine-6db0e8dcef0bf1e4ece02641b51b9df38dae31dc.tar.gz redmine-6db0e8dcef0bf1e4ece02641b51b9df38dae31dc.zip |
Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5422 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/wiki_controller.rb')
-rw-r--r-- | app/controllers/wiki_controller.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 5b87f902a..84fb16d2e 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -34,10 +34,9 @@ require 'diff' class WikiController < ApplicationController default_search_scope :wiki_pages before_filter :find_wiki, :authorize + before_filter :find_existing_or_new_page, :only => [:show, :edit, :update] before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy] - verify :method => :post, :only => [:protect], :redirect_to => { :action => :show } - helper :attachments include AttachmentsHelper helper :watchers @@ -56,8 +55,6 @@ class WikiController < ApplicationController # display a page (in editing mode if it doesn't exist) def show - 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? edit @@ -89,7 +86,6 @@ class WikiController < ApplicationController # edit an existing page or a new one def edit - @page = @wiki.find_or_new_page(params[:id]) return render_403 unless editable? @page.content = WikiContent.new(:page => @page) if @page.new_record? @@ -105,7 +101,6 @@ class WikiController < ApplicationController verify :method => :put, :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[:id]) return render_403 unless editable? @page.content = WikiContent.new(:page => @page) if @page.new_record? @@ -151,6 +146,7 @@ class WikiController < ApplicationController end end + verify :method => :post, :only => :protect, :redirect_to => { :action => :show } def protect @page.update_attribute :protected, params[:protected] redirect_to :action => 'show', :project_id => @project, :id => @page.title @@ -250,6 +246,11 @@ private render_404 end + # Finds the requested page or a new page if it doesn't exist + def find_existing_or_new_page + @page = @wiki.find_or_new_page(params[:id]) + end + # Finds the requested page and returns a 404 error if it doesn't exist def find_existing_page @page = @wiki.find_page(params[:id]) |