diff --git a/app/controllers/application.rb b/app/controllers/application.rb index da947e7..cd6ba4d 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -25,11 +25,6 @@ class ApplicationController < ActionController::Base helper :document helper :language - def boxes_editor? - false - end - protected :boxes_editor? - def self.no_design_blocks @no_design_blocks = true end @@ -106,6 +101,14 @@ class ApplicationController < ActionController::Base protected + def boxes_editor? + false + end + + def content_editor? + false + end + def user current_user.person if logged_in? end diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 00a2c1d..5ea3f86 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -383,5 +383,9 @@ class CmsController < MyProfileController @selected_locale = @article.language || FastGettext.locale end + def content_editor? + true + end + end diff --git a/app/controllers/my_profile/manage_products_controller.rb b/app/controllers/my_profile/manage_products_controller.rb index cc2d988..099fbaf 100644 --- a/app/controllers/my_profile/manage_products_controller.rb +++ b/app/controllers/my_profile/manage_products_controller.rb @@ -50,7 +50,7 @@ class ManageProductsController < ApplicationController render :partial => 'shared/redirect_via_javascript', :locals => { :url => url_for(:controller => 'manage_products', :action => 'show', :id => @product) } else - render :partial => 'shared/dialog_error_messages', :locals => { :object_name => 'product' } + render_dialog_error_messages 'product' end end end @@ -81,7 +81,7 @@ class ManageProductsController < ApplicationController render :partial => 'shared/redirect_via_javascript', :locals => { :url => url_for(:controller => 'manage_products', :action => 'show', :id => @product) } else - render :partial => 'shared/dialog_error_messages', :locals => { :object_name => 'product' } + render_dialog_error_messages 'product' end end end @@ -96,7 +96,7 @@ class ManageProductsController < ApplicationController @inputs = @product.inputs render :partial => 'display_inputs' else - render :partial => 'shared/dialog_error_messages', :locals => { :object_name => 'product' } + render_dialog_error_messages 'product' end else render :partial => 'add_input' @@ -147,7 +147,7 @@ class ManageProductsController < ApplicationController @inputs = @product.inputs render :partial => 'display_inputs' else - render :partial => 'shared/dialog_error_messages', :locals => { :object_name => 'input' } + render_dialog_error_messages 'input' end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7fa9664..ad78387 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -980,7 +980,10 @@ module ApplicationHelper def article_to_html(article, options = {}) options.merge!(:page => params[:npage]) content = article.to_html(options) - return self.instance_eval(&content) if content.kind_of?(Proc) + content = content.kind_of?(Proc) ? self.instance_eval(&content) : content + @plugins && @plugins.enabled_plugins.each do |plugin| + content = plugin.parse_content(content) + end content end @@ -1221,4 +1224,8 @@ module ApplicationHelper end end + def render_dialog_error_messages(instance_name) + render :partial => 'shared/dialog_error_messages', :locals => { :object_name => instance_name } + end + end diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb index b165249..c8e9457 100644 --- a/app/helpers/boxes_helper.rb +++ b/app/helpers/boxes_helper.rb @@ -99,7 +99,9 @@ module BoxesHelper unless block.visible? options[:title] = _("This block is invisible. Your visitors will not see it.") end - + @controller.send(:content_editor?) || @plugins.enabled_plugins.each do |plugin| + result = plugin.parse_content(result) + end box_decorator.block_target(block.box, block) + content_tag('div', content_tag('div', diff --git a/app/views/manage_products/_edit_image.rhtml b/app/views/manage_products/_edit_image.rhtml index 3924386..d8c3338 100644 --- a/app/views/manage_products/_edit_image.rhtml +++ b/app/views/manage_products/_edit_image.rhtml @@ -22,5 +22,5 @@ <% if errors %> - <%= render :partial => 'shared/dialog_error_messages', :locals => { :object_name => 'product' } %> + <%= render_dialog_error_messages 'product' %> <% end %> diff --git a/app/views/manage_products/_edit_info.rhtml b/app/views/manage_products/_edit_info.rhtml index ef4e5d7..e4cff79 100644 --- a/app/views/manage_products/_edit_info.rhtml +++ b/app/views/manage_products/_edit_info.rhtml @@ -1,5 +1,5 @@ <% if errors %> - <%= render :partial => 'shared/dialog_error_messages', :locals => { :object_name => 'product' } %> + <%= render_dialog_error_messages 'product' %> <% end %> <% remote_form_for(@product, diff --git a/app/views/manage_products/_edit_name.rhtml b/app/views/manage_products/_edit_name.rhtml index 7b9f416..f73170f 100644 --- a/app/views/manage_products/_edit_name.rhtml +++ b/app/views/manage_products/_edit_name.rhtml @@ -17,5 +17,5 @@ <% if errors %> - <%= render :partial => 'shared/dialog_error_messages', :locals => { :object_name => 'product' } %> + <%= render_dialog_error_messages 'product' %> <% end %> diff --git a/app/views/plugins/index.rhtml b/app/views/plugins/index.rhtml index 13a76c2..4f26306 100644 --- a/app/views/plugins/index.rhtml +++ b/app/views/plugins/index.rhtml @@ -12,7 +12,7 @@ <%= hidden_field_tag('environment[enabled_plugins][]', '') %> <% @active_plugins.each do |plugin| %> - <%= plugin.plugin_name %> + <%= plugin.has_admin_url? ? link_to(plugin.plugin_name, plugin.admin_url) : plugin.plugin_name %> <%= plugin.plugin_description %> <%= check_box_tag "environment[enabled_plugins][]", plugin, @environment.enabled_plugins.include?(plugin.to_s), :id => plugin.plugin_name %> diff --git a/config/cucumber.yml b/config/cucumber.yml index e89c790..b20b547 100644 --- a/config/cucumber.yml +++ b/config/cucumber.yml @@ -1,2 +1,2 @@ -default: --tags ~@selenium,~@wip --exclude features/support/selenium.rb --exclude features/step_definitions/selenium_steps.rb -selenium: --tags @selenium,~@wip +default: --tags ~@selenium,~@wip --exclude features/support/selenium.rb --exclude features/step_definitions/selenium_steps.rb -r features/support -r features/step_definitions +selenium: --tags @selenium,~@wip -r features/support -r features/step_definitions diff --git a/doc/noosfero/plugins/index.textile b/doc/noosfero/plugins/index.textile new file mode 100644 index 0000000..8492bf0 --- /dev/null +++ b/doc/noosfero/plugins/index.textile @@ -0,0 +1,2 @@ +h1. Plugins + diff --git a/features/plugins.feature b/features/plugins.feature index 0bbeca8..726a01c 100644 --- a/features/plugins.feature +++ b/features/plugins.feature @@ -56,4 +56,3 @@ Feature: plugins Then I should not see "Test plugin button" When I go to the profile Then I should not see "Test plugin tab" - diff --git a/lib/noosfero/i18n.rb b/lib/noosfero/i18n.rb index a7f8859..5fc4517 100644 --- a/lib/noosfero/i18n.rb +++ b/lib/noosfero/i18n.rb @@ -71,7 +71,9 @@ module ActionView::Helpers::ActiveRecordHelper end end - if options[:message_title] + if options[:header_message] + header_message = options[:header_message] + elsif options[:message_title] header_message = instance.error_message(options[:message_title], count) % {:num => count, :record => record} else header_message = ((count == 1) ? _(@error_message_title[0]) : _(@error_message_title[1])) % {:num => count, :record => record} diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index ddf1a76..2b421e3 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -52,6 +52,13 @@ class Noosfero::Plugin _("No description informed.") end + def admin_url + {:controller => "#{name.underscore}_admin", :action => 'index'} + end + + def has_admin_url? + File.exists?(File.join(root_path, 'controllers', "#{name.underscore}_admin_controller.rb")) + end end def expanded_template(file_path, locals = {}) @@ -121,4 +128,10 @@ class Noosfero::Plugin [] end + # -> Parse and possibly make changes of content (article, block, etc) during HTML rendering + # returns = content as string after parser and changes + def parse_content(raw_content) + raw_content + end + end diff --git a/lib/tasks/doc.rake b/lib/tasks/doc.rake index 317f28a..9e23c5f 100644 --- a/lib/tasks/doc.rake +++ b/lib/tasks/doc.rake @@ -1,5 +1,8 @@ namespace :noosfero do namespace :doc do + Dir.glob('plugins/**/doc/*.textile').each do |file| + ln_sf File.join(RAILS_ROOT, file), 'doc/noosfero/plugins/' + end input = Dir.glob('doc/noosfero/**/*.textile') topics_xhtml = input.map { |item| item.sub('.textile', '.en.xhtml') } sections = Dir.glob('doc/noosfero/*').select {|item| File.directory?(item) } diff --git a/test/unit/plugin_test.rb b/test/unit/plugin_test.rb index cd4fcf6..c1646a2 100644 --- a/test/unit/plugin_test.rb +++ b/test/unit/plugin_test.rb @@ -18,6 +18,12 @@ class PluginTest < Test::Unit::TestCase assert_includes Noosfero::Plugin.all, Plugin1.to_s end -end + should 'returns url to plugin management if plugin has admin_controller' do + class Plugin1 < Noosfero::Plugin + end + File.stubs(:exists?).with(anything).returns(true) + assert_equal({:controller => 'plugin_test/plugin1_admin', :action => 'index'}, Plugin1.admin_url) + end +end -- libgit2 0.21.2