diff --git a/db/migrate/20140715201649_add_paragraph_id_to_comment.rb b/db/migrate/20140715201649_add_paragraph_id_to_comment.rb deleted file mode 100644 index 639f4ca..0000000 --- a/db/migrate/20140715201649_add_paragraph_id_to_comment.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddParagraphIdToComment < ActiveRecord::Migration - def self.up - add_column :comments, :paragraph_id, :integer unless column_exists?(:comments, :paragraph_id) - end - - def self.down - remove_column :comments, :paragraph_id - end -end diff --git a/db/migrate/20141223184902_add_paragraph_uuid_to_comments.rb b/db/migrate/20141223184902_add_paragraph_uuid_to_comments.rb new file mode 100644 index 0000000..1bc166d --- /dev/null +++ b/db/migrate/20141223184902_add_paragraph_uuid_to_comments.rb @@ -0,0 +1,6 @@ +class AddParagraphUuidToComments < ActiveRecord::Migration + def change + add_column :comments, :paragraph_uuid, :string unless column_exists?(:comments, :paragraph_uuid) + add_index :comments, :paragraph_uuid + end +end diff --git a/lib/comment_paragraph_plugin.rb b/lib/comment_paragraph_plugin.rb index 701e944..b9d7ca7 100644 --- a/lib/comment_paragraph_plugin.rb +++ b/lib/comment_paragraph_plugin.rb @@ -40,48 +40,47 @@ class CommentParagraphPlugin < Noosfero::Plugin true end - def cms_controller_filters - block = proc do - if params['commit'] == 'Save' +# def cms_controller_filters +# block = proc do +# if params['commit'] == 'Save' +# +# settings = Noosfero::Plugin::Settings.new(environment, CommentParagraphPlugin, params[:settings]) +# +# extend CommentParagraphPlugin::CommentParagraphHelper +# if !@article.id.blank? && self.auto_marking_enabled?(settings, @article.class.name) +# +# parsed_paragraphs = [] +# paragraph_id = 0 +# +# doc = Hpricot(@article.body) +# paragraphs = doc.search("/*").each do |paragraph| +# +# if paragraph.to_html =~ /^
') && ! element.startsWith('
"){ - paragraphsTxt+="
" + jQuery(this).html() + "
"; - } - foundCommentableParagraph = true; - }); - - //undo the paragraph comment tags - if(foundCommentableParagraph === true){ - tinyMCE.activeEditor.setContent(paragraphsTxt); - return; - } - - //Wraps the paragraph using the chosen class - jQuery('#article_body_ifr').contents().find('body').children('p,table,img').each(function( index ) { - text=jQuery(this).prop('outerHTML'); - if(text!="" && text!=" " && text!=""){ - paragraphsTxt+='
' - } - }); - tinyMCE.activeEditor.setContent(paragraphsTxt); - - //Workaround necessary to post the body of the article - tinymce.activeEditor.execCommand('mceInsertContent', false, " "); -} +//String.prototype.startsWith = function(needle){ +// return(this.indexOf(needle) == 0); +//}; +// +//function makeAllCommentable() { +// var paragraphsTxt=""; +// var selectedTextCount=0; +// var notSelectedTextCount=0; +// var text; +// +// //Search for text that is not selected in the middle of selected text, in this case unselect everything +// jQuery('#article_body_ifr').contents().find('body').children().each(function( index ) { +// //Check if there are other texts not selected +// var element=jQuery(this).prop('outerHTML'); +// if(element.startsWith('
') && ! element.startsWith('
"){ +// paragraphsTxt+="
" + jQuery(this).html() + "
"; +// } +// foundCommentableParagraph = true; +// }); +// +// //undo the paragraph comment tags +// if(foundCommentableParagraph === true){ +// tinyMCE.activeEditor.setContent(paragraphsTxt); +// return; +// } +// +// //Wraps the paragraph using the chosen class +// jQuery('#article_body_ifr').contents().find('body').children('p,table,img').each(function( index ) { +// text=jQuery(this).prop('outerHTML'); +// if(text!="" && text!=" " && text!=""){ +// paragraphsTxt+='
' +// } +// }); +// tinyMCE.activeEditor.setContent(paragraphsTxt); +// +// //Workaround necessary to post the body of the article +// tinymce.activeEditor.execCommand('mceInsertContent', false, " "); +//} -- libgit2 0.21.2