Commit bfaf1bdde96ad4b2876382641f07164946024887
1 parent
aa0f384c
Exists in
master
and in
29 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,7 +71,9 @@ class CommentController < ApplicationController | ||
71 | return | 71 | return |
72 | end | 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 | respond_to do |format| | 78 | respond_to do |format| |
77 | format.js do | 79 | format.js do |
@@ -113,6 +115,8 @@ class CommentController < ApplicationController | @@ -113,6 +115,8 @@ class CommentController < ApplicationController | ||
113 | 115 | ||
114 | def update | 116 | def update |
115 | if @comment.update_attributes(params[:comment]) | 117 | if @comment.update_attributes(params[:comment]) |
118 | + @plugins.dispatch(:process_extra_comment_params, [@comment,params]) | ||
119 | + | ||
116 | respond_to do |format| | 120 | respond_to do |format| |
117 | format.js do | 121 | format.js do |
118 | comment_to_render = @comment.comment_root | 122 | comment_to_render = @comment.comment_root |
app/views/comment/_comment.rhtml
@@ -43,6 +43,7 @@ | @@ -43,6 +43,7 @@ | ||
43 | <p/> | 43 | <p/> |
44 | <%= txt2html comment.body %> | 44 | <%= txt2html comment.body %> |
45 | </div> | 45 | </div> |
46 | + <%= @plugins.dispatch(:comment_extra_contents, local_assigns).collect { |content| instance_eval(&content) }.join("") %> | ||
46 | </div> | 47 | </div> |
47 | 48 | ||
48 | <div class="comment_reply post_comment_box closed" id="comment_reply_to_<%= comment.id %>"> | 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,6 +442,25 @@ class Noosfero::Plugin | ||
442 | nil | 442 | nil |
443 | end | 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 | # -> Finds objects by their contents | 464 | # -> Finds objects by their contents |
446 | # returns = {:results => [a, b, c, ...], ...} | 465 | # returns = {:results => [a, b, c, ...], ...} |
447 | # P.S.: The plugin might add other informations on the return hash for its | 466 | # P.S.: The plugin might add other informations on the return hash for its |