Commit 84b066e039325999f9b67b871c9971888b1db93b
0 parents
Exists in
master
Sending email, but no feedback msg yet
Showing
5 changed files
with
221 additions
and
0 deletions
Show diff stats
controllers/email_article_plugin_myprofile_controller.rb
0 → 100644
| 1 | +++ a/controllers/email_article_plugin_myprofile_controller.rb | |
| ... | ... | @@ -0,0 +1,91 @@ |
| 1 | +class EmailArticlePluginMyprofileController < MyProfileController | |
| 2 | + | |
| 3 | + needs_profile | |
| 4 | +# before_filter :check_access_to_profile, :except => [:join, :join_not_logged, :index, :add] | |
| 5 | +# before_filter :store_location, :only => [:join, :join_not_logged, :report_abuse, :send_mail] | |
| 6 | +# 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] | |
| 7 | + | |
| 8 | +# self.members | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + def send_email | |
| 13 | + | |
| 14 | + puts "ID ***************************" | |
| 15 | + y params[:id] | |
| 16 | + puts "END ID ***************************" | |
| 17 | + | |
| 18 | + profile = Profile[params[:profile]] | |
| 19 | + article = Article.find(params[:id]) | |
| 20 | + session[:notice] = 'Tudo beleza' | |
| 21 | + EmailArticlePluginMyprofileController::Sender.deliver_mail(article) | |
| 22 | +# | |
| 23 | +# puts "########################params[:mailing]########################" | |
| 24 | +# y params[:mailing] | |
| 25 | +# raise | |
| 26 | +# | |
| 27 | + end | |
| 28 | + | |
| 29 | + | |
| 30 | + class Sender < ActionMailer::Base | |
| 31 | + def mail(article) | |
| 32 | + members = article.profile.members | |
| 33 | + emails = [] | |
| 34 | + members.each{ |m| | |
| 35 | + emails.push(m.user.email) | |
| 36 | + } | |
| 37 | + puts "***************************" | |
| 38 | + y emails | |
| 39 | + puts "***************************" | |
| 40 | + content_type 'text/html' | |
| 41 | + recipients emails | |
| 42 | + from "#{article.author.user.name} <#{article.author.user.email}>" | |
| 43 | + reply_to article.author.user.email | |
| 44 | +# if contact.sender | |
| 45 | +# headers 'X-Noosfero-Sender' => contact.sender.identifier | |
| 46 | +# end | |
| 47 | +# if contact.receive_a_copy | |
| 48 | +# cc "#{@article.author.user.name} <#{@article.author.user.email}>" | |
| 49 | +# end | |
| 50 | + subject "[Artigo] " + article.title | |
| 51 | + body article.body | |
| 52 | + | |
| 53 | + end | |
| 54 | + end | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | +# def deliver | |
| 59 | +# #return false unless self.valid? | |
| 60 | +# EmailArticlePluginMyprofileController::Sender.deliver_mail(self) | |
| 61 | +# end | |
| 62 | +# | |
| 63 | +# class Sender < ActionMailer::Base | |
| 64 | +# def mail(contact) | |
| 65 | +# content_type 'text/html' | |
| 66 | +# emails = contact.dest.notification_emails | |
| 67 | +# recipients emails | |
| 68 | +# from "#{contact.name} <#{contact.dest.environment.noreply_email}>" | |
| 69 | +# reply_to contact.email | |
| 70 | +# if contact.sender | |
| 71 | +# headers 'X-Noosfero-Sender' => contact.sender.identifier | |
| 72 | +# end | |
| 73 | +# if contact.receive_a_copy | |
| 74 | +# cc "#{contact.name} <#{contact.email}>" | |
| 75 | +# end | |
| 76 | +# subject "[#{contact.dest.short_name(30)}] " + contact.subject | |
| 77 | +# body :name => contact.name, | |
| 78 | +# :email => contact.email, | |
| 79 | +# :city => contact.city, | |
| 80 | +# :state => contact.state, | |
| 81 | +# :message => contact.message, | |
| 82 | +# :environment => contact.dest.environment.name, | |
| 83 | +# :url => url_for(:host => contact.dest.environment.default_hostname, :controller => 'home'), | |
| 84 | +# :target => contact.dest.name | |
| 85 | +# end | |
| 86 | +# end | |
| 87 | + | |
| 88 | + | |
| 89 | +end | |
| 90 | + | |
| 91 | +#append_view_path File.join(File.dirname(__FILE__) + '/../views') | |
| 0 | 92 | \ No newline at end of file | ... | ... |
| 1 | +++ a/lib/email_article_plugin.rb | |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +class EmailArticlePlugin < Noosfero::Plugin | |
| 2 | + | |
| 3 | + def self.plugin_name | |
| 4 | + "Email Article to Community Members Plugin" | |
| 5 | + end | |
| 6 | + | |
| 7 | + def self.plugin_description | |
| 8 | + _("A plugin that emails an article to the members of the community.") | |
| 9 | + end | |
| 10 | + | |
| 11 | + def article_toolbar_extra_buttons | |
| 12 | + lambda { | |
| 13 | + link_to_remote(_("Email article to members"), | |
| 14 | + {:url => { :controller => 'email_article_plugin_myprofile', :action => "send_email", :id => @page}, | |
| 15 | + :method => :get | |
| 16 | +# , :loading => "Enviando emails" | |
| 17 | + }) | |
| 18 | + } | |
| 19 | + end | |
| 20 | + | |
| 21 | + def stylesheet? | |
| 22 | + true | |
| 23 | + end | |
| 24 | + | |
| 25 | +end | ... | ... |
| 1 | +++ a/public/style.css | |
| ... | ... | @@ -0,0 +1,79 @@ |
| 1 | +#content .relevant-content-plugin_relevant-content-block { | |
| 2 | + padding: 10px 0px 10px 10px; | |
| 3 | + word-wrap: break-word; | |
| 4 | +} | |
| 5 | + | |
| 6 | +.relevant-content-plugin_relevant-content-block ul { | |
| 7 | + margin: 0px; | |
| 8 | + padding: 0px 0px 0px 20px; | |
| 9 | +} | |
| 10 | +.relevant-content-plugin_relevant-content-block li { | |
| 11 | + margin: 0px; | |
| 12 | + padding: 0px; | |
| 13 | + list-style: none | |
| 14 | +} | |
| 15 | +.relevant-content-plugin_relevant-content-block a { | |
| 16 | + text-decoration: none; | |
| 17 | +} | |
| 18 | +.relevant-content-plugin_relevant-content-block .block-footer-content { | |
| 19 | + font-size: 10px; | |
| 20 | +} | |
| 21 | +.relevant-content-plugin_relevant-content-block .block-footer-content a:hover { | |
| 22 | + text-decoration: underline; | |
| 23 | +} | |
| 24 | + | |
| 25 | +.relevant-content-plugin_relevant-content-block p { | |
| 26 | + text-align:center; | |
| 27 | +} | |
| 28 | + | |
| 29 | +.relevant-content-plugin_relevant-content-block p.like{ | |
| 30 | + background-image: url('images/positive-hand.png'); | |
| 31 | + background-repeat: no-repeat; | |
| 32 | + min-width: 50px; | |
| 33 | + text-align:center; | |
| 34 | +} | |
| 35 | + | |
| 36 | +.relevant-content-plugin_relevant-content-block p.dislike{ | |
| 37 | + background-image: url('images/negative-hand.png'); | |
| 38 | + background-repeat: no-repeat; | |
| 39 | + min-width: 50px; | |
| 40 | + text-align:center; | |
| 41 | +} | |
| 42 | + | |
| 43 | + | |
| 44 | +.relevant-content-plugin_relevant-content-block { | |
| 45 | + //overflow: hidden; | |
| 46 | + display: block; | |
| 47 | + width: 100%; | |
| 48 | +} | |
| 49 | + | |
| 50 | + | |
| 51 | +.relevant-content-cover img { | |
| 52 | + width: 100%; | |
| 53 | +} | |
| 54 | + | |
| 55 | +.relevant-content-plugin_relevant-content-block span.title { | |
| 56 | + display: block; | |
| 57 | + margin: 20px 0px 0px; | |
| 58 | + padding: 0px 0px 0px 20px; | |
| 59 | +} | |
| 60 | + | |
| 61 | +.relevant-content-plugin_relevant-content-block span.title.mread { | |
| 62 | + | |
| 63 | +} | |
| 64 | + | |
| 65 | +.relevant-content-plugin_relevant-content-block span.title.mcommented { | |
| 66 | + | |
| 67 | +} | |
| 68 | + | |
| 69 | +.relevant-content-plugin_relevant-content-block span.title.mliked { | |
| 70 | + | |
| 71 | +} | |
| 72 | + | |
| 73 | +.relevant-content-plugin_relevant-content-block span.title.mdisliked { | |
| 74 | + | |
| 75 | +} | |
| 76 | + | |
| 77 | +.relevant-content-plugin_relevant-content-block span.title.mvoted { | |
| 78 | + | |
| 79 | +} | ... | ... |
| 1 | +++ a/test/unit/email_article_plugin_test.rb | |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +require File.dirname(__FILE__) + '/../test_helper' | |
| 2 | + | |
| 3 | +class EmailArticlePluginTest < ActiveSupport::TestCase | |
| 4 | + | |
| 5 | + def setup | |
| 6 | + @plugin = EmailArticlePlugin.new | |
| 7 | + end | |
| 8 | + | |
| 9 | + should 'be a noosfero plugin' do | |
| 10 | + assert_kind_of Noosfero::Plugin, @plugin | |
| 11 | + end | |
| 12 | + | |
| 13 | + should 'have name' do | |
| 14 | + assert_equal 'Relevant Content Plugin', EmailArticlePlugin.plugin_name | |
| 15 | + end | |
| 16 | + | |
| 17 | + should 'have description' do | |
| 18 | + assert_equal _("A plugin that lists the most accessed, most commented, most liked and most disliked contents."), EmailArticlePlugin.plugin_description | |
| 19 | + end | |
| 20 | + | |
| 21 | + should 'have stylesheet' do | |
| 22 | + assert @plugin.stylesheet? | |
| 23 | + end | |
| 24 | + | |
| 25 | +end | ... | ... |