- update to 0.04

- assign to perl@
This commit is contained in:
Yen-Ming Lee 2006-04-26 22:49:06 +00:00
parent cc44b4a379
commit 12b1aaeb7e
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=160550
3 changed files with 10 additions and 213 deletions

View File

@ -6,32 +6,28 @@
#
PORTNAME= Kwiki-Notify-Mail
PORTVERSION= 0.03
PORTREVISION= 2
PORTVERSION= 0.04
CATEGORIES= www perl5
MASTER_SITES= ${MASTER_SITE_PERL_CPAN}
MASTER_SITE_SUBDIR= Kwiki
PKGNAMEPREFIX= p5-
MAINTAINER= ports@FreeBSD.org
MAINTAINER= perl@FreeBSD.org
COMMENT= Send email notification of topic updates
BUILD_DEPENDS= ${SITE_PERL}/Kwiki.pm:${PORTSDIR}/www/p5-Kwiki
RUN_DEPENDS= ${BUILD_DEPENDS} \
${SITE_PERL}/MIME/Lite.pm:${PORTSDIR}/mail/p5-MIME-Lite \
${SITE_PERL}/Kwiki/Diff.pm:${PORTSDIR}/www/p5-Kwiki-Diff
RUN_DEPENDS= ${SITE_PERL}/Kwiki.pm:${PORTSDIR}/www/p5-Kwiki \
${SITE_PERL}/MIME/Lite.pm:${PORTSDIR}/mail/p5-MIME-Lite
BUILD_DEPENDS= ${RUN_DEPENDS}
BUILD_DEPENDS+= ${SITE_PERL}/Test/More.pm:${PORTSDIR}/devel/p5-Test-Simple
PERL_CONFIGURE= yes
MAN3= Kwiki::Notify::Mail.3
post-patch:
${FIND} ${WRKSRC} -name '*.orig' -print0 | ${XARGS} -0 ${RM}
.include <bsd.port.pre.mk>
.if ${PERL_LEVEL} < 500601
IGNORE= This port requires perl 5.6.x or later. Install lang/perl5 then try again
IGNORE= requires perl 5.6.x or later. Install lang/perl5 then try again
.endif
post-install:

View File

@ -1,3 +1,3 @@
MD5 (Kwiki-Notify-Mail-0.03.tar.gz) = abfcffdbfb3bfe2ea7dc9133964494f9
SHA256 (Kwiki-Notify-Mail-0.03.tar.gz) = 31529daa51fc9688d122743f4202a4430ff85fd5ee0a43e8fb4c1cdba4125908
SIZE (Kwiki-Notify-Mail-0.03.tar.gz) = 3940
MD5 (Kwiki-Notify-Mail-0.04.tar.gz) = 62423894f27d642a6cca4687e78c11cc
SHA256 (Kwiki-Notify-Mail-0.04.tar.gz) = 5a7d8e32035db501a76fa3f0fb8f60c15cb2cf7057dfcce03fa46126c04693a2
SIZE (Kwiki-Notify-Mail-0.04.tar.gz) = 4958

View File

