diff --git a/app/views/content_viewer/view_page.html.erb b/app/views/content_viewer/view_page.html.erb index 036f6b5..0394da6 100644 --- a/app/views/content_viewer/view_page.html.erb +++ b/app/views/content_viewer/view_page.html.erb @@ -42,6 +42,7 @@ <%= render :partial => 'shared/disabled_enterprise' %> +<%= @plugins.dispatch(:social_buttons_contents).collect { |content| instance_exec(&content) }.join("") %> <% if NOOSFERO_CONF['addthis_enabled'] %> <%= render :partial => 'addthis' %> <% end %> diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index e966ae3..fd019d0 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -394,6 +394,12 @@ class Noosfero::Plugin nil end + # -> Adds social networks share buttons to content + # returns = proc that creates html code + def social_buttons_contents + nil + end + # -> Adds fields to the signup form # returns = proc that creates html code def signup_extra_contents diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index bc78b31..d466195 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -1391,4 +1391,29 @@ class ContentViewerControllerTest < ActionController::TestCase assert_tag :tag => 'meta', :attributes => { :property => 'og:image', :content => /\/images\/x.png/ } end + should 'add social content on content view page from plugins' do + class Plugin1 < Noosfero::Plugin + def social_buttons_contents + proc {"Plugin1 text"} + end + end + class Plugin2 < Noosfero::Plugin + def social_buttons_contents + proc {"
"} + end + end + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) + + Environment.default.enable_plugin(Plugin1.name) + Environment.default.enable_plugin(Plugin2.name) + + page = profile.articles.build(:name => 'test') + page.save! + + get :view_page, :profile => profile.identifier, :page => ['test'] + + assert_tag :tag => 'strong', :content => 'Plugin1 text' + assert_tag :tag => 'div', :attributes => {:class => 'social-buttons'} + end + end -- libgit2 0.21.2