summaryrefslogtreecommitdiffstats
path: root/app/controllers/wiki_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-05-26 15:42:37 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-05-26 15:42:37 +0000
commitf8ef65e8f64111b5bfa45abd42e0e684afd61f07 (patch)
treef38d893e289b9eb42f7732eeb33c225b8379ad41 /app/controllers/wiki_controller.rb
parent6446c312beab7e23162827a79bd9ab6f9e4d7958 (diff)
downloadredmine-f8ef65e8f64111b5bfa45abd42e0e684afd61f07.tar.gz
redmine-f8ef65e8f64111b5bfa45abd42e0e684afd61f07.zip
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments.
Attached images can be displayed inline, using textile image tag (for wiki pages, issue descriptions and forum messages). git-svn-id: http://redmine.rubyforge.org/svn/trunk@541 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/wiki_controller.rb')
-rw-r--r--app/controllers/wiki_controller.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index f68b71ecc..d8f23cfd1 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -17,10 +17,13 @@
class WikiController < ApplicationController
layout 'base'
- before_filter :find_wiki, :check_project_privacy, :except => [:preview]
- before_filter :authorize, :only => :destroy
+ before_filter :find_wiki, :check_project_privacy
+ before_filter :authorize, :only => [:destroy, :add_attachment, :destroy_attachment]
- verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index }
+ verify :method => :post, :only => [:destroy, :destroy_attachment], :redirect_to => { :action => :index }
+
+ helper :attachments
+ include AttachmentsHelper
# display a page (in editing mode if it doesn't exist)
def index
@@ -107,10 +110,28 @@ class WikiController < ApplicationController
end
def preview
+ page = @wiki.find_page(params[:page])
+ @attachements = page.attachments if page
@text = params[:content][:text]
render :partial => 'preview'
end
+ def add_attachment
+ @page = @wiki.find_page(params[:page])
+ # Save the attachments
+ params[:attachments].each { |file|
+ next unless file.size > 0
+ a = Attachment.create(:container => @page, :file => file, :author => logged_in_user)
+ } if params[:attachments] and params[:attachments].is_a? Array
+ redirect_to :action => 'index', :page => @page.title
+ end
+
+ def destroy_attachment
+ @page = @wiki.find_page(params[:page])
+ @page.attachments.find(params[:attachment_id]).destroy
+ redirect_to :action => 'index', :page => @page.title
+ end
+
private
def find_wiki