Commit 7d45fcb2b6ad4e4fa8da3288bacf48229e2742d6
1 parent
a5c0c0f3
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Sending email, but no feedback msg yet
Showing
7 changed files
with
238 additions
and
0 deletions
Show diff stats
app/views/content_viewer/_article_toolbar.rhtml
| @@ -37,6 +37,11 @@ | @@ -37,6 +37,11 @@ | ||
| 37 | <%= colorbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) unless remove_content_button(:new) %> | 37 | <%= colorbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) unless remove_content_button(:new) %> |
| 38 | <% end %> | 38 | <% end %> |
| 39 | 39 | ||
| 40 | + <% | ||
| 41 | + @plugins.dispatch(:article_toolbar_extra_buttons).each do |plugin_button| %> | ||
| 42 | + <%= instance_eval(&plugin_button) %> | ||
| 43 | + <% end %> | ||
| 44 | + | ||
| 40 | <% if @page.accept_uploads? && @page.allow_create?(user) %> | 45 | <% if @page.accept_uploads? && @page.allow_create?(user) %> |
| 41 | <%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) unless remove_content_button(:upload)%> | 46 | <%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) unless remove_content_button(:upload)%> |
| 42 | <% end %> | 47 | <% end %> |
lib/noosfero/plugin.rb
| @@ -285,6 +285,17 @@ class Noosfero::Plugin | @@ -285,6 +285,17 @@ class Noosfero::Plugin | ||
| 285 | nil | 285 | nil |
| 286 | end | 286 | end |
| 287 | 287 | ||
| 288 | + | ||
| 289 | + # -> Adds buttons to manage members page | ||
| 290 | + # returns = { :title => title, :icon => icon, :url => url } | ||
| 291 | + # title = name that will be displayed. | ||
| 292 | + # icon = css class name (for customized icons include them in a css file). | ||
| 293 | + # url = url or route to which the button will redirect. | ||
| 294 | + def article_toolbar_extra_buttons | ||
| 295 | + nil | ||
| 296 | + end | ||
| 297 | + | ||
| 298 | + | ||
| 288 | # This method will be called just before a comment is saved to the database. | 299 | # This method will be called just before a comment is saved to the database. |
| 289 | # | 300 | # |
| 290 | # It can modify the comment in several ways. In special, a plugin can call | 301 | # It can modify the comment in several ways. In special, a plugin can call |
| @@ -571,5 +582,6 @@ class Noosfero::Plugin | @@ -571,5 +582,6 @@ class Noosfero::Plugin | ||
| 571 | #content_expire too. | 582 | #content_expire too. |
| 572 | %w[edit delete spread locale suggest home new upload] | 583 | %w[edit delete spread locale suggest home new upload] |
| 573 | end | 584 | end |
| 585 | + | ||
| 574 | 586 | ||
| 575 | end | 587 | end |
plugins/email_article/controllers/email_article_plugin_myprofile_controller.rb
0 → 100644
| @@ -0,0 +1,91 @@ | @@ -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 | \ No newline at end of file | 92 | \ No newline at end of file |
| @@ -0,0 +1,25 @@ | @@ -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 |
| @@ -0,0 +1,79 @@ | @@ -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 | +} |
| @@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
| 1 | +require File.dirname(__FILE__) + '/../../../test/test_helper' |
plugins/email_article/test/unit/email_article_plugin_test.rb
0 → 100644
| @@ -0,0 +1,25 @@ | @@ -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 |