@ -1,199 +0,0 @@
--- lib/Kwiki/Notify/Mail.pm.orig Tue Jan 25 20:49:23 2005
+++ lib/Kwiki/Notify/Mail.pm Mon Jun 6 11:19:17 2005
@@ -6,6 +6,7 @@
use Kwiki::Plugin '-Base';
use mixin 'Kwiki::Installer';
use MIME::Lite;
+use CGI;
our $VERSION = '0.03';
@@ -26,26 +27,82 @@
);
}
+sub recipient_list {
+ my $notify_mail_obj = $self->hub->load_class('notify_mail');
+ my $mail_to = $notify_mail_obj->config->notify_mail_to;
+ my $topic = $notify_mail_obj->config->notify_mail_topic;
+ my $meta_data = $self->hub->edit->pages->current->metadata;
+ my $who = $meta_data->{edit_by};
+ my $page_name = $meta_data->{id};
+ my ($cfg, $page, $email);
+
+ return undef unless defined $mail_to && defined $who && defined $page_name;
+
+ # Support for a notify_mail_topic configuration entry giving a page from
+ # which notification info can be read.
+ $cfg = $self->hub->pages->new_page($topic);
+ if (defined $cfg) {
+ foreach (split(/\n/, $cfg->content)) {
+ s/#.*//;
+ next if /^\s*$/;
+ unless (($page, $email) = /^([^:]+):\s*(.+)/) {
+ print STDERR "Kwiki::Notify::Mail: Unregognised line in ",
+ $topic, ": ", $_, "\n";
+ next;
+ }
+ next unless $page_name =~ /^$page$/;
+ $mail_to .= " " . $email;
+ }
+ }
+
+ return $mail_to;
+}
+
sub notify {
my $hook = pop;
- my $page = shift;
+ my $page = $self->hub->edit->pages->current;
my $notify_mail_obj = $self->hub->load_class('notify_mail');
-
- my $meta_data = $self->hub->edit->pages->current->metadata;
+ my $meta_data = $page->metadata;
my $site_title = $self->hub->config->site_title;
-
my $edited_by = $meta_data->{edit_by} || 'unknown name';
my $page_name = $meta_data->{id} || 'unknown page';
- my $to = $notify_mail_obj->config->notify_mail_to || 'unknown@unknown';
+ my $to = $notify_mail_obj->recipient_list();
+ return $self unless $to;
+
my $from = $notify_mail_obj->config->notify_mail_from || 'unknown';
my $subject = sprintf($notify_mail_obj->config->notify_mail_subject,
$site_title,
$page_name,
$edited_by) || 'unknown';
+ $subject =~ s/\$1/$site_title/g;
+ $subject =~ s/\$2/$page_name/g;
+ $subject =~ s/\$3/$edited_by/g;
+
+ my $body;
+
+ my $revs = $self->revision_numbers;
+ if ($#$revs > 0) {
+ $body = "$site_title page $page_name edited by $edited_by\n\n";
+
+ $body .= "See " . CGI::url() . "?action=diff&page_name=" . $page_name .
+ "&revision_id=" . $revs->[1] . "\n\n"
+ if $self->hub->have_plugin('diff');
+
+ if ($notify_mail_obj->config->notify_mail_inline_diff) {
+ my $oldname = $self->file_path . ".rev-" . $revs->[1];
+ open (OLD, ">", $oldname);
+ print OLD $self->hub->archive->fetch($page, $revs->[1]);
+ close OLD;
+ $body .= "Diffs are as follows:\n\n";
+ $body .= io("/usr/bin/diff -u $oldname " . $self->file_path .
+ " |")->utf8->all;
+ unlink $oldname;
+ }
+ } else {
+ $body = "$site_title page $page_name created by $edited_by";
+ }
- my $body = "$site_title page $page_name edited by $edited_by\n";
-
- $notify_mail_obj->mail_it($to,$from,$subject,$body);
+ $notify_mail_obj->mail_it($to,$from,$subject,$body) if $to;
return $self;
}
@@ -96,9 +153,11 @@
=head1 DESCRIPTION
-This module allows you to notify yourself by email when some one
-updates a page. You can specify the To:, From: and Subject: headers,
-but the email message body is not currently configurable.
+This module allows you to notify people by email when a page is updated.
+You can specify the To:, From: and Subject: headers, and the mail body
+may include unified diffs. Furthermore, if the Kwiki::Diff module is
+installed, a link to an sdiff of the changes is also provided in the
+mail body.
A sample email looks like:
@@ -121,7 +180,27 @@
=item * notify_mail_to
-Specify the mail address you are sending to.
+Specify the mail address you are sending to. Email will be sent to these
+addresses for all page updates.
+
+=item * notify_mail_topic
+
+Specify the mail topic or ConfigPage that is used to decide who to send mail
+to. The ConfigPage is of the format
+
+ WikiPage: email@domain.com
+
+WikiPage may be given as a regular expression, and multiple email addresses
+may be given. For example:
+
+ HomePage: me@my.domain.com
+ .*: bigmailbox@my.domain.com
+ Doc.*: docs@my.domain.com me@my.domain.com
+
+=item * notify_mail_inline_diff
+
+Specify whether inline unified diffs should be added to the mail body. The
+default is 1 -- diffs are included.
=item * notify_mail_from
@@ -131,9 +210,10 @@
Specify a subject line for the mail message. You can make use of
sprintf()-type formatting codes (%s is the only one that is relevant).
-If you put or more %s in the configuration directive it will print out
-the site title, page name and whom it was edited by. You can can't
-change the order, however.
+If you put one or more %s in the configuration directive it will print out
+the site title, page name and whom it was edited by. You may also put
+$1, $2 and/or $3 in the subject line. They will be replaced with the site
+title, the page name and whom it was edited by respectively.
Examples:
@@ -168,8 +248,16 @@
Subject: My wiki ProjectDiscussion page NextWeeksAgenda was updated
by PointyHairedBoss
-The important thing to remember is that you can have either none or one or two
-or three %s, but you can't change the order. The default value is
+The important thing to remember is that when using %s, you can't change the
+order of argument substitution. To do that, you need something like this:
+
+ notify_mail_subject: $3 has updated $2 on $1
+
+gives you the Subject: line
+
+ Subject: PointyHairedBoss has updated NextWeeksAgenda on ProjectDiscussion
+
+The default value is
notify_mail_subject: %s wiki page %s updated by %s
@@ -194,9 +282,6 @@
=head1 BUGS
-The subject line configuration relies on sprintf() which doesn't allow
-you to change the order of what gets printed out.
-
The debug file is saved to /tmp and should be user configurable. This
module was not tested under Windows and certainly /tmp doesn't exist
there.
@@ -215,7 +300,9 @@
=cut
__config/notify_mail.yaml__
-notify_mail_to: nobody@nobody.abc
+notify_mail_to:
+notify_mail_topic: NotifyMail
+notify_mail_inline_diff: 1
notify_mail_from: nobody
notify_mail_subject: %s wiki page %s updated by %s
notify_mail_debug: 0