Commit bfaf1bdde96ad4b2876382641f07164946024887
1 parent
aa0f384c
Exists in
master
and in
22 other branches
Added hotspots for comments
Showing
3 changed files
with
25 additions
and
1 deletions
Show diff stats
app/controllers/public/comment_controller.rb
| ... | ... | @@ -71,7 +71,9 @@ class CommentController < ApplicationController |
| 71 | 71 | return |
| 72 | 72 | end |
| 73 | 73 | |
| 74 | - @comment.save | |
| 74 | + if @comment.save | |
| 75 | + @plugins.dispatch(:process_extra_comment_params, [@comment,params]) | |
| 76 | + end | |
| 75 | 77 | |
| 76 | 78 | respond_to do |format| |
| 77 | 79 | format.js do |
| ... | ... | @@ -113,6 +115,8 @@ class CommentController < ApplicationController |
| 113 | 115 | |
| 114 | 116 | def update |
| 115 | 117 | if @comment.update_attributes(params[:comment]) |
| 118 | + @plugins.dispatch(:process_extra_comment_params, [@comment,params]) | |
| 119 | + | |
| 116 | 120 | respond_to do |format| |
| 117 | 121 | format.js do |
| 118 | 122 | comment_to_render = @comment.comment_root | ... | ... |
app/views/comment/_comment.rhtml
| ... | ... | @@ -43,6 +43,7 @@ |
| 43 | 43 | <p/> |
| 44 | 44 | <%= txt2html comment.body %> |
| 45 | 45 | </div> |
| 46 | + <%= @plugins.dispatch(:comment_extra_contents, local_assigns).collect { |content| instance_eval(&content) }.join("") %> | |
| 46 | 47 | </div> |
| 47 | 48 | |
| 48 | 49 | <div class="comment_reply post_comment_box closed" id="comment_reply_to_<%= comment.id %>"> | ... | ... |
lib/noosfero/plugin.rb
| ... | ... | @@ -442,6 +442,25 @@ class Noosfero::Plugin |
| 442 | 442 | nil |
| 443 | 443 | end |
| 444 | 444 | |
| 445 | + # -> Adds adittional content to comment visualization | |
| 446 | + # returns = lambda block that creates html code | |
| 447 | + def comment_extra_contents(args) | |
| 448 | + nil | |
| 449 | + end | |
| 450 | + | |
| 451 | + # This method is called when the user clicks to send a comment. | |
| 452 | + # A plugin can add new content to comment form and this method can process the params sent to avoid creating field on core tables. | |
| 453 | + # returns = params after processed by plugins | |
| 454 | + # example: | |
| 455 | + # | |
| 456 | + # def process_extra_comment_params(params) | |
| 457 | + # params.delete(:extra_field) | |
| 458 | + # end | |
| 459 | + # | |
| 460 | + def process_extra_comment_params(params) | |
| 461 | + params | |
| 462 | + end | |
| 463 | + | |
| 445 | 464 | # -> Finds objects by their contents |
| 446 | 465 | # returns = {:results => [a, b, c, ...], ...} |
| 447 | 466 | # P.S.: The plugin might add other informations on the return hash for its | ... | ... |