From 84b066e039325999f9b67b871c9971888b1db93b Mon Sep 17 00:00:00 2001 From: Evandro Junior Date: Thu, 8 May 2014 21:16:36 +0000 Subject: [PATCH] Sending email, but no feedback msg yet --- controllers/email_article_plugin_myprofile_controller.rb | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/email_article_plugin.rb | 25 +++++++++++++++++++++++++ public/style.css | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test_helper.rb | 1 + test/unit/email_article_plugin_test.rb | 25 +++++++++++++++++++++++++ 5 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 controllers/email_article_plugin_myprofile_controller.rb create mode 100644 lib/email_article_plugin.rb create mode 100644 public/style.css create mode 100644 test/test_helper.rb create mode 100644 test/unit/email_article_plugin_test.rb diff --git a/controllers/email_article_plugin_myprofile_controller.rb b/controllers/email_article_plugin_myprofile_controller.rb new file mode 100644 index 0000000..ad3154d --- /dev/null +++ b/controllers/email_article_plugin_myprofile_controller.rb @@ -0,0 +1,91 @@ +class EmailArticlePluginMyprofileController < MyProfileController + + needs_profile +# before_filter :check_access_to_profile, :except => [:join, :join_not_logged, :index, :add] +# before_filter :store_location, :only => [:join, :join_not_logged, :report_abuse, :send_mail] +# before_filter :login_required, :only => [:add, :join, :join_not_logged, :leave, :unblock, :leave_scrap, :remove_scrap, :remove_activity, :view_more_activities, :view_more_network_activities, :report_abuse, :register_report, :leave_comment_on_activity, :send_mail] + +# self.members + + + + def send_email + + puts "ID ***************************" + y params[:id] + puts "END ID ***************************" + + profile = Profile[params[:profile]] + article = Article.find(params[:id]) + session[:notice] = 'Tudo beleza' + EmailArticlePluginMyprofileController::Sender.deliver_mail(article) +# +# puts "########################params[:mailing]########################" +# y params[:mailing] +# raise +# + end + + + class Sender < ActionMailer::Base + def mail(article) + members = article.profile.members + emails = [] + members.each{ |m| + emails.push(m.user.email) + } + puts "***************************" + y emails + puts "***************************" + content_type 'text/html' + recipients emails + from "#{article.author.user.name} <#{article.author.user.email}>" + reply_to article.author.user.email +# if contact.sender +# headers 'X-Noosfero-Sender' => contact.sender.identifier +# end +# if contact.receive_a_copy +# cc "#{@article.author.user.name} <#{@article.author.user.email}>" +# end + subject "[Artigo] " + article.title + body article.body + + end + end + + + +# def deliver +# #return false unless self.valid? +# EmailArticlePluginMyprofileController::Sender.deliver_mail(self) +# end +# +# class Sender < ActionMailer::Base +# def mail(contact) +# content_type 'text/html' +# emails = contact.dest.notification_emails +# recipients emails +# from "#{contact.name} <#{contact.dest.environment.noreply_email}>" +# reply_to contact.email +# if contact.sender +# headers 'X-Noosfero-Sender' => contact.sender.identifier +# end +# if contact.receive_a_copy +# cc "#{contact.name} <#{contact.email}>" +# end +# subject "[#{contact.dest.short_name(30)}] " + contact.subject +# body :name => contact.name, +# :email => contact.email, +# :city => contact.city, +# :state => contact.state, +# :message => contact.message, +# :environment => contact.dest.environment.name, +# :url => url_for(:host => contact.dest.environment.default_hostname, :controller => 'home'), +# :target => contact.dest.name +# end +# end + + +end + +#append_view_path File.join(File.dirname(__FILE__) + '/../views') \ No newline at end of file diff --git a/lib/email_article_plugin.rb b/lib/email_article_plugin.rb new file mode 100644 index 0000000..ce14775 --- /dev/null +++ b/lib/email_article_plugin.rb @@ -0,0 +1,25 @@ +class EmailArticlePlugin < Noosfero::Plugin + + def self.plugin_name + "Email Article to Community Members Plugin" + end + + def self.plugin_description + _("A plugin that emails an article to the members of the community.") + end + + def article_toolbar_extra_buttons + lambda { + link_to_remote(_("Email article to members"), + {:url => { :controller => 'email_article_plugin_myprofile', :action => "send_email", :id => @page}, + :method => :get +# , :loading => "Enviando emails" + }) + } + end + + def stylesheet? + true + end + +end diff --git a/public/style.css b/public/style.css new file mode 100644 index 0000000..b0327fc --- /dev/null +++ b/public/style.css @@ -0,0 +1,79 @@ +#content .relevant-content-plugin_relevant-content-block { + padding: 10px 0px 10px 10px; + word-wrap: break-word; +} + +.relevant-content-plugin_relevant-content-block ul { + margin: 0px; + padding: 0px 0px 0px 20px; +} +.relevant-content-plugin_relevant-content-block li { + margin: 0px; + padding: 0px; + list-style: none +} +.relevant-content-plugin_relevant-content-block a { + text-decoration: none; +} +.relevant-content-plugin_relevant-content-block .block-footer-content { + font-size: 10px; +} +.relevant-content-plugin_relevant-content-block .block-footer-content a:hover { + text-decoration: underline; +} + +.relevant-content-plugin_relevant-content-block p { + text-align:center; +} + +.relevant-content-plugin_relevant-content-block p.like{ + background-image: url('images/positive-hand.png'); + background-repeat: no-repeat; + min-width: 50px; + text-align:center; +} + +.relevant-content-plugin_relevant-content-block p.dislike{ + background-image: url('images/negative-hand.png'); + background-repeat: no-repeat; + min-width: 50px; + text-align:center; +} + + +.relevant-content-plugin_relevant-content-block { + //overflow: hidden; + display: block; + width: 100%; +} + + +.relevant-content-cover img { + width: 100%; +} + +.relevant-content-plugin_relevant-content-block span.title { + display: block; + margin: 20px 0px 0px; + padding: 0px 0px 0px 20px; +} + +.relevant-content-plugin_relevant-content-block span.title.mread { + +} + +.relevant-content-plugin_relevant-content-block span.title.mcommented { + +} + +.relevant-content-plugin_relevant-content-block span.title.mliked { + +} + +.relevant-content-plugin_relevant-content-block span.title.mdisliked { + +} + +.relevant-content-plugin_relevant-content-block span.title.mvoted { + +} diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..cca1fd3 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1 @@ +require File.dirname(__FILE__) + '/../../../test/test_helper' diff --git a/test/unit/email_article_plugin_test.rb b/test/unit/email_article_plugin_test.rb new file mode 100644 index 0000000..7d2049b --- /dev/null +++ b/test/unit/email_article_plugin_test.rb @@ -0,0 +1,25 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class EmailArticlePluginTest < ActiveSupport::TestCase + + def setup + @plugin = EmailArticlePlugin.new + end + + should 'be a noosfero plugin' do + assert_kind_of Noosfero::Plugin, @plugin + end + + should 'have name' do + assert_equal 'Relevant Content 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 + end + + should 'have stylesheet' do + assert @plugin.stylesheet? + end + +end -- libgit2 0.21.2