From cb4e3d39af25f2638e850f1fb913bb16cb222632 Mon Sep 17 00:00:00 2001 From: Michel Felipe de Oliveira Ferreira Date: Fri, 4 Dec 2015 13:03:55 -0300 Subject: [PATCH] New hotspot to add custom buttons on content manager page --- app/views/cms/_view_items.html.erb | 1 + lib/noosfero/plugin.rb | 7 +++++++ test/unit/plugin_test.rb | 12 ++++++++++++ 3 files changed, 20 insertions(+), 0 deletions(-) diff --git a/app/views/cms/_view_items.html.erb b/app/views/cms/_view_items.html.erb index 38f0077..82c3711 100644 --- a/app/views/cms/_view_items.html.erb +++ b/app/views/cms/_view_items.html.erb @@ -13,6 +13,7 @@ <%= time_ago_in_words article.updated_at %> + <%= @plugins.dispatch(:extra_content_actions, article).collect { |content| instance_exec(&content) }.join("") %> <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit, article) %> <%= button_without_text :eyes, _('Public view'), article.view_url %> <%= display_spread_button(article) unless remove_content_button(:spread, article) %> diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 34b05a0..7b02831 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -213,6 +213,13 @@ class Noosfero::Plugin end.select {|const| const.is_a?(Class) && const < Noosfero::Plugin::Macro} end + # New buttons actions with icons in each article on content manager page + # returns = proc block that creates html code to custom buttons + # + def extra_content_actions(article) + nil + end + # Here the developer may specify the events to which the plugins can # register and must return true or false. The default value must be false. # Must also explicitly define its returning variables. diff --git a/test/unit/plugin_test.rb b/test/unit/plugin_test.rb index a7337a3..744bc4f 100644 --- a/test/unit/plugin_test.rb +++ b/test/unit/plugin_test.rb @@ -567,4 +567,16 @@ class PluginTest < ActiveSupport::TestCase assert_equal [], p.article_extra_toolbar_buttons(nil) end + should 'get extra buttons actions on content manager grid' do + class Plugin1 < Noosfero::Plugin + def extra_content_actions + proc do + 'Btn' + end + end + end + p = Plugin1.new + assert_tag_in_string p.extra_content_actions.call(), :tag => 'a', :content => 'Btn' + end + end -- libgit2 0.21.2