Commit 92c207ee44c3afd5d35db5191ba70187fb1b29d9
1 parent
e7445aa3
Exists in
staging
and in
42 other branches
[macro-support-review] Adjusting details of the plugin to comply with core changes
Showing
9 changed files
with
18 additions
and
13 deletions
Show diff stats
app/helpers/macros_helper.rb
| ... | ... | @@ -6,13 +6,12 @@ module MacrosHelper |
| 6 | 6 | |
| 7 | 7 | def macros_with_buttons |
| 8 | 8 | @plugins.dispatch(:macros).reject{ |macro| !macro.configuration[:icon_path] } |
| 9 | - | |
| 10 | 9 | end |
| 11 | 10 | |
| 12 | 11 | def macro_title(macro) |
| 13 | 12 | macro.configuration[:title] || macro.name.humanize |
| 14 | 13 | end |
| 15 | - | |
| 14 | + | |
| 16 | 15 | def generate_macro_config_dialog(macro) |
| 17 | 16 | if macro.configuration[:skip_dialog] |
| 18 | 17 | "function(){#{macro_generator(macro)}}" |
| ... | ... | @@ -55,7 +54,7 @@ module MacrosHelper |
| 55 | 54 | end |
| 56 | 55 | |
| 57 | 56 | protected |
| 58 | - | |
| 57 | + | |
| 59 | 58 | def macro_generator(macro) |
| 60 | 59 | if macro.configuration[:generator] |
| 61 | 60 | macro.configuration[:generator] | ... | ... |
app/views/shared/tiny_mce.rhtml
| ... | ... | @@ -31,7 +31,7 @@ tinymce.create('tinymce.plugins.MacrosPlugin', { |
| 31 | 31 | image : '/designs/icons/tango/Tango/16x16/emblems/emblem-system.png', |
| 32 | 32 | icons : false |
| 33 | 33 | }); |
| 34 | - | |
| 34 | + | |
| 35 | 35 | <% macros_in_menu.each do |macro| %> |
| 36 | 36 | c.onRenderMenu.add(function(c, m) { |
| 37 | 37 | m.add({ |
| ... | ... | @@ -40,7 +40,7 @@ tinymce.create('tinymce.plugins.MacrosPlugin', { |
| 40 | 40 | }); |
| 41 | 41 | }); |
| 42 | 42 | <% end %> |
| 43 | - | |
| 43 | + | |
| 44 | 44 | // Return the new menu button instance |
| 45 | 45 | return c; |
| 46 | 46 | <% end %> | ... | ... |
lib/noosfero/plugin.rb
| ... | ... | @@ -147,7 +147,7 @@ class Noosfero::Plugin |
| 147 | 147 | def macros |
| 148 | 148 | self.class.constants.map do |constant_name| |
| 149 | 149 | self.class.const_get(constant_name) |
| 150 | - end.select {|klass| klass <= Noosfero::Plugin::Macro} | |
| 150 | + end.select {|klass| klass < Noosfero::Plugin::Macro} | |
| 151 | 151 | end |
| 152 | 152 | |
| 153 | 153 | # Here the developer may specify the events to which the plugins can | ... | ... |
lib/noosfero/plugin/manager.rb
| ... | ... | @@ -54,7 +54,7 @@ class Noosfero::Plugin::Manager |
| 54 | 54 | end |
| 55 | 55 | |
| 56 | 56 | def parse_macro(macro_name, macro, source = nil) |
| 57 | - macro_instance = enabled_macros[macro_name] || enabled_macros['default'] | |
| 57 | + macro_instance = enabled_macros[macro_name] || default_macro | |
| 58 | 58 | macro_instance.convert(macro, source) |
| 59 | 59 | end |
| 60 | 60 | |
| ... | ... | @@ -64,10 +64,14 @@ class Noosfero::Plugin::Manager |
| 64 | 64 | end |
| 65 | 65 | end |
| 66 | 66 | |
| 67 | + def default_macro | |
| 68 | + @default_macro ||= Noosfero::Plugin::Macro.new(context) | |
| 69 | + end | |
| 70 | + | |
| 67 | 71 | def enabled_macros |
| 68 | 72 | @enabled_macros ||= dispatch(:macros).inject({}) do |memo, macro| |
| 69 | 73 | memo.merge!(macro.identifier => macro.new(context)) |
| 70 | - end.merge('default' => Noosfero::Plugin::Macro.new(context)) | |
| 74 | + end | |
| 71 | 75 | end |
| 72 | 76 | |
| 73 | 77 | def [](name) | ... | ... |
plugins/comment_group/lib/comment_group_plugin.rb
plugins/comment_group/lib/comment_group_plugin/macros/allow_comment.rb
| ... | ... | @@ -17,6 +17,6 @@ class CommentGroupPlugin::AllowComment < Noosfero::Plugin::Macro |
| 17 | 17 | article = source |
| 18 | 18 | count = article.group_comments.without_spam.in_group(group_id).count |
| 19 | 19 | |
| 20 | - 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 }} | |
| 20 | + 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 }} | |
| 21 | 21 | end |
| 22 | 22 | end | ... | ... |
plugins/comment_group/public/comment_group.js
| ... | ... | @@ -29,7 +29,7 @@ function makeCommentable() { |
| 29 | 29 | if(!hasTag) { |
| 30 | 30 | tags = start.siblings().add(start); |
| 31 | 31 | tags = tags.slice(tags.index(start), tags.index(end)>=0?tags.index(end)+1:tags.index(start)+1); |
| 32 | - tags.wrapAll('<div class=\"macro article_comments\" data-macro=\"display_comments\" data-macro-group_id=\"'+getNextGroupId()+'\"/>'); | |
| 32 | + tags.wrapAll('<div class=\"macro article_comments\" data-macro=\"comment_group_plugin/allow_comment\" data-macro-group_id=\"'+getNextGroupId()+'\"/>'); | |
| 33 | 33 | |
| 34 | 34 | contents = jQuery('#article_body_ifr').contents(); |
| 35 | 35 | lastP = contents.find('p.article_comments_last_paragraph'); | ... | ... |
plugins/comment_group/public/comment_group_macro.js
| ... | ... | @@ -5,12 +5,12 @@ jQuery(document).ready(function($) { |
| 5 | 5 | |
| 6 | 6 | var val = anchor.split('-'); //anchor format = #comment-\d+ |
| 7 | 7 | if(val.length!=2 || val[0]!='#comment') return; |
| 8 | - if($('div[data-macro=display_comments]').length==0) return; //display_comments div must exists | |
| 8 | + if($('div[data-macro=comment_group_plugin/allow_comment]').length==0) return; //comment_group_plugin/allow_comment div must exists | |
| 9 | 9 | var comment_id = val[1]; |
| 10 | 10 | if(!/^\d+$/.test(comment_id)) return; //test for integer |
| 11 | 11 | |
| 12 | 12 | comment_group_anchor = anchor; |
| 13 | - var url = '/plugin/comment_group_macro/public/comment_group/'+comment_id; | |
| 13 | + var url = '/plugin/comment_group/public/comment_group/'+comment_id; | |
| 14 | 14 | $.getJSON(url, function(data) { |
| 15 | 15 | if(data.group_id!=null) { |
| 16 | 16 | var button = $('div.comment_group_'+ data.group_id + ' a'); | ... | ... |
plugins/comment_group/views/_comment_group.rhtml
| 1 | 1 | <div class="comments"> |
| 2 | 2 | <div class="comment_group_<%= group_id %>" style="float: left"> |
| 3 | 3 | <div style="float: left"> |
| 4 | - <%= link_to_remote(image_tag("/plugins/comment_group_macro/images/comments.gif"), | |
| 4 | + <%= link_to_remote(image_tag("/plugins/comment_group/images/comments.gif"), | |
| 5 | 5 | :url => { :profile => profile_identifier, :controller => 'comment_group_plugin_profile', :action => 'view_comments', :group_id => group_id, :article_id => article_id}, |
| 6 | 6 | :loaded => visual_effect(:highlight, "comments_list_group_#{group_id}"), |
| 7 | 7 | :method => :post, | ... | ... |