* Removed support for sending commit notification mails. Along with it went

the svnrepo and notify settings, though both will be ignored if left in
  setup files.
master
Joey Hess 2008-01-29 00:36:58 -05:00
parent 2ff726e875
commit d7fdd04b5a
26 changed files with 33 additions and 341 deletions

View File

@ -62,7 +62,6 @@ sub defaultconfig () { #{{{
cgi => 0,
post_commit => 0,
rcs => '',
notify => 0,
url => '',
cgiurl => '',
historyurl => '',
@ -76,7 +75,6 @@ sub defaultconfig () { #{{{
w3mmode => 0,
wrapper => undef,
wrappermode => undef,
svnrepo => undef,
svnpath => "trunk",
gitorigin_branch => "origin",
gitmaster_branch => "master",

View File

@ -242,9 +242,6 @@ sub cgi_prefs ($$) { #{{{
$form->field(name => "do", type => "hidden");
$form->field(name => "email", size => 50, fieldset => "preferences");
$form->field(name => "subscriptions", size => 50,
fieldset => "preferences",
comment => "(".htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).")");
$form->field(name => "banned_users", size => 50,
fieldset => "admin");
@ -256,8 +253,6 @@ sub cgi_prefs ($$) { #{{{
if (! $form->submitted) {
$form->field(name => "email", force => 1,
value => userinfo_get($user_name, "email"));
$form->field(name => "subscriptions", force => 1,
value => userinfo_get($user_name, "subscriptions"));
if (is_admin($user_name)) {
$form->field(name => "banned_users", force => 1,
value => join(" ", get_banned_users()));
@ -274,11 +269,9 @@ sub cgi_prefs ($$) { #{{{
return;
}
elsif ($form->submitted eq 'Save Preferences' && $form->validate) {
foreach my $field (qw(email subscriptions)) {
if (defined $form->field($field)) {
userinfo_set($user_name, $field, $form->field($field)) ||
error("failed to set $field");
}
if (defined $form->field('email')) {
userinfo_set($user_name, 'email', $form->field('email')) ||
error("failed to set email");
}
if (is_admin($user_name)) {
set_banned_users(grep { ! is_admin($_) }

View File

@ -57,13 +57,6 @@ sub rcs_recentchanges ($) {
# }
}
sub rcs_notify () {
# This function is called when a change is committed to the wiki,
# and ikiwiki is running as a post-commit hook from the RCS.
# It should examine the repository to somehow determine what pages
# changed, and then send emails to users subscribed to those pages.
}
sub rcs_getctime ($) {
# Optional, used to get the page creation time from the RCS.
error gettext("getctime not implemented");

View File

@ -419,47 +419,6 @@ sub rcs_recentchanges ($) { #{{{
return @rets;
} #}}}
sub rcs_notify () { #{{{
# Send notification mail to subscribed users.
#
# In usual Git usage, hooks/update script is presumed to send
# notification mails (see git-receive-pack(1)). But we prefer
# hooks/post-update to support IkiWiki commits coming from a
# cloned repository (through command line) because post-update
# is called _after_ each ref in repository is updated (update
# hook is called _before_ the repository is updated).
#
# Here, we rely on a simple fact: we can extract all parts of the
# notification content by parsing the "HEAD" commit.
my $ci = git_commit_info('HEAD');
return if !defined $ci;
my @changed_pages = map { $_->{'file'} } @{ $ci->{'details'} };
my ($user, $message);
if (@{ $ci->{'comment'} }[0] =~ m/$config{web_commit_regexp}/) {
$user = defined $2 ? $2 : $3;
$message = $4;
}
else {
$user = $ci->{'author_username'};
$message = join "\n", @{ $ci->{'comment'} };
}
my $sha1 = $ci->{'sha1'};
require IkiWiki::UserInfo;
send_commit_mails(
sub {
$message;
},
sub {
join "\n", run_or_die('git', 'diff', "${sha1}^", $sha1);
}, $user, @changed_pages
);
} #}}}
sub rcs_getctime ($) { #{{{
my $file=shift;
# Remove srcdir prefix

View File

@ -151,10 +151,6 @@ sub rcs_recentchanges ($) { #{{{
return @ret;
} #}}}
sub rcs_notify () { #{{{
# TODO
} #}}}
sub rcs_getctime ($) { #{{{
my ($file) = @_;

View File

@ -452,54 +452,6 @@ sub rcs_recentchanges ($) { #{{{
return @ret;
} #}}}
sub rcs_notify () { #{{{
debug("The monotone rcs_notify function is currently untested. Use at own risk!");
if (! exists $ENV{REV}) {
error(gettext("REV is not set, not running from mtn post-commit hook, cannot send notifications"));
}
if ($ENV{REV} !~ m/($sha1_pattern)/) { # sha1 is untainted now
error(gettext("REV is not a valid revision identifier, cannot send notifications"));
}
my $rev = $1;
check_config();
my $automator = Monotone->new();
$automator->open(undef, $config{mtnrootdir});
my $certs = [read_certs($automator, $rev)];
my $user;
my $message;
my $when;
foreach my $cert (@$certs) {
if ($cert->{signature} eq "ok" && $cert->{trust} eq "trusted") {
if ($cert->{name} eq "author") {
$user = $cert->{value};
} elsif ($cert->{name} eq "date") {
$when = $cert->{value};
} elsif ($cert->{name} eq "changelog") {
$message = $cert->{value};
}
}
}
my @changed_pages = get_changed_files($automator, $rev);
$automator->close();
require IkiWiki::UserInfo;
send_commit_mails(
sub {
return $message;
},
sub {
`mtn --root=$config{mtnrootdir} au content_diff -r $rev`;
},
$user, @changed_pages);
} #}}}
sub rcs_getctime ($) { #{{{
my $file=shift;

View File

@ -217,44 +217,6 @@ sub rcs_recentchanges ($) { #{{{
return @ret;
} #}}}
sub rcs_notify () { #{{{
if (! exists $ENV{REV}) {
error(gettext("REV is not set, not running from svn post-commit hook, cannot send notifications"));
}
my $rev=int(possibly_foolish_untaint($ENV{REV}));
my $user=`svnlook author $config{svnrepo} -r $rev`;
chomp $user;
my $message=`svnlook log $config{svnrepo} -r $rev`;
if ($message=~/$config{web_commit_regexp}/) {
$user=defined $2 ? "$2" : "$3";
$message=$4;
}
my @changed_pages;
foreach my $change (`svnlook changed $config{svnrepo} -r $rev`) {
chomp $change;
if (length $config{svnpath}) {
if ($change =~ /^[A-Z]+\s+\Q$config{svnpath}\E\/(.*)/) {
push @changed_pages, $1;
}
}
else {
push @changed_pages, $change;
}
}
require IkiWiki::UserInfo;
send_commit_mails(
sub {
return $message;
},
sub {
`svnlook diff $config{svnrepo} -r $rev --no-diff-deleted`;
}, $user, @changed_pages);
} #}}}
sub rcs_getctime ($) { #{{{
my $file=shift;

View File

@ -160,51 +160,6 @@ sub rcs_recentchanges ($) {
return @ret;
}
sub rcs_notify () { #{{{
# FIXME: Not set
if (! exists $ENV{ARCH_VERSION}) {
error("ARCH_VERSION is not set, not running from tla post-commit hook, cannot send notifications");
}
my $rev=int(possibly_foolish_untaint($ENV{REV}));
eval q{use Mail::Header};
error($@) if $@;
open(LOG, $ENV{"ARCH_LOG"});
my $head = Mail::Header->new(\*LOG);
close(LOG);
my $user = $head->get("Creator");
my $newfiles = $head->get("New-files");
my $modfiles = $head->get("Modified-files");
my $remfiles = $head->get("Removed-files");
my @changed_pages = grep { !/(^.*\/)?\.arch-ids\/.*\.id$/ }
split(/ /, "$newfiles $modfiles $remfiles .arch-ids/fake.id");
require IkiWiki::UserInfo;
send_commit_mails(
sub {
my $message = $head->get("Summary");
if ($message =~ /$config{web_commit_regexp}/) {
$user=defined $2 ? "$2" : "$3";
$message=$4;
}
},
sub {
my $logs = `tla logs -d $config{srcdir}`;
my @changesets = reverse split(/\n/, $logs);
my $i;
for($i=0;$i<$#changesets;$i++) {
last if $changesets[$i] eq $rev;
}
my $revminusone = $changesets[$i+1];
`tla diff -d $ENV{ARCH_TREE_ROOT} $revminusone`;
}, $user, @changed_pages);
} #}}}
sub rcs_getctime ($) { #{{{
my $file=shift;
eval q{use Date::Parse};

View File

@ -92,91 +92,4 @@ sub set_banned_users (@) { #{{{
return userinfo_store($userinfo);
} #}}}
sub commit_notify_list ($@) { #{{{
my $committer=shift;
my @pages = map pagename($_), @_;
my @ret;
my $userinfo=userinfo_retrieve();
foreach my $user (keys %{$userinfo}) {
next if $user eq $committer;
if (exists $userinfo->{$user}->{subscriptions} &&
length $userinfo->{$user}->{subscriptions} &&
exists $userinfo->{$user}->{email} &&
length $userinfo->{$user}->{email} &&
grep { pagespec_match($_,
$userinfo->{$user}->{subscriptions},
user => $committer) }
map pagename($_), @_) {
push @ret, $userinfo->{$user}->{email};
}
}
return @ret;
} #}}}
sub send_commit_mails ($$$@) { #{{{
my $messagesub=shift;
my $diffsub=shift;
my $user=shift;
my @changed_pages=@_;
return unless @changed_pages;
my @email_recipients=commit_notify_list($user, @changed_pages);
if (@email_recipients) {
# TODO: if a commit spans multiple pages, this will send
# subscribers a diff that might contain pages they did not
# sign up for. Should separate the diff per page and
# reassemble into one mail with just the pages subscribed to.
my $diff=$diffsub->();
my $message=$messagesub->();
my $pagelist;
if (@changed_pages > 2) {
$pagelist="$changed_pages[0] $changed_pages[1] ...";
}
else {
$pagelist.=join(" ", @changed_pages);
}
#translators: The three variables are the name of the wiki,
#translators: A list of one or more pages that were changed,
#translators: And the name of the user making the change.
#translators: This is used as the subject of a commit email.
my $subject=sprintf(gettext("update of %s's %s by %s"),
$config{wikiname}, $pagelist, $user);
my $template=template("notifymail.tmpl");
$template->param(
wikiname => $config{wikiname},
diff => $diff,
user => $user,
message => $message,
);
# Daemonize, in case the mail sending takes a while.
defined(my $pid = fork) or error("Can't fork: $!");
return if $pid;
setsid() or error("Can't start a new session: $!");
chdir '/';
open STDIN, '/dev/null';
open STDOUT, '>/dev/null';
open STDERR, '>&STDOUT' or error("Can't dup stdout: $!");
unlockwiki(); # don't need to keep a lock on the wiki
eval q{use Mail::Sendmail};
error($@) if $@;
foreach my $email (@email_recipients) {
sendmail(
To => $email,
From => "$config{wikiname} <$config{adminemail}>",
Subject => $subject,
Message => $template->output,
);
}
exit 0; # daemon process done
}
} #}}}
1

View File

@ -36,22 +36,6 @@ sub gen_wrapper () { #{{{
addenv("$var", s);
EOF
}
if ($config{rcs} eq "svn" && $config{notify}) {
# Support running directly as hooks/post-commit by passing
# $2 in REV in the environment.
$envsave.=<<"EOF"
if (argc == 3)
addenv("REV", argv[2]);
else if ((s=getenv("REV")))
addenv("REV", s);
EOF
}
if ($config{rcs} eq "tla" && $config{notify}) {
$envsave.=<<"EOF"
if ((s=getenv("ARCH_VERSION")))
addenv("ARCH_VERSION", s);
EOF
}
$Data::Dumper::Indent=0; # no newlines
my $configstring=Data::Dumper->Dump([\%config], ['*config']);

3
debian/changelog vendored
View File

@ -23,6 +23,9 @@ ikiwiki (2.21) UNRELEASED; urgency=low
function.
* Pages with extensions starting with "_" are internal-use, and will
not be rendered or web-edited.
* Removed support for sending commit notification mails. Along with it went
the svnrepo and notify settings, though both will be ignored if left in
setup files.
-- Joey Hess <joeyh@debian.org> Fri, 11 Jan 2008 15:09:37 -0500

View File

@ -1,3 +1,5 @@
[[done]] (in this branch); fixed removing email notification support!
I was suprised to receive two mails from ikiwiki about one web edit:
1 F Oct 30 To joey+ikiwiki update of ikiwiki's plugins/contrib/gallery.mdwn by http://arpitjain11.myopenid.com/

View File

@ -127,7 +127,7 @@ with that there's no new commit marker syntax to learn.
Nearly the definition of a wiki, although perhaps ikiwiki challenges how
much of that web gunk a wiki really needs. These features are optional
and can be enabled by enabling [[CGI]].
and can be enabled by enabling [[CGI]] and a [[Revision_Control_Systems|rcs]].
### User registration
@ -161,11 +161,6 @@ Well, sorta. Rather than implementing YA history browser, it can link to
ikiwiki can use the [[HyperEstraier]] search engine to add powerful
full text search capabilities to your wiki.
### Commit mails
ikiwiki can be configured to send you commit mails with diffs of changes
to selected pages.
### [[w3mmode]]
Can be set up so that w3m can be used to browse a wiki and edit pages

View File

@ -23,7 +23,6 @@ use IkiWiki::Setup::Standard {
#rcs => "svn",
#historyurl => "http://svn.example.org/trunk/[[file]]",
#diffurl => "http://svn.example.org/trunk/[[file]]?root=wiki&amp;r1=[[r1]]&amp;r2=[[r2]]",
#svnrepo => "/svn/wiki",
#svnpath => "trunk",
# Git stuff.
@ -72,8 +71,6 @@ use IkiWiki::Setup::Standard {
# # what you want.
# wrapper => "/svn/wikirepo/hooks/post-commit",
# wrappermode => "04755",
# # Enable mail notifications of commits.
# notify => 1,
# # Log to syslog since svn post-commit hooks
# # hide output and errors.
# syslog => 1,

View File

@ -405,6 +405,9 @@ I'm playing around with various ways that I can use subversion with ikiwiki.
> away without running the post-commit wrapper on commit, and all you lose
> is the ability to send commit notification emails.
> (And now that [[recentchanges]] includes rss, you can just subscribe to
> that, no need to worry about commit notification emails anymore.)
* Is it possible / sensible to have ikiwiki share a subversion repository with other data (either completely unrelated files or another ikiwiki instance)? This works in part but again the post-commit hook seems problematic.
--[[AdamShand]]

View File

@ -10,7 +10,6 @@ The module is available from the monotone source repository at:
Monotone support works, but there are still a few minor missing bits (listed here so they are not forgotten):
* At the moment there are no links to display diffs between revisions. It shouldn't be hard to add links to a [ViewMTN](http://grahame.angrygoats.net/moinmoin/ViewMTN) instance, but it hasn't been done yet.
* The [[post-commit]] hook support, so that Ikiwiki sends change notifications when people commit using Monotone rather than the web interface, is partially implemented and untested.
* Documentation (this page) could be improved.
There is also a mismatch between the way Ikiwiki handles conflicts and the way Monotone handles conflicts. At present, if there is a conflict, then Ikiwiki will commit a revision with conflict markers before presenting it to the user. This is ugly, but there is no clean way to fix it at present.

View File

@ -180,8 +180,7 @@ about using the git repositories.
Once your wiki is checked in to the revision control system,
you should configure ikiwiki to use revision control. Edit your
ikiwiki.setup, and uncomment the lines for the revision control system
you chose to use. Be sure to set `svnrepo` to $REPOSITORY, if using
subversion. Uncomment the block for the wrapper for your revision
you chose to use. Uncomment the block for the wrapper for your revision
control system, and configure the wrapper path in that block
appropriately (for Git, it should be `$REPOSITORY/hooks/post-update`).

View File

@ -3,4 +3,8 @@ user to add a page to their subscribed list while editing. This would prove
particularly useful for [[todo]] and [bug](bugs) items, to allow users to receive
notifications for activity on their reports.
--[[JoshTriplett]]
--[[JoshTriplett]]
I went and removed commit notification mails entirely, the idea is that you
subscribe using the [[RecentChanges]] rss feed, and filter it on your end.
Good enough? --[[Joey]]

View File

@ -4,6 +4,8 @@ rcs_commit was only changed to work around bzr's lack of a switch to set the
username). bzr_log could probably be written better by someone better at perl,
and rcs_getctime and rcs_notify aren't written at all. --[[bma]]
(rcs_notify is not needed in this branch --[[Joey]])
#!/usr/bin/perl
use warnings;

View File

@ -1,6 +1,6 @@
* Need to get post commit hook working (or an example of how to use it.)
* See below. --[[bma]]
* rcs_notify is not implemented
* rcs_notify is not implemented (not needed in this branch --[[Joey]])
* Is the code sufficiently robust? It just warns when mercurial fails.
* When rcs_commit is called with a $user that is an openid, it will be
passed through to mercurial -u. Will mercurial choke on this?

View File

@ -133,11 +133,6 @@ configuration options of their own.
access controlled by a group, it makes sense for the ikiwiki wrappers
to run setgid to that group.
* --notify, --no-notify
Enable email notification of commits. This should be used when running
ikiwiki as a [[post-commit]] hook.
* --rcs=svn|git|.., --no-rcs
Enable or disable use of a [[revision_control_system|rcs]].
@ -151,11 +146,6 @@ configuration options of their own.
No revision control is enabled by default.
* --svnrepo /svn/wiki
Specify the location of the svn repository for the wiki. This is required
for using --notify with [[Subversion|rcs/svn]].
* --svnpath trunk
Specify the path inside your svn repository where the wiki is located.

View File

@ -11,9 +11,6 @@ located in /usr/share/ikiwiki/templates by default.
* `misc.tmpl` - Generic template used for any page that doesn't
have a custom template.
* `editpage.tmpl` - Create/edit page.
* `notifymail.tmpl` - Not a html template, this is used to
generate change notification mails for users who have subscribed to
changes to a page.
* `recentchanges.tmpl` - Used to generate a RecentChanges table with inline.
* `change.tmpl` - Used to create a page describing a change made to the wiki.
* `passwordmail.tmpl` - Not a html template, this is used to

View File

@ -15,5 +15,10 @@ use IkiWiki::Setup::Standard {
syslog => 0,
userdir => "users",
usedirs => 0,
add_plugins => [qw{goodstuff version haiku polygen fortune}],
rcs => 'git',
rss => 1,
cgiurl => "http://ikiwiki.info/ikiwiki.cgi",
url => "http://ikiwiki.info",
add_plugins => [qw{goodstuff version haiku polygen fortune
recentchanges }],
}

View File

@ -36,12 +36,10 @@ sub getconfig () { #{{{
"cgi!" => \$config{cgi},
"discussion!" => \$config{discussion},
"w3mmode!" => \$config{w3mmode},
"notify!" => \$config{notify},
"url=s" => \$config{url},
"cgiurl=s" => \$config{cgiurl},
"historyurl=s" => \$config{historyurl},
"diffurl=s" => \$config{diffurl},
"svnrepo" => \$config{svnrepo},
"svnpath" => \$config{svnpath},
"adminemail=s" => \$config{adminemail},
"timeformat=s" => \$config{timeformat},
@ -132,10 +130,7 @@ sub main () { #{{{
commandline_render();
}
elsif ($config{post_commit} && ! commit_hook_enabled()) {
if ($config{notify}) {
loadindex();
rcs_notify();
}
# do nothing
}
else {
lockwiki();
@ -143,7 +138,6 @@ sub main () { #{{{
require IkiWiki::Render;
rcs_update();
refresh();
rcs_notify() if $config{notify};
saveindex();
}
} #}}}

View File

@ -21,13 +21,14 @@ BEGIN { use_ok("IkiWiki"); }
%config=IkiWiki::defaultconfig();
$config{rcs} = "svn";
$config{srcdir} = "$dir/src";
$config{svnrepo} = "$dir/repo";
$config{svnpath} = "trunk";
IkiWiki::checkconfig();
system "svnadmin create $config{svnrepo} >/dev/null";
system "svn mkdir file://$config{svnrepo}/trunk -m add >/dev/null";
system "svn co file://$config{svnrepo}/trunk $config{srcdir} >/dev/null";
my $svnrepo = "$dir/repo";
system "svnadmin create $svnrepo >/dev/null";
system "svn mkdir file://$svnrepo/trunk -m add >/dev/null";
system "svn co file://$svnrepo/trunk $config{srcdir} >/dev/null";
# Web commit
my $test1 = readfile("t/test1.mdwn");

View File

@ -1,4 +0,0 @@
The following change was made by <TMPL_VAR USER>:
<TMPL_VAR MESSAGE>
<TMPL_VAR DIFF>