Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Commit

Permalink
Version 0.5.0: Compatibility with Redmine 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
teleological committed Jul 11, 2012
1 parent 4b39b73 commit 46fb75b
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 13 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2010 Riley Lynch
Copyright (C) 2010-2012 Riley Lynch

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Expand Down
11 changes: 7 additions & 4 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This is a plugin for the "Redmine project management application":http://www.red

h2. Installation

# Install the redmine-stealth-plugin into your redmine application directory: ./script/plugin install http://github.com/teleological/redmine-stealth-plugin.git
# Restart any running Redmine application servers
# Install the redmine-stealth-plugin into your redmine application directory. For Redmine 2, git clone http://github.com/teleological/redmine-stealth-plugin.git plugins/redmine-stealth-plugin or for Redmine 1: ./script/plugin install http://github.com/teleological/redmine-stealth-plugin.git
# Restart any running Redmine application servers or touch tmp/restart.txt for Passenger
# Configure the per-role permissions for "Toggle stealth mode" as desired

h2. Usage
Expand All @@ -14,9 +14,12 @@ h2. Usage
# Do whatever it is that needs doing. Redmine will not send emails as a result of your actions while stealth mode is enabled. Other users's actions will continue to send email unless they have also activated stealth mode.
# Click "Disable stealth mode" in the account menu. Don't worry. You got away with it.

h2. To-do
h2. Compatibility

* Determine compatibility with different versions of redmine. This plugin was initially developed this with Redmine 0.9.1.stable, and version 0.4.0 was developed against Redmine 1.4.3. Please let me know if you find incompatibilities with older or newer versions.
* Version 0.5.0 was written for Redmine 2.0.3 and tested for backwards-compatibility with Redmine 1.4.3.
* Version 0.4.0 was written for Redmine 1.4.3 and added support for Ruby 1.9.
* Previous verions were written for Redmine 0.9.1.stable and reported to work with Redmine 1.1.2 and 1.3-stable.
* Compatibility with Chiliproject is unknown, but patches are welcome.

h2. License

Expand Down
17 changes: 15 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
ActionController::Routing::Routes.draw do |map|
map.connect '/stealth/toggle', :controller => 'stealth', :action => 'toggle'

if Rails::VERSION::MAJOR >= 3

RedmineApp::Application.routes.draw do
match '/stealth/toggle', :to => 'stealth#toggle'
end

else

ActionController::Routing::Routes.draw do |map|
map.connect '/stealth/toggle',
:controller => 'stealth', :action => 'toggle'
end

end

27 changes: 22 additions & 5 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@

require 'redmine'
require 'redmine/i18n'

require 'redmine_stealth'
require 'redmine_menu_manager_extensions'
require 'action_mailer_base_extensions'

if Rails::VERSION::MAJOR >= 3
require 'stealth_mail_interceptor'
else
require 'action_mailer_base_extensions'
end

require 'stealth_hooks'

Redmine::Plugin.register :redmine_stealth do
Expand All @@ -14,7 +21,7 @@
author 'Riley Lynch'
description 'Enables users to disable Redmine email notifications ' +
'for their actions'
version '0.4.0'
version '0.5.0'

if respond_to?(:url)
url 'http://teleological.github.com/redmine-stealth-plugin'
Expand Down Expand Up @@ -53,9 +60,19 @@
}
end

require 'dispatcher'
require 'application_helper'
require 'stealth_css_helper'

Dispatcher.to_prepare do
ApplicationHelper.send(:include, StealthCssHelper)
stealth_css_helper_mixin = lambda do |*_|
unless ApplicationHelper.included_modules.include?(StealthCssHelper)
ApplicationHelper.send(:include, StealthCssHelper)
end
end

if Rails::VERSION::MAJOR >= 3
ActionDispatch::Callbacks.to_prepare(&stealth_css_helper_mixin)
else
require 'dispatcher'
Dispatcher.to_prepare(&stealth_css_helper_mixin)
end

2 changes: 2 additions & 0 deletions lib/action_mailer_base_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

# Rails < 3

module ActionMailerBaseExtensions
def deliver_with_stealth!(mail=nil)
mail ||= instance_variable_get(:@mail)
Expand Down
2 changes: 1 addition & 1 deletion lib/stealth_css_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require_dependency 'application_helper'

module StealthCssHelper
def self.included(base) # :nodoc:
Expand All @@ -21,3 +20,4 @@ def body_css_classes_with_stealth
end
end
end

16 changes: 16 additions & 0 deletions lib/stealth_mail_interceptor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# Rails >= 3

class StealthMailInterceptor
def self.delivering_email(msg)
if ::RedmineStealth.cloaked?
msg.perform_deliveries = false
if logger = ActionMailer::Base.logger
logger.info("Squelching notification: #{msg.subject}")
end
end
end
end

ActionMailer::Base.register_interceptor(StealthMailInterceptor)

0 comments on commit 46fb75b

Please sign in to comment.