diff --git a/app/helpers/macros_helper.rb b/app/helpers/macros_helper.rb index 8cf8bbf..9e9c7d0 100644 --- a/app/helpers/macros_helper.rb +++ b/app/helpers/macros_helper.rb @@ -6,13 +6,12 @@ module MacrosHelper def macros_with_buttons @plugins.dispatch(:macros).reject{ |macro| !macro.configuration[:icon_path] } - end def macro_title(macro) macro.configuration[:title] || macro.name.humanize end - + def generate_macro_config_dialog(macro) if macro.configuration[:skip_dialog] "function(){#{macro_generator(macro)}}" @@ -55,7 +54,7 @@ module MacrosHelper end protected - + def macro_generator(macro) if macro.configuration[:generator] macro.configuration[:generator] diff --git a/app/views/shared/tiny_mce.rhtml b/app/views/shared/tiny_mce.rhtml index 28d5024..2314dfb 100644 --- a/app/views/shared/tiny_mce.rhtml +++ b/app/views/shared/tiny_mce.rhtml @@ -31,7 +31,7 @@ tinymce.create('tinymce.plugins.MacrosPlugin', { image : '/designs/icons/tango/Tango/16x16/emblems/emblem-system.png', icons : false }); - + <% macros_in_menu.each do |macro| %> c.onRenderMenu.add(function(c, m) { m.add({ @@ -40,7 +40,7 @@ tinymce.create('tinymce.plugins.MacrosPlugin', { }); }); <% end %> - + // Return the new menu button instance return c; <% end %> diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index d4de15e..fcb4a4d 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -147,7 +147,7 @@ class Noosfero::Plugin def macros self.class.constants.map do |constant_name| self.class.const_get(constant_name) - end.select {|klass| klass <= Noosfero::Plugin::Macro} + end.select {|klass| klass < Noosfero::Plugin::Macro} end # Here the developer may specify the events to which the plugins can diff --git a/lib/noosfero/plugin/manager.rb b/lib/noosfero/plugin/manager.rb index 987f049..f82f5d7 100644 --- a/lib/noosfero/plugin/manager.rb +++ b/lib/noosfero/plugin/manager.rb @@ -54,7 +54,7 @@ class Noosfero::Plugin::Manager end def parse_macro(macro_name, macro, source = nil) - macro_instance = enabled_macros[macro_name] || enabled_macros['default'] + macro_instance = enabled_macros[macro_name] || default_macro macro_instance.convert(macro, source) end @@ -64,10 +64,14 @@ class Noosfero::Plugin::Manager end end + def default_macro + @default_macro ||= Noosfero::Plugin::Macro.new(context) + end + def enabled_macros @enabled_macros ||= dispatch(:macros).inject({}) do |memo, macro| memo.merge!(macro.identifier => macro.new(context)) - end.merge('default' => Noosfero::Plugin::Macro.new(context)) + end end def [](name) diff --git a/plugins/comment_group/lib/comment_group_plugin.rb b/plugins/comment_group/lib/comment_group_plugin.rb index 1a8b0e9..56915fa 100644 --- a/plugins/comment_group/lib/comment_group_plugin.rb +++ b/plugins/comment_group/lib/comment_group_plugin.rb @@ -28,3 +28,5 @@ class CommentGroupPlugin < Noosfero::Plugin end end + +require_dependency 'comment_group_plugin/macros/allow_comment' diff --git a/plugins/comment_group/lib/comment_group_plugin/macros/allow_comment.rb b/plugins/comment_group/lib/comment_group_plugin/macros/allow_comment.rb index 5c6ab48..97c65c3 100644 --- a/plugins/comment_group/lib/comment_group_plugin/macros/allow_comment.rb +++ b/plugins/comment_group/lib/comment_group_plugin/macros/allow_comment.rb @@ -17,6 +17,6 @@ class CommentGroupPlugin::AllowComment < Noosfero::Plugin::Macro article = source count = article.group_comments.without_spam.in_group(group_id).count - lambda {render :partial => 'plugins/comment_group_macro/views/comment_group.rhtml', :locals => {:group_id => group_id, :article_id => article.id, :inner_html => inner_html, :count => count, :profile_identifier => article.profile.identifier }} + lambda {render :partial => 'plugins/comment_group/views/comment_group.rhtml', :locals => {:group_id => group_id, :article_id => article.id, :inner_html => inner_html, :count => count, :profile_identifier => article.profile.identifier }} end end diff --git a/plugins/comment_group/public/comment_group.js b/plugins/comment_group/public/comment_group.js index 96a3f31..7309295 100644 --- a/plugins/comment_group/public/comment_group.js +++ b/plugins/comment_group/public/comment_group.js @@ -29,7 +29,7 @@ function makeCommentable() { if(!hasTag) { tags = start.siblings().add(start); tags = tags.slice(tags.index(start), tags.index(end)>=0?tags.index(end)+1:tags.index(start)+1); - tags.wrapAll('
'); + tags.wrapAll('
'); contents = jQuery('#article_body_ifr').contents(); lastP = contents.find('p.article_comments_last_paragraph'); diff --git a/plugins/comment_group/public/comment_group_macro.js b/plugins/comment_group/public/comment_group_macro.js index a85966d..8aa7944 100644 --- a/plugins/comment_group/public/comment_group_macro.js +++ b/plugins/comment_group/public/comment_group_macro.js @@ -5,12 +5,12 @@ jQuery(document).ready(function($) { var val = anchor.split('-'); //anchor format = #comment-\d+ if(val.length!=2 || val[0]!='#comment') return; - if($('div[data-macro=display_comments]').length==0) return; //display_comments div must exists + if($('div[data-macro=comment_group_plugin/allow_comment]').length==0) return; //comment_group_plugin/allow_comment div must exists var comment_id = val[1]; if(!/^\d+$/.test(comment_id)) return; //test for integer comment_group_anchor = anchor; - var url = '/plugin/comment_group_macro/public/comment_group/'+comment_id; + var url = '/plugin/comment_group/public/comment_group/'+comment_id; $.getJSON(url, function(data) { if(data.group_id!=null) { var button = $('div.comment_group_'+ data.group_id + ' a'); diff --git a/plugins/comment_group/views/_comment_group.rhtml b/plugins/comment_group/views/_comment_group.rhtml index 1c25537..6aa2f74 100644 --- a/plugins/comment_group/views/_comment_group.rhtml +++ b/plugins/comment_group/views/_comment_group.rhtml @@ -1,7 +1,7 @@
- <%= link_to_remote(image_tag("/plugins/comment_group_macro/images/comments.gif"), + <%= link_to_remote(image_tag("/plugins/comment_group/images/comments.gif"), :url => { :profile => profile_identifier, :controller => 'comment_group_plugin_profile', :action => 'view_comments', :group_id => group_id, :article_id => article_id}, :loaded => visual_effect(:highlight, "comments_list_group_#{group_id}"), :method => :post, -- libgit2 0.21.2