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
29 29
    comment.comment = params[:comment]
30 30
    comment.save
31 31
    page = WikiPage.find(comment.wiki_page_id)
32
    # Send email-notification to watchers of wiki page
33
    WikiExtensionsCommentsMailer.deliver_wiki_commented(comment, page) if Setting.notified_events.include? "wiki_comment_added"
32 34
    redirect_to :controller => 'wiki', :action => 'show', :project_id => @project, :id => page.title
33 35
  end
34 36
  
......
41 43
    comment.comment = params[:reply]
42 44
    comment.save
43 45
    page = WikiPage.find(comment.wiki_page_id)
46
    # Send email-notification to watchers of wiki page
47
    WikiExtensionsCommentsMailer.deliver_wiki_commented(comment, page) if Setting.notified_events.include? "wiki_comment_added"
44 48
    redirect_to :controller => 'wiki', :action => 'show', :project_id => @project, :id => page.title
45 49
  end
46 50

  
redmine_wiki_extensions_with_notifications/app/views/wiki_extensions_comments_mailer/wiki_commented.text.html.rhtml 2011-08-17 14:24:05.344711938 +0400
1
<%= 
2
l(:wiki_page_commented_header, :project_name => @project.name, :page_title => @wiki_page_title, :author => @author)
3
%>
4
<hr />
5
<%=
6
l(:wiki_page_commented_comment_head)
7
%>
8
<br /><br />
9
<%=
10
@text
11
%>
12
<hr />
13
<%=
14
l(:wiki_page_commented_url)
15
%>
16
<br />
17
<%=
18
"<a href=\"" + @wiki_page_url + "\">" + @wiki_page_url + "<a/>"
19
%>
redmine_wiki_extensions_with_notifications/app/views/wiki_extensions_comments_mailer/wiki_commented.text.plain.rhtml 2011-08-17 14:23:21.204711931 +0400
1
<%= 
2
l(:wiki_page_commented_header, :project_name => @project.name, :page_title => @wiki_page_title, :author => @author)
3
%>
4
----------------------------------------
5
<%=
6
l(:wiki_page_commented_comment_head)
7
%>
8

  
9
<%=
10
@text
11
%>
12
----------------------------------------
13
<%=
14
l(:wiki_page_commented_url)
15
%>
16
<%=
17
@wiki_page_url
18
%>
redmine_wiki_extensions_with_notifications/config/locales/en.yml 2011-08-17 14:24:50.788711945 +0400
13 13
  field_auto_preview_enabled: Enable auto preview
14 14
  field_sidebar_disabled: Disable side bar
15 15
  wiki_extensions_vote: vote
16

  
17
  # Wiki comments notification
18
  wiki_page_commented_header: Comment to wiki page "%{page_title}" of project "%{project_name}" added by user %{author}
19
  wiki_page_commented_comment_head: 'Comment:'
20
  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
12 12

  
13 13
  field_auto_preview_enabled: Enable auto preview
14 14
  field_sidebar_disabled: Disable side bar
15
  wiki_extensions_vote: vote
15
  wiki_extensions_vote: vote
16
  
17
  # Wiki comments notification
18
  wiki_page_commented_header: Вики-страница "%{page_title}" проекта "%{project_name}" прокомментированна пользователем %{author}
19
  wiki_page_commented_comment_head: 'Комментарий:'
20
  wiki_page_commented_url: 'Вы можете просмотреть страницу с комментарием перейдя по следующей ссылке:'
