Commit 04962ef3e6cfc8c5c86179aaa1d039ffbf1b6bc6
Exists in
master
and in
28 other branches
Merge branch 'parse-everything' into stable
Showing
6 changed files
with
36 additions
and
4 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -1401,7 +1401,7 @@ module ApplicationHelper | @@ -1401,7 +1401,7 @@ module ApplicationHelper | ||
1401 | end | 1401 | end |
1402 | 1402 | ||
1403 | def filter_html(html, source) | 1403 | def filter_html(html, source) |
1404 | - if @plugins | 1404 | + if @plugins && source.has_macro? |
1405 | html = convert_macro(html, source) | 1405 | html = convert_macro(html, source) |
1406 | #TODO This parse should be done through the macro infra, but since there | 1406 | #TODO This parse should be done through the macro infra, but since there |
1407 | # are old things that do not support it we are keeping this hot spot. | 1407 | # are old things that do not support it we are keeping this hot spot. |
app/helpers/boxes_helper.rb
@@ -100,9 +100,7 @@ module BoxesHelper | @@ -100,9 +100,7 @@ module BoxesHelper | ||
100 | options[:title] = _("This block is invisible. Your visitors will not see it.") | 100 | options[:title] = _("This block is invisible. Your visitors will not see it.") |
101 | end | 101 | end |
102 | 102 | ||
103 | - if @controller.send(:content_editor?) | ||
104 | - result = filter_html(result, block) | ||
105 | - end | 103 | + result = filter_html(result, block) |
106 | 104 | ||
107 | box_decorator.block_target(block.box, block) + | 105 | box_decorator.block_target(block.box, block) + |
108 | content_tag('div', | 106 | content_tag('div', |
app/models/article.rb
@@ -673,6 +673,10 @@ class Article < ActiveRecord::Base | @@ -673,6 +673,10 @@ class Article < ActiveRecord::Base | ||
673 | 673 | ||
674 | delegate :region, :region_id, :environment, :environment_id, :to => :profile, :allow_nil => true | 674 | delegate :region, :region_id, :environment, :environment_id, :to => :profile, :allow_nil => true |
675 | 675 | ||
676 | + def has_macro? | ||
677 | + true | ||
678 | + end | ||
679 | + | ||
676 | private | 680 | private |
677 | 681 | ||
678 | def sanitize_tag_list | 682 | def sanitize_tag_list |
app/models/block.rb
app/models/raw_html_block.rb
@@ -10,4 +10,7 @@ class RawHTMLBlock < Block | @@ -10,4 +10,7 @@ class RawHTMLBlock < Block | ||
10 | (title.blank? ? '' : block_title(title)).html_safe + html.to_s.html_safe | 10 | (title.blank? ? '' : block_title(title)).html_safe + html.to_s.html_safe |
11 | end | 11 | end |
12 | 12 | ||
13 | + def has_macro? | ||
14 | + true | ||
15 | + end | ||
13 | end | 16 | end |
test/unit/application_helper_test.rb
@@ -791,6 +791,29 @@ class ApplicationHelperTest < ActiveSupport::TestCase | @@ -791,6 +791,29 @@ class ApplicationHelperTest < ActiveSupport::TestCase | ||
791 | '<br style=\'clear: left;\' /></div>', result | 791 | '<br style=\'clear: left;\' /></div>', result |
792 | end | 792 | end |
793 | 793 | ||
794 | + should 'not filter html if source does not have macros' do | ||
795 | + class Plugin1 < Noosfero::Plugin | ||
796 | + end | ||
797 | + | ||
798 | + class Plugin1::Macro1 < Noosfero::Plugin::Macro | ||
799 | + def parse(params, inner_html, source) | ||
800 | + 'Test1' | ||
801 | + end | ||
802 | + end | ||
803 | + | ||
804 | + environment = Environment.default | ||
805 | + environment.enable_plugin(Plugin1) | ||
806 | + @plugins = Noosfero::Plugin::Manager.new(environment, self) | ||
807 | + macro1_name = Plugin1::Macro1.identifier | ||
808 | + source = mock | ||
809 | + source.stubs(:has_macro?).returns(false) | ||
810 | + | ||
811 | + html = "<div class='macro nonEdit' data-macro='#{macro1_name}' data-macro-param='123'></div>" | ||
812 | + parsed_html = filter_html(html, source) | ||
813 | + | ||
814 | + assert_no_match /Test1/, parsed_html | ||
815 | + end | ||
816 | + | ||
794 | protected | 817 | protected |
795 | include NoosferoTestHelper | 818 | include NoosferoTestHelper |
796 | 819 |