Project

General

Profile

Patch #14829

Updated by Toshi MARUYAMA over 7 years ago

Patch to support setting parent-page for WIKI entries via REST API: 
 <pre><code class="diff"> <pre> 
  app/controllers/wiki_controller.rb | 4 +++- 
  1 file changed, 3 insertions(+), 1 deletion(-) 

 diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb 
 index a1d68ed..898eedc 100644 
 --- a/app/controllers/wiki_controller.rb 
 +++ b/app/controllers/wiki_controller.rb 
 @@ -138,12 +138,13 @@ class WikiController < ApplicationController 
      @content = @page.content 
      content_params = params[:content] 
      if content_params.nil? && params[:wiki_page].is_a?(Hash) 
 -        content_params = params[:wiki_page].slice(:text, :comments, :version) 
 +        content_params = params[:wiki_page].slice(:text, :comments, :version, :parent_title) 
      end 
      content_params ||= {} 
 
      @content.comments = content_params[:comments] 
      @text = content_params[:text] 
 +      @parent_title = content_params[:parent_title] 
      if params[:section].present? && Redmine::WikiFormatting.supports_section_edit? 
        @section = params[:section].to_i 
        @section_hash = params[:section_hash] 
 @@ -151,6 +152,7 @@ class WikiController < ApplicationController 
      else 
        @content.version = content_params[:version] if content_params[:version] 
        @content.text = @text 
 +        @page.parent_title = @parent_title 
      end 
      @content.author = User.current 
 </code></pre> 

 </pre> 


 Usage: 
 <pre><code class="json"> <pre> 
 PUT /projects/foo/wiki/[WIKI ENTRY].json 
 { 
   "wiki_page": { 
     "parent_title": "[PARENT_PAGE_TITLE]", 
     "text": "[CONTENT]", 
     "comment": "[COMMENT]" 
   } 
 } 
 </code></pre> </pre> 

 // Michael Medin

Back