@@ -85,7 +85,10 class WikiController < ApplicationController | |||
|
85 | 85 | end |
|
86 | 86 | end |
|
87 | 87 | @editable = editable? |
|
88 |
@sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) && |
|
|
88 | @sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) && | |
|
89 | params[:version].nil? && | |
|
90 | Redmine::WikiFormatting.supports_section_edit? | |
|
91 | ||
|
89 | 92 | render :action => 'show' |
|
90 | 93 | end |
|
91 | 94 | |
@@ -103,7 +106,7 class WikiController < ApplicationController | |||
|
103 | 106 | @content.version = @page.content.version |
|
104 | 107 | |
|
105 | 108 | @text = @content.text |
|
106 | if params[:section].present? | |
|
109 | if params[:section].present? && Redmine::WikiFormatting.supports_section_edit? | |
|
107 | 110 | @section = params[:section].to_i |
|
108 | 111 | @text, @section_hash = Redmine::WikiFormatting.formatter.new(@text).get_section(@section) |
|
109 | 112 | render_404 if @text.blank? |
@@ -131,7 +134,7 class WikiController < ApplicationController | |||
|
131 | 134 | |
|
132 | 135 | @content.comments = params[:content][:comments] |
|
133 | 136 | @text = params[:content][:text] |
|
134 | if params[:section].present? | |
|
137 | if params[:section].present? && Redmine::WikiFormatting.supports_section_edit? | |
|
135 | 138 | @section = params[:section].to_i |
|
136 | 139 | @section_hash = params[:section_hash] |
|
137 | 140 | @content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(params[:section].to_i, @text, @section_hash) |
@@ -62,6 +62,11 module Redmine | |||
|
62 | 62 | text |
|
63 | 63 | end |
|
64 | 64 | |
|
65 | # Returns true if the text formatter supports single section edit | |
|
66 | def supports_section_edit? | |
|
67 | (formatter.instance_methods & ['update_section', :update_section]).any? | |
|
68 | end | |
|
69 | ||
|
65 | 70 | # Returns a cache key for the given text +format+, +object+ and +attribute+ or nil if no caching should be done |
|
66 | 71 | def cache_key_for(format, object, attribute) |
|
67 | 72 | if object && attribute && !object.new_record? && object.respond_to?(:updated_on) && !format.blank? |
@@ -42,4 +42,14 EXPECTED | |||
|
42 | 42 | |
|
43 | 43 | assert_equal expected.gsub(%r{[\r\n\t]}, ''), Redmine::WikiFormatting::NullFormatter::Formatter.new(raw).to_html.gsub(%r{[\r\n\t]}, '') |
|
44 | 44 | end |
|
45 | ||
|
46 | def test_supports_section_edit | |
|
47 | with_settings :text_formatting => 'textile' do | |
|
48 | assert_equal true, Redmine::WikiFormatting.supports_section_edit? | |
|
49 | end | |
|
50 | ||
|
51 | with_settings :text_formatting => '' do | |
|
52 | assert_equal false, Redmine::WikiFormatting.supports_section_edit? | |
|
53 | end | |
|
54 | end | |
|
45 | 55 | end |
General Comments 0
You need to be logged in to leave comments.
Login now