diff --git a/app/views/content_viewer/_article_toolbar.rhtml b/app/views/content_viewer/_article_toolbar.rhtml
index aee80d5..e83ad4e 100644
--- a/app/views/content_viewer/_article_toolbar.rhtml
+++ b/app/views/content_viewer/_article_toolbar.rhtml
@@ -53,6 +53,7 @@
<%= link_to(image_tag('icons-mime/rss-feed.png'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %>
+ <%= @plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_eval(&content) }.join("") %>
<%= article_title(@page, :no_link => true) %>
<%= article_translations(@page) %>
diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb
index 8fc0061..7b7e03a 100644
--- a/lib/noosfero/plugin.rb
+++ b/lib/noosfero/plugin.rb
@@ -449,6 +449,12 @@ class Noosfero::Plugin
nil
end
+ # -> Adds adicional content to article header
+ # returns = lambda block that creates html code
+ def article_header_extra_contents(article)
+ nil
+ end
+
# -> Finds objects by their contents
# returns = {:results => [a, b, c, ...], ...}
# P.S.: The plugin might add other informations on the return hash for its
diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb
index f103e79..a25ed4d 100644
--- a/test/functional/content_viewer_controller_test.rb
+++ b/test/functional/content_viewer_controller_test.rb
@@ -1270,5 +1270,32 @@ class ContentViewerControllerTest < ActionController::TestCase
get :view_page, :profile => profile.identifier, :page => [blog.path]
assert_tag :tag => 'strong', :content => /bold/
end
+
+ should 'add extra content on article header from plugins' do
+ class Plugin1 < Noosfero::Plugin
+ def article_header_extra_contents(args)
+ lambda {
+ content_tag('div', '', :class => 'plugin1')
+ }
+ end
+ end
+ class Plugin2 < Noosfero::Plugin
+ def article_header_extra_contents(args)
+ lambda {
+ content_tag('div', '', :class => 'plugin2')
+ }
+ end
+ end
+
+ Environment.default.enable_plugin(Plugin1.name)
+ Environment.default.enable_plugin(Plugin2.name)
+
+ page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text')
+
+ xhr :get, :view_page, :profile => profile.identifier, :page => [ 'myarticle' ], :toolbar => true
+
+ assert_tag :tag => 'div', :attributes => {:class => 'plugin1'}
+ assert_tag :tag => 'div', :attributes => {:class => 'plugin2'}
+ end
end
--
libgit2 0.21.2