diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-18 16:25:00 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-18 16:25:00 +0000 |
commit | 6fc245327ce5bb4bb75f1378424635e347dfcd02 (patch) | |
tree | fd9d00eab0e444da2f6ecb58842cb973c37540a5 /app/controllers/wiki_controller.rb | |
parent | b38dc9a301c3ab0fafc5dd824ad57059ec58fc91 (diff) | |
download | redmine-6fc245327ce5bb4bb75f1378424635e347dfcd02.tar.gz redmine-6fc245327ce5bb4bb75f1378424635e347dfcd02.zip |
Wiki: allows single section edit (#2222).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7829 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/wiki_controller.rb')
-rw-r--r-- | app/controllers/wiki_controller.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 8111a617b..721ea28de 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -100,6 +100,13 @@ class WikiController < ApplicationController # To prevent StaleObjectError exception when reverting to a previous version @content.version = @page.content.version + + @text = @content.text + if params[:section].present? + @section = params[:section].to_i + @text, @section_hash = Redmine::WikiFormatting.formatter.new(@text).get_section(@section) + render_404 if @text.blank? + end end verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } @@ -120,7 +127,17 @@ class WikiController < ApplicationController redirect_to :action => 'show', :project_id => @project, :id => @page.title return end - @content.attributes = params[:content] + + @content.comments = params[:content][:comments] + @text = params[:content][:text] + if params[:section].present? + @section = params[:section].to_i + @section_hash = params[:section_hash] + @content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(params[:section].to_i, @text, @section_hash) + else + @content.version = params[:content][:version] + @content.text = @text + end @content.author = User.current # if page is new @page.save will also save content, but not if page isn't a new record if (@page.new_record? ? @page.save : @content.save) @@ -132,7 +149,7 @@ class WikiController < ApplicationController render :action => 'edit' end - rescue ActiveRecord::StaleObjectError + rescue ActiveRecord::StaleObjectError, Redmine::WikiFormatting::StaleSectionError # Optimistic locking exception flash.now[:error] = l(:notice_locking_conflict) render :action => 'edit' |