Commit a5e0b197a69dd21b4f556868a7e271152dd9bd56

Authored by Evandro Junior
1 parent f9937d0e

changed paragraph_id to paragraph_uuid

plugins/comment_paragraph/controllers/profile/comment_paragraph_plugin_profile_controller.rb
@@ -3,9 +3,9 @@ class CommentParagraphPluginProfileController < ProfileController @@ -3,9 +3,9 @@ class CommentParagraphPluginProfileController < ProfileController
3 3
4 def view_comments 4 def view_comments
5 @article_id = params[:article_id] 5 @article_id = params[:article_id]
6 - @paragraph_id = params[:paragraph_id] 6 + @paragraph_uuid = params[:paragraph_uuid]
7 article = profile.articles.find(@article_id) 7 article = profile.articles.find(@article_id)
8 - @comments = article.comments.without_spam.in_paragraph(@paragraph_id) 8 + @comments = article.comments.without_spam.in_paragraph(@paragraph_uuid)
9 @comments_count = @comments.count 9 @comments_count = @comments.count
10 @comments = @comments.without_reply 10 @comments = @comments.without_reply
11 end 11 end
plugins/comment_paragraph/controllers/public/comment_paragraph_plugin_public_controller.rb
@@ -3,7 +3,7 @@ class CommentParagraphPluginPublicController < PublicController @@ -3,7 +3,7 @@ class CommentParagraphPluginPublicController < PublicController
3 3
4 def comment_paragraph 4 def comment_paragraph
5 @comment = Comment.find(params[:id]) 5 @comment = Comment.find(params[:id])
6 - render :json => { :paragraph_id => @comment.paragraph_id } 6 + render :json => { :paragraph_uuid => @comment.paragraph_uuid }
7 end 7 end
8 8
9 end 9 end
plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
@@ -14,11 +14,11 @@ class CommentParagraphPlugin < Noosfero::Plugin @@ -14,11 +14,11 @@ class CommentParagraphPlugin < Noosfero::Plugin
14 14
15 def comment_form_extra_contents(args) 15 def comment_form_extra_contents(args)
16 comment = args[:comment] 16 comment = args[:comment]
17 - paragraph_id = comment.paragraph_id || args[:paragraph_id] 17 + paragraph_uuid = comment.paragraph_uuid || args[:paragraph_uuid]
18 proc { 18 proc {
19 arr = [] 19 arr = []
20 arr << hidden_field_tag('comment[id]', comment.id) 20 arr << hidden_field_tag('comment[id]', comment.id)
21 - arr << hidden_field_tag('comment[paragraph_id]', paragraph_id) if paragraph_id 21 + arr << hidden_field_tag('comment[paragraph_uuid]', paragraph_uuid) if paragraph_uuid
22 arr << hidden_field_tag('comment[comment_paragraph_selected_area]', comment.comment_paragraph_selected_area) unless comment.comment_paragraph_selected_area.blank? 22 arr << hidden_field_tag('comment[comment_paragraph_selected_area]', comment.comment_paragraph_selected_area) unless comment.comment_paragraph_selected_area.blank?
23 arr << hidden_field_tag('comment[comment_paragraph_selected_content]', comment.comment_paragraph_selected_content) unless comment.comment_paragraph_selected_content.blank? 23 arr << hidden_field_tag('comment[comment_paragraph_selected_content]', comment.comment_paragraph_selected_content) unless comment.comment_paragraph_selected_content.blank?
24 arr 24 arr
@@ -50,22 +50,22 @@ class CommentParagraphPlugin &lt; Noosfero::Plugin @@ -50,22 +50,22 @@ class CommentParagraphPlugin &lt; Noosfero::Plugin
50 # if !@article.id.blank? && self.auto_marking_enabled?(settings, @article.class.name) 50 # if !@article.id.blank? && self.auto_marking_enabled?(settings, @article.class.name)
51 # 51 #
52 # parsed_paragraphs = [] 52 # parsed_paragraphs = []
53 -# paragraph_id = 0 53 +# paragraph_uuid = 0
54 # 54 #
55 # doc = Hpricot(@article.body) 55 # doc = Hpricot(@article.body)
56 # paragraphs = doc.search("/*").each do |paragraph| 56 # paragraphs = doc.search("/*").each do |paragraph|
57 # 57 #
58 -# if paragraph.to_html =~ /^<div(.*)paragraph_comment(.*)$/ || paragraph.to_html =~ /^<p>\W<\/p>$/ 58 +# if paragraph.to_html =~ /^<div(.*)paragraph_comment(.*)$/ || paragraph.t o_html =~ /^<p>\W<\/p>$/
59 # parsed_paragraphs << paragraph.to_html 59 # parsed_paragraphs << paragraph.to_html
60 # else 60 # else
61 # if paragraph.to_html =~ /^(<div|<table|<p|<ul).*/ 61 # if paragraph.to_html =~ /^(<div|<table|<p|<ul).*/
62 -# parsed_paragraphs << CommentParagraphPlugin.parse_paragraph(paragraph.to_html, paragraph_id) 62 +# parsed_paragraphs << CommentParagraphPlugin.parse_paragraph(paragraph.to_html, paragraph_uuid)
63 # else 63 # else
64 # parsed_paragraphs << paragraph.to_html 64 # parsed_paragraphs << paragraph.to_html
65 # end 65 # end
66 # end 66 # end
67 # 67 #
68 -# paragraph_id += 1 68 +# paragraph_uuid += 1
69 # 69 #
70 # end 70 # end
71 # 71 #
@@ -82,10 +82,10 @@ class CommentParagraphPlugin &lt; Noosfero::Plugin @@ -82,10 +82,10 @@ class CommentParagraphPlugin &lt; Noosfero::Plugin
82 # end 82 # end
83 83
84 84
85 - def self.parse_paragraph( paragraph_content, paragraph_id ) 85 + def self.parse_paragraph( paragraph_content, paragraph_uuid )
86 "<div class='macro article_comments paragraph_comment' " + 86 "<div class='macro article_comments paragraph_comment' " +
87 "data-macro='comment_paragraph_plugin/allow_comment' " + 87 "data-macro='comment_paragraph_plugin/allow_comment' " +
88 - "data-macro-paragraph_id='#{paragraph_id}'>#{paragraph_content}</div>\r\n" + 88 + "data-macro-paragraph_uuid='#{paragraph_uuid}'>#{paragraph_content}</div>\r\n" +
89 "<p>&nbsp;</p>" 89 "<p>&nbsp;</p>"
90 end 90 end
91 91
plugins/comment_paragraph/lib/comment_paragraph_plugin/macros/allow_comment.rb
1 #FIXME See a better way to generalize this parameter. 1 #FIXME See a better way to generalize this parameter.
2 -ActionView::Base.sanitized_allowed_attributes += ['data-macro', 'data-macro-paragraph_id'] 2 +ActionView::Base.sanitized_allowed_attributes += ['data-macro', 'data-macro-paragraph_uuid']
3 3
4 class CommentParagraphPlugin::AllowComment < Noosfero::Plugin::Macro 4 class CommentParagraphPlugin::AllowComment < Noosfero::Plugin::Macro
5 def self.configuration 5 def self.configuration
@@ -12,13 +12,13 @@ class CommentParagraphPlugin::AllowComment &lt; Noosfero::Plugin::Macro @@ -12,13 +12,13 @@ class CommentParagraphPlugin::AllowComment &lt; Noosfero::Plugin::Macro
12 end 12 end
13 13
14 def parse(params, inner_html, source) 14 def parse(params, inner_html, source)
15 - paragraph_id = params[:paragraph_id].to_i 15 + paragraph_uuid = params[:paragraph_uuid]
16 article = source 16 article = source
17 - count = article.paragraph_comments.without_spam.in_paragraph(paragraph_id).count 17 + count = article.paragraph_comments.without_spam.in_paragraph(paragraph_uuid).count
18 18
19 proc { 19 proc {
20 render :partial => 'comment_paragraph_plugin_profile/comment_paragraph', 20 render :partial => 'comment_paragraph_plugin_profile/comment_paragraph',
21 - :locals => {:paragraph_id => paragraph_id, :article_id => article.id, :inner_html => inner_html, :count => count, :profile_identifier => article.profile.identifier } 21 + :locals => {:paragraph_uuid => paragraph_uuid, :article_id => article.id, :inner_html => inner_html, :count => count, :profile_identifier => article.profile.identifier }
22 } 22 }
23 end 23 end
24 end 24 end
plugins/comment_paragraph/lib/ext/comment.rb
@@ -2,17 +2,17 @@ require_dependency &#39;comment&#39; @@ -2,17 +2,17 @@ require_dependency &#39;comment&#39;
2 2
3 class Comment 3 class Comment
4 4
5 - scope :without_paragraph, :conditions => {:paragraph_id => nil } 5 + scope :without_paragraph, :conditions => {:paragraph_uuid => nil }
6 6
7 settings_items :comment_paragraph_selected_area, :type => :string 7 settings_items :comment_paragraph_selected_area, :type => :string
8 settings_items :comment_paragraph_selected_content, :type => :string 8 settings_items :comment_paragraph_selected_content, :type => :string
9 9
10 - scope :in_paragraph, proc { |paragraph_id| {  
11 - :conditions => ['paragraph_id = ?', paragraph_id] 10 + scope :in_paragraph, proc { |paragraph_uuid| {
  11 + :conditions => ['paragraph_uuid = ?', paragraph_uuid]
12 } 12 }
13 } 13 }
14 14
15 - attr_accessible :paragraph_id, :comment_paragraph_selected_area, :id, :comment_paragraph_selected_content 15 + attr_accessible :paragraph_uuid, :comment_paragraph_selected_area, :id, :comment_paragraph_selected_content
16 16
17 before_validation do |comment| 17 before_validation do |comment|
18 comment.comment_paragraph_selected_area = nil if comment.comment_paragraph_selected_area.blank? 18 comment.comment_paragraph_selected_area = nil if comment.comment_paragraph_selected_area.blank?
plugins/comment_paragraph/public/comment_paragraph.js
@@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
47 // jQuery('#article_body_ifr').contents().find('body').children('p,table,img').each(function( index ) { 47 // jQuery('#article_body_ifr').contents().find('body').children('p,table,img').each(function( index ) {
48 // text=jQuery(this).prop('outerHTML'); 48 // text=jQuery(this).prop('outerHTML');
49 // if(text!="" && text!=" " && text!="<br>"){ 49 // if(text!="" && text!=" " && text!="<br>"){
50 -// paragraphsTxt+='<div class="macro article_comments paragraph_comment" data-macro="comment_paragraph_plugin/allow_comment" data-macro-paragraph_id="' + index + '">' + text + '</div><br>' 50 +// paragraphsTxt+='<div class="macro article_comments paragraph_comment" data-macro="comment_paragraph_plugin/allow_comment" data-macro-paragraph_uuid="' + index + '">' + text + '</div><br>'
51 // } 51 // }
52 // }); 52 // });
53 // tinyMCE.activeEditor.setContent(paragraphsTxt); 53 // tinyMCE.activeEditor.setContent(paragraphsTxt);
plugins/comment_paragraph/public/comment_paragraph_macro.js
@@ -20,9 +20,9 @@ jQuery(document).ready(function($) { @@ -20,9 +20,9 @@ jQuery(document).ready(function($) {
20 20
21 all_paragraphs = $('.comment_paragraph'); 21 all_paragraphs = $('.comment_paragraph');
22 all_paragraphs.each( function(paragraph) { 22 all_paragraphs.each( function(paragraph) {
23 - var paragraph_id = $( all_paragraphs.get(paragraph) ).attr('data-paragraph'); 23 + var paragraph_uuid = $( all_paragraphs.get(paragraph) ).attr('data-paragraph');
24 var paragraph_content = all_paragraphs.get(paragraph).innerHTML; 24 var paragraph_content = all_paragraphs.get(paragraph).innerHTML;
25 - original_paragraphs.push( { id: paragraph_id, content: paragraph_content } ); 25 + original_paragraphs.push( { id: paragraph_uuid, content: paragraph_content } );
26 }); 26 });
27 27
28 $(document).keyup(function(e) { 28 $(document).keyup(function(e) {
@@ -248,8 +248,8 @@ jQuery(document).ready(function($) { @@ -248,8 +248,8 @@ jQuery(document).ready(function($) {
248 248
249 $(document).on('mouseenter', 'li.article-comment', function() { 249 $(document).on('mouseenter', 'li.article-comment', function() {
250 var selected_area = $(this).find('input.paragraph_comment_area').val(); 250 var selected_area = $(this).find('input.paragraph_comment_area').val();
251 - var paragraph_id = $(this).find('input.paragraph_id').val();  
252 - var rootElement = $('#comment_paragraph_' + paragraph_id).get(0); 251 + var paragraph_uuid = $(this).find('input.paragraph_uuid').val();
  252 + var rootElement = $('#comment_paragraph_' + paragraph_uuid).get(0);
253 253
254 if(selected_area != ""){ 254 if(selected_area != ""){
255 rangy.deserializeSelection(selected_area, rootElement); 255 rangy.deserializeSelection(selected_area, rootElement);
@@ -258,11 +258,11 @@ jQuery(document).ready(function($) { @@ -258,11 +258,11 @@ jQuery(document).ready(function($) {
258 }); 258 });
259 259
260 $(document).on('mouseleave', 'li.article-comment', function() { 260 $(document).on('mouseleave', 'li.article-comment', function() {
261 - var paragraph_id = $(this).find('input.paragraph_id').val();  
262 - var rootElement = $('#comment_paragraph_'+ paragraph_id).get(0); 261 + var paragraph_uuid = $(this).find('input.paragraph_uuid').val();
  262 + var rootElement = $('#comment_paragraph_'+ paragraph_uuid).get(0);
263 263
264 original_paragraphs.each( function(paragraph) { 264 original_paragraphs.each( function(paragraph) {
265 - if (paragraph.id == paragraph_id) { 265 + if (paragraph.id == paragraph_uuid) {
266 rootElement.innerHTML = paragraph.content; 266 rootElement.innerHTML = paragraph.content;
267 } 267 }
268 }); 268 });
plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb
@@ -19,28 +19,28 @@ class CommentParagraphPluginProfileControllerTest &lt; ActionController::TestCase @@ -19,28 +19,28 @@ class CommentParagraphPluginProfileControllerTest &lt; ActionController::TestCase
19 attr_reader :profile 19 attr_reader :profile
20 20
21 should 'be able to show paragraph comments' do 21 should 'be able to show paragraph comments' do
22 - comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_id => 0)  
23 - xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :paragraph_id => 0 22 + comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_uuid => 0)
  23 + xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :paragraph_uuid => 0
24 assert_template 'comment_paragraph_plugin_profile/view_comments' 24 assert_template 'comment_paragraph_plugin_profile/view_comments'
25 assert_match /comments_list_paragraph_0/, @response.body 25 assert_match /comments_list_paragraph_0/, @response.body
26 assert_match /\"comment-count-0\", \"1\"/, @response.body 26 assert_match /\"comment-count-0\", \"1\"/, @response.body
27 end 27 end
28 28
29 should 'do not show global comments' do 29 should 'do not show global comments' do
30 - fast_create(Comment, :source_id => article, :author_id => profile, :title => 'global comment', :body => 'global', :paragraph_id => nil)  
31 - fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_id => 0)  
32 - xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :paragraph_id => 0 30 + fast_create(Comment, :source_id => article, :author_id => profile, :title => 'global comment', :body => 'global', :paragraph_uuid => nil)
  31 + fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_uuid => 0)
  32 + xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :paragraph_uuid => 0
33 assert_template 'comment_paragraph_plugin_profile/view_comments' 33 assert_template 'comment_paragraph_plugin_profile/view_comments'
34 assert_match /comments_list_paragraph_0/, @response.body 34 assert_match /comments_list_paragraph_0/, @response.body
35 assert_match /\"comment-count-0\", \"1\"/, @response.body 35 assert_match /\"comment-count-0\", \"1\"/, @response.body
36 end 36 end
37 37
38 should 'be able to show all comments of a paragraph' do 38 should 'be able to show all comments of a paragraph' do
39 - comment1 = fast_create(Comment, :created_at => Time.now - 1.days, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'a comment', :paragraph_id => 0)  
40 - comment2 = fast_create(Comment, :created_at => Time.now - 2.days, :source_id => article, :author_id => profile, :title => 'b comment', :body => 'b comment', :paragraph_id => 0)  
41 - comment3 = fast_create(Comment, :created_at => Time.now - 3.days, :source_id => article, :author_id => profile, :title => 'c comment', :body => 'c comment', :paragraph_id => 0)  
42 - comment4 = fast_create(Comment, :created_at => Time.now - 4.days, :source_id => article, :author_id => profile, :title => 'd comment', :body => 'd comment', :paragraph_id => 0)  
43 - xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :paragraph_id => 0 39 + comment1 = fast_create(Comment, :created_at => Time.now - 1.days, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'a comment', :paragraph_uuid => 0)
  40 + comment2 = fast_create(Comment, :created_at => Time.now - 2.days, :source_id => article, :author_id => profile, :title => 'b comment', :body => 'b comment', :paragraph_uuid => 0)
  41 + comment3 = fast_create(Comment, :created_at => Time.now - 3.days, :source_id => article, :author_id => profile, :title => 'c comment', :body => 'c comment', :paragraph_uuid => 0)
  42 + comment4 = fast_create(Comment, :created_at => Time.now - 4.days, :source_id => article, :author_id => profile, :title => 'd comment', :body => 'd comment', :paragraph_uuid => 0)
  43 + xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :paragraph_uuid => 0
44 assert_match /a comment/, @response.body 44 assert_match /a comment/, @response.body
45 assert_match /b comment/, @response.body 45 assert_match /b comment/, @response.body
46 assert_match /c comment/, @response.body 46 assert_match /c comment/, @response.body
plugins/comment_paragraph/test/functional/comment_paragraph_plugin_public_controller_test.rb
@@ -20,17 +20,17 @@ class CommentParagraphPluginPublicControllerTest &lt; ActionController::TestCase @@ -20,17 +20,17 @@ class CommentParagraphPluginPublicControllerTest &lt; ActionController::TestCase
20 attr_reader :profile 20 attr_reader :profile
21 21
22 22
23 - should 'be able to return paragraph_id for a comment' do  
24 - comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_id => 0) 23 + should 'be able to return paragraph_uuid for a comment' do
  24 + comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_uuid => 0)
25 cid = comment.id 25 cid = comment.id
26 xhr :get, :comment_paragraph, :id => cid 26 xhr :get, :comment_paragraph, :id => cid
27 - assert_match /\{\"paragraph_id\":0\}/, @response.body 27 + assert_match /\{\"paragraph_uuid\":0\}/, @response.body
28 end 28 end
29 29
30 - should 'return paragraph_id=null for a global comment' do 30 + should 'return paragraph_uuid=null for a global comment' do
31 comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala' ) 31 comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala' )
32 xhr :get, :comment_paragraph, :id => comment.id 32 xhr :get, :comment_paragraph, :id => comment.id
33 - assert_match /\{\"paragraph_id\":null\}/, @response.body 33 + assert_match /\{\"paragraph_uuid\":null\}/, @response.body
34 end 34 end
35 35
36 36
plugins/comment_paragraph/test/functional/content_viewer_controller_test.rb
@@ -11,7 +11,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase @@ -11,7 +11,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
11 11
12 def setup 12 def setup
13 @profile = fast_create(Community) 13 @profile = fast_create(Community)
14 - @page = fast_create(Article, :profile_id => @profile.id, :body => "<div class=\"macro\" data-macro-paragraph_id=\"0\" data-macro='comment_paragraph_plugin/allow_comment' ></div>") 14 + @page = fast_create(Article, :profile_id => @profile.id, :body => "<div class=\"macro\" data-macro-paragraph_uuid=\"0\" data-macro='comment_paragraph_plugin/allow_comment' ></div>")
15 @environment = Environment.default 15 @environment = Environment.default
16 @environment.enable_plugin(CommentParagraphPlugin) 16 @environment.enable_plugin(CommentParagraphPlugin)
17 end 17 end
@@ -19,7 +19,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase @@ -19,7 +19,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
19 attr_reader :page 19 attr_reader :page
20 20
21 should 'parse article body and render comment paragraph view' do 21 should 'parse article body and render comment paragraph view' do
22 - comment1 = fast_create(Comment, :paragraph_id => 0, :source_id => page.id) 22 + comment1 = fast_create(Comment, :paragraph_uuid => 0, :source_id => page.id)
23 get :view_page, @page.url 23 get :view_page, @page.url
24 assert_tag 'div', :attributes => {:class => 'comment_paragraph'} 24 assert_tag 'div', :attributes => {:class => 'comment_paragraph'}
25 end 25 end
plugins/comment_paragraph/test/unit/allow_comment_test.rb
@@ -15,11 +15,11 @@ class AllowCommentTest &lt; ActiveSupport::TestCase @@ -15,11 +15,11 @@ class AllowCommentTest &lt; ActiveSupport::TestCase
15 should 'parse contents to include comment paragraph view' do 15 should 'parse contents to include comment paragraph view' do
16 profile = fast_create(Community) 16 profile = fast_create(Community)
17 article = fast_create(Article, :profile_id => profile.id) 17 article = fast_create(Article, :profile_id => profile.id)
18 - comment = fast_create(Comment, :paragraph_id => 1, :source_id => article.id) 18 + comment = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id)
19 inner_html = 'inner' 19 inner_html = 'inner'
20 - content = macro.parse({:paragraph_id => comment.paragraph_id}, inner_html, article) 20 + content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, inner_html, article)
21 21
22 - expects(:render).with({:partial => 'comment_paragraph_plugin_profile/comment_paragraph', :locals => {:paragraph_id => comment.paragraph_id, :article_id => article.id, :inner_html => inner_html, :count => 1, :profile_identifier => profile.identifier} }) 22 + expects(:render).with({:partial => 'comment_paragraph_plugin_profile/comment_paragraph', :locals => {:paragraph_uuid => comment.paragraph_uuid, :article_id => article.id, :inner_html => inner_html, :count => 1, :profile_identifier => profile.identifier} })
23 instance_eval(&content) 23 instance_eval(&content)
24 end 24 end
25 25
plugins/comment_paragraph/test/unit/article_test.rb
@@ -11,14 +11,14 @@ class ArticleTest &lt; ActiveSupport::TestCase @@ -11,14 +11,14 @@ class ArticleTest &lt; ActiveSupport::TestCase
11 attr_reader :article 11 attr_reader :article
12 12
13 should 'return paragraph comments from article' do 13 should 'return paragraph comments from article' do
14 - comment1 = fast_create(Comment, :paragraph_id => 1, :source_id => article.id)  
15 - comment2 = fast_create(Comment, :paragraph_id => nil, :source_id => article.id) 14 + comment1 = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id)
  15 + comment2 = fast_create(Comment, :paragraph_uuid => nil, :source_id => article.id)
16 assert_equal [comment1], article.paragraph_comments 16 assert_equal [comment1], article.paragraph_comments
17 end 17 end
18 18
19 should 'allow save if comment paragraph macro is not removed for paragraph with comments' do 19 should 'allow save if comment paragraph macro is not removed for paragraph with comments' do
20 - article.body = "<div class=\"macro\" data-macro-paragraph_id=0></div>"  
21 - comment1 = fast_create(Comment, :paragraph_id => 0, :source_id => article.id) 20 + article.body = "<div class=\"macro\" data-macro-paragraph_uuid=0></div>"
  21 + comment1 = fast_create(Comment, :paragraph_uuid => 0, :source_id => article.id)
22 assert article.save 22 assert article.save
23 end 23 end
24 24
plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb
@@ -29,9 +29,9 @@ class CommentParagraphPluginTest &lt; ActiveSupport::TestCase @@ -29,9 +29,9 @@ class CommentParagraphPluginTest &lt; ActiveSupport::TestCase
29 should 'not add comment_paragraph_selected_area if comment_paragraph_selected_area is blank' do 29 should 'not add comment_paragraph_selected_area if comment_paragraph_selected_area is blank' do
30 comment = Comment.new 30 comment = Comment.new
31 comment.comment_paragraph_selected_area = "" 31 comment.comment_paragraph_selected_area = ""
32 - comment.paragraph_id = 2 32 + comment.paragraph_uuid = 2
33 cpp = CommentParagraphPlugin.new 33 cpp = CommentParagraphPlugin.new
34 - prok = cpp.comment_form_extra_contents({:comment=>comment, :paragraph_id=>4}) 34 + prok = cpp.comment_form_extra_contents({:comment=>comment, :paragraph_uuid=>4})
35 assert_nil /comment_paragraph_selected_area/.match(prok.call.inspect) 35 assert_nil /comment_paragraph_selected_area/.match(prok.call.inspect)
36 end 36 end
37 37
plugins/comment_paragraph/test/unit/comment_test.rb
@@ -10,16 +10,16 @@ class CommentTest &lt; ActiveSupport::TestCase @@ -10,16 +10,16 @@ class CommentTest &lt; ActiveSupport::TestCase
10 attr_reader :article 10 attr_reader :article
11 11
12 should 'return comments that belongs to a specified paragraph' do 12 should 'return comments that belongs to a specified paragraph' do
13 - comment1 = fast_create(Comment, :paragraph_id => 1, :source_id => article.id)  
14 - comment2 = fast_create(Comment, :paragraph_id => nil, :source_id => article.id)  
15 - comment3 = fast_create(Comment, :paragraph_id => 2, :source_id => article.id) 13 + comment1 = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id)
  14 + comment2 = fast_create(Comment, :paragraph_uuid => nil, :source_id => article.id)
  15 + comment3 = fast_create(Comment, :paragraph_uuid => 2, :source_id => article.id)
16 assert_equal [comment1], article.comments.in_paragraph(1) 16 assert_equal [comment1], article.comments.in_paragraph(1)
17 end 17 end
18 18
19 should 'return comments that do not belongs to any paragraph' do 19 should 'return comments that do not belongs to any paragraph' do
20 - comment1 = fast_create(Comment, :paragraph_id => 1, :source_id => article.id)  
21 - comment2 = fast_create(Comment, :paragraph_id => nil, :source_id => article.id)  
22 - comment3 = fast_create(Comment, :paragraph_id => 2, :source_id => article.id) 20 + comment1 = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id)
  21 + comment2 = fast_create(Comment, :paragraph_uuid => nil, :source_id => article.id)
  22 + comment3 = fast_create(Comment, :paragraph_uuid => 2, :source_id => article.id)
23 assert_equal [comment2], article.comments.without_paragraph 23 assert_equal [comment2], article.comments.without_paragraph
24 end 24 end
25 25
plugins/comment_paragraph/views/comment/comment_extra.html.erb
1 <input type="hidden" value="<%= comment.comment_paragraph_selected_area%>" class="paragraph_comment_area" /> 1 <input type="hidden" value="<%= comment.comment_paragraph_selected_area%>" class="paragraph_comment_area" />
2 -<input type="hidden" value="<%= comment.paragraph_id%>" class="paragraph_id" /><input type="hidden" value="<%= comment.comment_paragraph_selected_content%>" class="paragraph_selected_content" /> 2 +<input type="hidden" value="<%= comment.paragraph_uuid%>" class="paragraph_uuid" /><input type="hidden" value="<%= comment.comment_paragraph_selected_content%>" class="paragraph_selected_content" />
3 <input type="hidden" value="<%= comment.comment_paragraph_selected_content%>" class="paragraph_selected_content" /> 3 <input type="hidden" value="<%= comment.comment_paragraph_selected_content%>" class="paragraph_selected_content" />
plugins/comment_paragraph/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb
1 <table class="comments"> 1 <table class="comments">
2 <tr> 2 <tr>
3 <td> 3 <td>
4 - <div class="comment_paragraph" id="comment_paragraph_<%= paragraph_id %>" data-paragraph="<%= paragraph_id %>"> 4 + <div class="comment_paragraph" id="comment_paragraph_<%= paragraph_uuid %>" data-paragraph="<%= paragraph_uuid %>">
5 <%= inner_html %> 5 <%= inner_html %>
6 </div> 6 </div>
7 </td> 7 </td>
8 <td> 8 <td>
9 - <div align="center" class="side-comments-counter" id="side_comments_counter_<%= paragraph_id %>" data-paragraph="<%= paragraph_id %>" style="vertical-align: middle; padding-left: 3px; padding-right: 5px;">  
10 - <span id="comment-count-<%= paragraph_id %>" class='comment-count'> 9 + <div align="center" class="side-comments-counter" id="side_comments_counter_<%= paragraph_uuid %>" data-paragraph="<%= paragraph_uuid %>" style="vertical-align: middle; padding-left: 3px; padding-right: 5px;">
  10 + <span id="comment-count-<%= paragraph_uuid %>" class='comment-count'>
11 <%= count %> 11 <%= count %>
12 </span> 12 </span>
13 </div> 13 </div>
@@ -15,28 +15,28 @@ @@ -15,28 +15,28 @@
15 <td> 15 <td>
16 <div class="comment-paragraph-group-comments"> 16 <div class="comment-paragraph-group-comments">
17 <%= 17 <%=
18 - url = { :profile => profile_identifier, :controller => 'comment_paragraph_plugin_profile', :action => 'view_comments', :paragraph_id => paragraph_id, :article_id => article_id} 18 + url = { :profile => profile_identifier, :controller => 'comment_paragraph_plugin_profile', :action => 'view_comments', :paragraph_uuid => paragraph_uuid, :article_id => article_id}
19 link_to_remote( 19 link_to_remote(
20 '', 20 '',
21 { 21 {
22 :url => url, 22 :url => url,
23 :method => :post, 23 :method => :post,
24 - :condition => "!toggleParagraph(#{paragraph_id})",  
25 - :complete => "loadCompleted(#{paragraph_id})" 24 + :condition => "!toggleParagraph(#{paragraph_uuid})",
  25 + :complete => "loadCompleted(#{paragraph_uuid})"
26 }, 26 },
27 { 27 {
28 - :id => "link_to_ajax_comments_#{paragraph_id}", 28 + :id => "link_to_ajax_comments_#{paragraph_uuid}",
29 :'data-url' => url_for(url) 29 :'data-url' => url_for(url)
30 } 30 }
31 )%> 31 )%>
32 32
33 - <div class="side-comment" id="side_comment_<%= paragraph_id %>" data-paragraph="<%= paragraph_id %>" style="display:none">  
34 - <div class="comment-paragraph-loading-<%= paragraph_id %>">  
35 - <div class="comments_list_toggle_paragraph_<%= paragraph_id %>" >  
36 - <div class="article-comments-list" id="comments_list_paragraph_<%= paragraph_id %>"></div>  
37 - <div class ="article-comments-list-more" id="comments_list_paragraph_<%= paragraph_id %>_more"></div>  
38 - <div id="page-comment-form-<%= paragraph_id %>" class='post_comment_box closed'>  
39 - <%= render :partial => 'comment/comment_form', :locals => {:comment => Comment.new, :display_link => true, :cancel_triggers_hide => true, :paragraph_id => paragraph_id}%> 33 + <div class="side-comment" id="side_comment_<%= paragraph_uuid %>" data-paragraph="<%= paragraph_uuid %>" style="display:none">
  34 + <div class="comment-paragraph-loading-<%= paragraph_uuid %>">
  35 + <div class="comments_list_toggle_paragraph_<%= paragraph_uuid %>" >
  36 + <div class="article-comments-list" id="comments_list_paragraph_<%= paragraph_uuid %>"></div>
  37 + <div class ="article-comments-list-more" id="comments_list_paragraph_<%= paragraph_uuid %>_more"></div>
  38 + <div id="page-comment-form-<%= paragraph_uuid %>" class='post_comment_box closed'>
  39 + <%= render :partial => 'comment/comment_form', :locals => {:comment => Comment.new, :display_link => true, :cancel_triggers_hide => true, :paragraph_uuid => paragraph_uuid}%>
40 </div> 40 </div>
41 </div> 41 </div>
42 </div> 42 </div>
plugins/comment_paragraph/views/comment_paragraph_plugin_profile/view_comments.rjs
1 -page.replace_html "comments_list_paragraph_#{@paragraph_id}", :partial => 'comment/comment.html.erb', :collection => @comments  
2 -page.replace_html "comment-count-#{@paragraph_id}", @comments_count 1 +page.replace_html "comments_list_paragraph_#{@paragraph_uuid}", :partial => 'comment/comment.html.erb', :collection => @comments
  2 +page.replace_html "comment-count-#{@paragraph_uuid}", @comments_count