diff --git a/controllers/email_article_plugin_myprofile_controller.rb b/controllers/email_article_plugin_myprofile_controller.rb index 17e135a..c1e2bc9 100644 --- a/controllers/email_article_plugin_myprofile_controller.rb +++ b/controllers/email_article_plugin_myprofile_controller.rb @@ -1,4 +1,5 @@ class EmailArticlePluginMyprofileController < MyProfileController + needs_profile # before_filter :check_access_to_profile, :except => [:join, :join_not_logged, :index, :add] @@ -14,6 +15,7 @@ class EmailArticlePluginMyprofileController < MyProfileController end class Sender < ActionMailer::Base + add_template_helper(PersonNotifierHelper) def mail(article) members = article.profile.members emails = [] @@ -25,7 +27,26 @@ class EmailArticlePluginMyprofileController < MyProfileController from "#{article.author.user.name} <#{article.author.user.email}>" reply_to article.author.user.email subject "[Artigo] " + article.title - body article.body + body set_absolute_path(article.body, article.environment) end + + def set_absolute_path(body, environment) + parsed = Hpricot(body.to_s) + parsed.search('img[@src]').map { |i| change_element_path(i, 'src', environment) } + parsed.search('a[@href]').map { |i| change_element_path(i, 'href', environment) } + parsed.to_s end + + def change_element_path(el, attribute, environment) + fullpath = /^http/.match(el[attribute]) + if not fullpath + relative_path = /\/?(.*)/.match(el[attribute]) + el[attribute] = "http://#{environment.default_hostname}/#{relative_path[1]}" + end + end + + + end + + end \ No newline at end of file diff --git a/lib/email_article_plugin.rb b/lib/email_article_plugin.rb index 555e806..fd96988 100644 --- a/lib/email_article_plugin.rb +++ b/lib/email_article_plugin.rb @@ -5,7 +5,7 @@ class EmailArticlePlugin < Noosfero::Plugin end def self.plugin_description - _("A plugin that emails an article to the members of the community.") + _("A plugin that emails an article to the members of the community") end def article_toolbar_extra_buttons diff --git a/test/unit/email_article_plugin_test.rb b/test/unit/email_article_plugin_test.rb index f5d94eb..c157f25 100644 --- a/test/unit/email_article_plugin_test.rb +++ b/test/unit/email_article_plugin_test.rb @@ -11,11 +11,11 @@ class EmailArticlePluginTest < ActiveSupport::TestCase end should 'have name' do - assert_equal 'Relevant Content Plugin', EmailArticlePlugin.plugin_name + assert_equal 'Email Article to Community Members Plugin', EmailArticlePlugin.plugin_name end should 'have description' do - assert_equal _("A plugin that lists the most accessed, most commented, most liked and most disliked contents."), EmailArticlePlugin.plugin_description + assert_equal _("A plugin that emails an article to the members of the community"), EmailArticlePlugin.plugin_description end end -- libgit2 0.21.2