if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
@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)
+ @content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(@section, @text, @section_hash)
else
@content.version = content_params[:version] if content_params[:version]
@content.text = @text
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
respond_to do |format|
- format.html { redirect_to project_wiki_page_path(@project, @page.title) }
+ format.html {
+ anchor = @section ? "section-#{@section}" : nil
+ redirect_to project_wiki_page_path(@project, @page.title, :anchor => anchor)
+ }
format.api {
if was_new_page
render :action => 'show', :status => :created, :location => project_wiki_page_path(@project, @page.title)
content_tag('div',
link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
:class => 'contextual',
- :title => l(:button_edit_section)) + heading.html_safe
+ :title => l(:button_edit_section),
+ :id => "section-#{@current_section}") + heading.html_safe
else
heading
end
end
end
end
- assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections'
+ assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections#section-2'
assert_equal Redmine::WikiFormatting::Textile::Formatter.new(text).update_section(2, "New section content"), page.reload.content.text
end
end
end
end
- assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections'
+ assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections#section-2'
page.reload
assert_equal Redmine::WikiFormatting::Textile::Formatter.new(text).update_section(2, "New section content"), page.content.text
assert_equal 4, page.content.version