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