Project

General

Profile

RE: Wiki Extensions Plugin » comments_mailer.patch

Dmitriy Belokurov, 2011-08-17 13:55

View differences:

redmine_wiki_extensions_with_notifications/app/controllers/wiki_extensions_controller.rb 2011-08-17 14:21:57.856711918 +0400
comment.comment = params[:comment]
comment.save
page = WikiPage.find(comment.wiki_page_id)
# Send email-notification to watchers of wiki page
WikiExtensionsCommentsMailer.deliver_wiki_commented(comment, page) if Setting.notified_events.include? "wiki_comment_added"
redirect_to :controller => 'wiki', :action => 'show', :project_id => @project, :id => page.title
end
......
comment.comment = params[:reply]
comment.save
page = WikiPage.find(comment.wiki_page_id)
# Send email-notification to watchers of wiki page
WikiExtensionsCommentsMailer.deliver_wiki_commented(comment, page) if Setting.notified_events.include? "wiki_comment_added"
redirect_to :controller => 'wiki', :action => 'show', :project_id => @project, :id => page.title
end
redmine_wiki_extensions_with_notifications/app/views/wiki_extensions_comments_mailer/wiki_commented.text.html.rhtml 2011-08-17 14:24:05.344711938 +0400
<%=
l(:wiki_page_commented_header, :project_name => @project.name, :page_title => @wiki_page_title, :author => @author)
%>
<hr />
<%=
l(:wiki_page_commented_comment_head)
%>
<br /><br />
<%=
@text
%>
<hr />
<%=
l(:wiki_page_commented_url)
%>
<br />
<%=
"<a href=\"" + @wiki_page_url + "\">" + @wiki_page_url + "<a/>"
%>
redmine_wiki_extensions_with_notifications/app/views/wiki_extensions_comments_mailer/wiki_commented.text.plain.rhtml 2011-08-17 14:23:21.204711931 +0400
<%=
l(:wiki_page_commented_header, :project_name => @project.name, :page_title => @wiki_page_title, :author => @author)
%>
----------------------------------------
<%=
l(:wiki_page_commented_comment_head)
%>
<%=
@text
%>
----------------------------------------
<%=
l(:wiki_page_commented_url)
%>
<%=
@wiki_page_url
%>
redmine_wiki_extensions_with_notifications/config/locales/en.yml 2011-08-17 14:24:50.788711945 +0400
field_auto_preview_enabled: Enable auto preview
field_sidebar_disabled: Disable side bar
wiki_extensions_vote: vote
# Wiki comments notification
wiki_page_commented_header: Comment to wiki page "%{page_title}" of project "%{project_name}" added by user %{author}
wiki_page_commented_comment_head: 'Comment:'
wiki_page_commented_url: 'You can see page with comment by the following link:'
redmine_wiki_extensions_with_notifications/config/locales/ru.yml 2011-08-17 14:25:29.268711951 +0400
field_auto_preview_enabled: Enable auto preview
field_sidebar_disabled: Disable side bar
wiki_extensions_vote: vote
wiki_extensions_vote: vote
# Wiki comments notification
wiki_page_commented_header: Вики-страница "%{page_title}" проекта "%{project_name}" прокомментированна пользователем %{author}
wiki_page_commented_comment_head: 'Комментарий:'
wiki_page_commented_url: 'Вы можете просмотреть страницу с комментарием перейдя по следующей ссылке:'
redmine_wiki_extensions_with_notifications/.hgtags 1970-01-01 03:00:00.000000000 +0300
0cf29479de38eb2b632b7c04165fa8e686051cff redmine_wiki_extensions-0.2.1
256a06a44757e2161db5d08d5116f228e54dd609 redmine_wiki_extensions-0.1.3
80b391231d6bffbb33236179049430714861ab8c redmine_wiki_extensions-0.2.4
8a68256f5e4420fef68be995c3aee478a3c82c37 redmine_wiki_extensions-0.1.5
a162e687b3ca472a13c582c665051c615b8d7ca9 redmine_wiki_extensions-0.2.0
b997b63cc744dc50964fc77405fd03b867f60dae redmine_wiki_extensions-0.1.5.1
d861c5d461812794ed832cbe5fef1e47de21ab57 redmine_wiki_extensions-0.2.2
dd70a8b8bdc0a82a7f7676872681858963ee4878 redmine_wiki_extensions-0.0.9
e8de37da2e6286b57509f6f1f6e116678dd2a191 redmine_wiki_extensions-0.1.4
f286845a9a6376dab1fec4027e054795f36bb348 redmine_wiki_extensions-0.1.1
f931ee08731cbbb61efcef944381331c142f4ecb redmine_wiki_extensions-0.1.2
148b9f08e40bd96c1a737489d759ab13492f6e0a redmine_wiki_extensions-0.2.5
308e985db3426150e2c4bab8a0ad908ed2290030 redmine_wiki_extensions-0.2.5.1
312ba544fbb6d32f1a43ddc5f8aa53a76c9040f1 redmine_wiki_extensions-0.3.0
7351add1cad47aa563dee170efde5ba47f4b1818 redmine_wiki_extensions-0.3.1
29567f419215460f9db8e2f1f3c854fa9c1a4bc1 0.3.2
98ba08cbb53bb22e765c6f20045968ac7187082a 0.3.3
47a062e4d8d19341bc1e02d5e2625d6dabac4ad8 0.3.4
redmine_wiki_extensions_with_notifications/init.rb 2011-08-17 14:25:57.280711956 +0400
rescue LoadError
end
require 'redcloth3'
require_dependency 'wiki_extensions_notifiable_patch'
Dir::foreach(File.join(File.dirname(__FILE__), 'lib')) do |file|
next unless /\.rb$/ =~ file
require file
redmine_wiki_extensions_with_notifications/lib/wiki_extensions_comments_mailer.rb 2011-08-17 14:27:03.088711967 +0400
require 'mailer'
class WikiExtensionsCommentsMailer < Mailer
# Modifiyng view paths to make our mail-views visible for plugin
self.instance_variable_get("@inheritable_attributes")[:view_paths] << RAILS_ROOT + "/vendor/plugins/redmine_wiki_extensions/app/views"
def wiki_commented(comment, wiki_page)
project = wiki_page.project
author = comment.user
text = comment.comment
redmine_headers 'Project' => project,
'Wiki-Page-Id' => wiki_page.id,
'Author' => author
message_id wiki_page
# Send notification to watchers of wiki page
recipients wiki_page.watchers.collect{|watcher| watcher.user.mail}
subject "[#{project.name} - Wiki - #{wiki_page.title}] commented"
body = {
:project => project,
:author => author,
:text => text,
:wiki_page_title => wiki_page.title,
:wiki_page_url => url_for(:controller => 'wiki', :action => 'show', :project_id => project, :id => wiki_page.title)
}
render_multipart('wiki_commented', body)
end
end
redmine_wiki_extensions_with_notifications/lib/wiki_extensions_notifiable_patch.rb 2011-08-17 14:27:50.976711975 +0400
module WikiExtensionsNotifiablePatch
def self.included(base) # :nodoc:
@is_wrap = false
base.extend NotifiableMethods
base.class_eval do
unloadable
class << self
if !@is_wrap
alias_method_chain :all, :wiki_comments
@is_wrap = true
end
end
end
end
end
module NotifiableMethods
def all_with_wiki_comments
notifications = all_without_wiki_comments
notifications << Redmine::Notifiable.new('wiki_comment_added')
notifications
end
end
Redmine::Notifiable.send(:include, WikiExtensionsNotifiablePatch)
    (1-1/1)