##// END OF EJS Templates
Code cleanup....
Jean-Philippe Lang -
r5302:6db0e8dcef0b
parent child
Show More
@@ -34,10 +34,9 require 'diff'
34 class WikiController < ApplicationController
34 class WikiController < ApplicationController
35 default_search_scope :wiki_pages
35 default_search_scope :wiki_pages
36 before_filter :find_wiki, :authorize
36 before_filter :find_wiki, :authorize
37 before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
37 before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
38 before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
38
39
39 verify :method => :post, :only => [:protect], :redirect_to => { :action => :show }
40
41 helper :attachments
40 helper :attachments
42 include AttachmentsHelper
41 include AttachmentsHelper
43 helper :watchers
42 helper :watchers
@@ -56,8 +55,6 class WikiController < ApplicationController
56
55
57 # display a page (in editing mode if it doesn't exist)
56 # display a page (in editing mode if it doesn't exist)
58 def show
57 def show
59 page_title = params[:id]
60 @page = @wiki.find_or_new_page(page_title)
61 if @page.new_record?
58 if @page.new_record?
62 if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
59 if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
63 edit
60 edit
@@ -89,7 +86,6 class WikiController < ApplicationController
89
86
90 # edit an existing page or a new one
87 # edit an existing page or a new one
91 def edit
88 def edit
92 @page = @wiki.find_or_new_page(params[:id])
93 return render_403 unless editable?
89 return render_403 unless editable?
94 @page.content = WikiContent.new(:page => @page) if @page.new_record?
90 @page.content = WikiContent.new(:page => @page) if @page.new_record?
95
91
@@ -105,7 +101,6 class WikiController < ApplicationController
105 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
101 verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
106 # Creates a new page or updates an existing one
102 # Creates a new page or updates an existing one
107 def update
103 def update
108 @page = @wiki.find_or_new_page(params[:id])
109 return render_403 unless editable?
104 return render_403 unless editable?
110 @page.content = WikiContent.new(:page => @page) if @page.new_record?
105 @page.content = WikiContent.new(:page => @page) if @page.new_record?
111
106
@@ -151,6 +146,7 class WikiController < ApplicationController
151 end
146 end
152 end
147 end
153
148
149 verify :method => :post, :only => :protect, :redirect_to => { :action => :show }
154 def protect
150 def protect
155 @page.update_attribute :protected, params[:protected]
151 @page.update_attribute :protected, params[:protected]
156 redirect_to :action => 'show', :project_id => @project, :id => @page.title
152 redirect_to :action => 'show', :project_id => @project, :id => @page.title
@@ -250,6 +246,11 private
250 render_404
246 render_404
251 end
247 end
252
248
249 # Finds the requested page or a new page if it doesn't exist
250 def find_existing_or_new_page
251 @page = @wiki.find_or_new_page(params[:id])
252 end
253
253 # Finds the requested page and returns a 404 error if it doesn't exist
254 # Finds the requested page and returns a 404 error if it doesn't exist
254 def find_existing_page
255 def find_existing_page
255 @page = @wiki.find_page(params[:id])
256 @page = @wiki.find_page(params[:id])
General Comments 0
You need to be logged in to leave comments. Login now