diff --git a/app/controllers/public/comment_controller.rb b/app/controllers/public/comment_controller.rb index 1b436c4..37bc0b3 100644 --- a/app/controllers/public/comment_controller.rb +++ b/app/controllers/public/comment_controller.rb @@ -71,7 +71,9 @@ class CommentController < ApplicationController return end - @comment.save + if @comment.save + @plugins.dispatch(:process_extra_comment_params, [@comment,params]) + end respond_to do |format| format.js do @@ -113,6 +115,8 @@ class CommentController < ApplicationController def update if @comment.update_attributes(params[:comment]) + @plugins.dispatch(:process_extra_comment_params, [@comment,params]) + respond_to do |format| format.js do comment_to_render = @comment.comment_root diff --git a/app/views/comment/_comment.rhtml b/app/views/comment/_comment.rhtml index 645fd0e..9c67014 100644 --- a/app/views/comment/_comment.rhtml +++ b/app/views/comment/_comment.rhtml @@ -43,6 +43,7 @@

<%= txt2html comment.body %> + <%= @plugins.dispatch(:comment_extra_contents, local_assigns).collect { |content| instance_eval(&content) }.join("") %>

diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 3bd7cf0..eed5ac5 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -442,6 +442,25 @@ class Noosfero::Plugin nil end + # -> Adds adittional content to comment visualization + # returns = lambda block that creates html code + def comment_extra_contents(args) + nil + end + + # This method is called when the user clicks to send a comment. + # A plugin can add new content to comment form and this method can process the params sent to avoid creating field on core tables. + # returns = params after processed by plugins + # example: + # + # def process_extra_comment_params(params) + # params.delete(:extra_field) + # end + # + def process_extra_comment_params(params) + params + 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 -- libgit2 0.21.2