Commit 604eb3f6bb8d6ad9515ea0d596ae29b1d51d87bb
1 parent
3b83c471
Exists in
master
and in
22 other branches
plugins-infra: add infra support to core extensions
The core extensions now should be created inside the folder lib/ext. They will automatically loaded, so no need for the requires on the plugin class definition file. Further information on how to use this feature here: http://noosfero.org/Development/PluginsArchitecture#Extending_core_classes
Showing
31 changed files
with
75 additions
and
104 deletions
Show diff stats
lib/noosfero/plugin.rb
@@ -64,6 +64,9 @@ class Noosfero::Plugin | @@ -64,6 +64,9 @@ class Noosfero::Plugin | ||
64 | require init.gsub(/.rb$/, '') if File.file? init | 64 | require init.gsub(/.rb$/, '') if File.file? init |
65 | end | 65 | end |
66 | 66 | ||
67 | + # load extensions | ||
68 | + Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file } | ||
69 | + | ||
67 | # load class | 70 | # load class |
68 | klass(plugin_name) | 71 | klass(plugin_name) |
69 | end | 72 | end |
plugins/bsc/lib/bsc_plugin.rb
plugins/comment_group/lib/comment_group_plugin.rb
plugins/comment_group/lib/comment_group_plugin/ext/article.rb
@@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
1 | -require_dependency 'article' | ||
2 | - | ||
3 | -class Article | ||
4 | - | ||
5 | - #FIXME make this test | ||
6 | - has_many :group_comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc', :conditions => [ 'group_id IS NOT NULL'] | ||
7 | - | ||
8 | - #FIXME make this test | ||
9 | - validate :not_empty_group_comments_removed | ||
10 | - | ||
11 | - #FIXME make this test | ||
12 | - def not_empty_group_comments_removed | ||
13 | - if body | ||
14 | - groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq | ||
15 | - groups = Hpricot(body.to_s).search('.macro').collect{|element| element['data-macro-group_id'].to_i} | ||
16 | - errors.add_to_base(N_('Not empty group comment cannot be removed')) unless (groups_with_comments-groups).empty? | ||
17 | - end | ||
18 | - end | ||
19 | - | ||
20 | -end | ||
21 | - |
plugins/comment_group/lib/comment_group_plugin/ext/comment.rb
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +require_dependency 'article' | ||
2 | + | ||
3 | +class Article | ||
4 | + | ||
5 | + #FIXME make this test | ||
6 | + has_many :group_comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc', :conditions => [ 'group_id IS NOT NULL'] | ||
7 | + | ||
8 | + #FIXME make this test | ||
9 | + validate :not_empty_group_comments_removed | ||
10 | + | ||
11 | + #FIXME make this test | ||
12 | + def not_empty_group_comments_removed | ||
13 | + if body | ||
14 | + groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq | ||
15 | + groups = Hpricot(body.to_s).search('.macro').collect{|element| element['data-macro-group_id'].to_i} | ||
16 | + errors.add_to_base(N_('Not empty group comment cannot be removed')) unless (groups_with_comments-groups).empty? | ||
17 | + end | ||
18 | + end | ||
19 | + | ||
20 | +end | ||
21 | + |
plugins/custom_forms/lib/custom_forms_plugin.rb
plugins/foo/lib/foo_plugin.rb
plugins/foo/lib/foo_plugin/ext/profile.rb
plugins/google_analytics/lib/google_analytics_plugin.rb
plugins/ldap/lib/ldap_plugin.rb
1 | -require_dependency File.dirname(__FILE__) + '/ext/environment' | ||
2 | require File.dirname(__FILE__) + '/ldap_authentication.rb' | 1 | require File.dirname(__FILE__) + '/ldap_authentication.rb' |
3 | 2 | ||
4 | - | ||
5 | class LdapPlugin < Noosfero::Plugin | 3 | class LdapPlugin < Noosfero::Plugin |
6 | 4 | ||
7 | def self.plugin_name | 5 | def self.plugin_name |
plugins/pg_search/lib/pg_search_plugin.rb
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin/ext/profile.rb
plugins/shopping_cart/lib/shopping_cart_plugin.rb
plugins/shopping_cart/lib/shopping_cart_plugin/ext/enterprise.rb
plugins/shopping_cart/lib/shopping_cart_plugin/ext/person.rb
plugins/solr/lib/solr_plugin.rb
plugins/stoa/lib/stoa_plugin.rb
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +require_dependency 'organization' | ||
2 | +class Organization | ||
3 | + settings_items :sub_organizations_plugin_parent_to_be | ||
4 | + | ||
5 | + after_create do |organization| | ||
6 | + if organization.sub_organizations_plugin_parent_to_be.present? | ||
7 | + parent = Organization.find(organization.sub_organizations_plugin_parent_to_be) | ||
8 | + SubOrganizationsPlugin::Relation.add_children(parent,organization) | ||
9 | + end | ||
10 | + end | ||
11 | + | ||
12 | + FIELDS << 'sub_organizations_plugin_parent_to_be' | ||
13 | +end |
plugins/sub_organizations/lib/sub_organizations_plugin.rb
plugins/sub_organizations/lib/sub_organizations_plugin/ext/create_enterprise.rb
plugins/sub_organizations/lib/sub_organizations_plugin/ext/organization.rb
@@ -1,13 +0,0 @@ | @@ -1,13 +0,0 @@ | ||
1 | -require_dependency 'organization' | ||
2 | -class Organization | ||
3 | - settings_items :sub_organizations_plugin_parent_to_be | ||
4 | - | ||
5 | - after_create do |organization| | ||
6 | - if organization.sub_organizations_plugin_parent_to_be.present? | ||
7 | - parent = Organization.find(organization.sub_organizations_plugin_parent_to_be) | ||
8 | - SubOrganizationsPlugin::Relation.add_children(parent,organization) | ||
9 | - end | ||
10 | - end | ||
11 | - | ||
12 | - FIELDS << 'sub_organizations_plugin_parent_to_be' | ||
13 | -end |
plugins/tolerance_time/lib/tolerance_time_plugin.rb
plugins/work_assignment/lib/work_assignment_plugin.rb