redmine_wiki_extensions_with_notifications/.hgtags 1970-01-01 03:00:00.000000000 +0300
1
0cf29479de38eb2b632b7c04165fa8e686051cff redmine_wiki_extensions-0.2.1
2
256a06a44757e2161db5d08d5116f228e54dd609 redmine_wiki_extensions-0.1.3
3
80b391231d6bffbb33236179049430714861ab8c redmine_wiki_extensions-0.2.4
4
8a68256f5e4420fef68be995c3aee478a3c82c37 redmine_wiki_extensions-0.1.5
5
a162e687b3ca472a13c582c665051c615b8d7ca9 redmine_wiki_extensions-0.2.0
6
b997b63cc744dc50964fc77405fd03b867f60dae redmine_wiki_extensions-0.1.5.1
7
d861c5d461812794ed832cbe5fef1e47de21ab57 redmine_wiki_extensions-0.2.2
8
dd70a8b8bdc0a82a7f7676872681858963ee4878 redmine_wiki_extensions-0.0.9
9
e8de37da2e6286b57509f6f1f6e116678dd2a191 redmine_wiki_extensions-0.1.4
10
f286845a9a6376dab1fec4027e054795f36bb348 redmine_wiki_extensions-0.1.1
11
f931ee08731cbbb61efcef944381331c142f4ecb redmine_wiki_extensions-0.1.2
12
148b9f08e40bd96c1a737489d759ab13492f6e0a redmine_wiki_extensions-0.2.5
13
308e985db3426150e2c4bab8a0ad908ed2290030 redmine_wiki_extensions-0.2.5.1
14
312ba544fbb6d32f1a43ddc5f8aa53a76c9040f1 redmine_wiki_extensions-0.3.0
15
7351add1cad47aa563dee170efde5ba47f4b1818 redmine_wiki_extensions-0.3.1
16
29567f419215460f9db8e2f1f3c854fa9c1a4bc1 0.3.2
17
98ba08cbb53bb22e765c6f20045968ac7187082a 0.3.3
18
47a062e4d8d19341bc1e02d5e2625d6dabac4ad8 0.3.4
redmine_wiki_extensions_with_notifications/init.rb 2011-08-17 14:25:57.280711956 +0400
20 20
rescue LoadError
21 21
end
22 22
require 'redcloth3'
23
require_dependency 'wiki_extensions_notifiable_patch'
23 24
Dir::foreach(File.join(File.dirname(__FILE__), 'lib')) do |file|
24 25
  next unless /\.rb$/ =~ file
25 26
  require file
redmine_wiki_extensions_with_notifications/lib/wiki_extensions_comments_mailer.rb 2011-08-17 14:27:03.088711967 +0400
1
require 'mailer'
2

  
3
class WikiExtensionsCommentsMailer < Mailer
4
  # Modifiyng view paths to make our mail-views visible for plugin
5
  self.instance_variable_get("@inheritable_attributes")[:view_paths] << RAILS_ROOT + "/vendor/plugins/redmine_wiki_extensions/app/views" 
6

  
7
  def wiki_commented(comment, wiki_page)
8
    project = wiki_page.project
9
    author = comment.user
10
    text = comment.comment
11
    redmine_headers 'Project' => project,
12
                    'Wiki-Page-Id' => wiki_page.id,
13
                    'Author' => author
14
    message_id wiki_page
15
    # Send notification to watchers of wiki page
16
    recipients wiki_page.watchers.collect{|watcher| watcher.user.mail}
17
    subject "[#{project.name} - Wiki - #{wiki_page.title}] commented"
18
    body = {
19
      :project => project,
20
      :author => author,
21
      :text => text,
22
      :wiki_page_title => wiki_page.title,
23
      :wiki_page_url => url_for(:controller => 'wiki', :action => 'show', :project_id => project, :id => wiki_page.title)
24
    }
25
    render_multipart('wiki_commented', body)
26
  end
27
end
redmine_wiki_extensions_with_notifications/lib/wiki_extensions_notifiable_patch.rb 2011-08-17 14:27:50.976711975 +0400
1
module WikiExtensionsNotifiablePatch
2
  def self.included(base) # :nodoc:
3
    @is_wrap = false 
4
    base.extend NotifiableMethods
5
    base.class_eval do
6
      unloadable
7
      class << self
8
        if !@is_wrap
9
          alias_method_chain :all, :wiki_comments
10
          @is_wrap = true
11
        end
12
      end
13
    end
14
  end
15
end
16

  
17
module NotifiableMethods
18
  def all_with_wiki_comments
19
    notifications = all_without_wiki_comments
20
    notifications << Redmine::Notifiable.new('wiki_comment_added')
21
    notifications
22
  end
23
end
24

  
25
Redmine::Notifiable.send(:include, WikiExtensionsNotifiablePatch)
    (1-1/1)