Some wikis allow you to subscribe, such that you get e-mail notification. Some, like UseModWiki, will only allow notification for any page. Others (can't think of an example right now) allow you to subscribe on a page-by-page basis.

The Idea

I'd like to implement the latter for 'Tavi, without making it too messy. Here's what I'm thinking of; please comment!

Create a display macro, for example, "SendEmailWhenChanged", which looks like this:

 [[SendEmailWhenChanged smoonen@andstuff.org, joeuser@example.com, hi@there.com]]

Have it map to an empty function so that it doesn't even show up when a document is viewed. Create a separate save parser that looks for [[SendEmailWhenChanged ...]] and emails the given individuals a quick note when the page is saved.

Thoughts

This particular approach is ridiculously simple. No new mechanisms really need to be created as far as the script is concerned; just add your name to the list and you're done.

On the other hand, it's non-obvious. If a page doesn't already have a sign-up list, how would someone know they could sign up? Moreover, it clutters the page at edit-time with information that is not really meant to be in the page text itself.

Also, it would be possible to remove someone's name from the list. They'd never discover it, since they'd never receive a notification. Ideally, to fix that, we'd need to send e-mail to the union of the sets of email addresses on the saved version and the previous version. Which would get a little cumbersome.

And there's no way to request emails about any new pages that are created. That would be a handy way to alert people that there may be a new page they want to sign up for.

Conclusion

I don't know. I just thought of this idea, and it was simple enough that I thought it worthwhile writing out. But as I consider the downsides, it's not quite as flexible as most users would probably like it to be. However, implementing a full-fledged subscription service would be a little bit bigger of an undertaking.

Thoughts, anyone?

  • When the inevitable login project is complete, it shouldn't be a problem to add a checkbox that lets users opt into a list that will send a reminder when the page changes, either user or administrator configured, upon a choice of criteria. Nominally, I'd set something up that will send e-mail once or twice a day to notify users who chose to receie update reminders. It shouldn't be forced to send out every time it's updated, as there're users (like me) who don't know how to use the preview function, and would end up spamming someone's box as a result.

Another approach

While writing the code for it would take a little time another way to handle EmailNotification is to allow users to have a link in the footer which would allow a user to subscribe to the page. We'd need an interface for registration and perhaps a page which showed all the pages to which one subscribed with an option to remove pages. Obviously we'd need MySQL tables for all of this too.

Since we don't want every change to a page to send a notificationwe want to queue them until a quiet period has elapsed indicating that work on the page is completewe could write code in our page save mechanism that would:

  1. Run a query (after page content has been spent to the browser) that checks if anyone has requested notification for this page.
  2. If so, use ignore_user_abort(), set_time_limit(), and sleep() to hang out (without consuming CPU) for the duration of the quiet period.
  3. Run a query to see if subsequent updates have been made to the page.
  4. If not, send the email notifications.

Known limitations:

I'd argue; however, that this is better than nothing--and if notification is really needed, it is mostly likely needed in a timely manner. The once-a-day digest is easily replaced by a daily look at RecentChanges. If changes are infrequent enough that this would be impractical, then they probably won't be so frequent as to make page-change-notification offensive.

--John-Mason P. Shackelford


A possible solution

I wanted something simlar. I wrote a little perl script which I run once a day via cron. The recipient could be a mailinglist.

#!/usr/bin/perl

use strict;
use diagnostics;
use DBI;

my $dsn="DBI:mysql:<database>;host=localhost";		# EDIT Database 
my $dbuser="<user>";					# EDIT User
my $dbpass="<password>";				# EDIT Password
my $sender="sender\@domain.com";			# EDIT Senderadress
my $recipients="one\@domain.com two\@domain.com>";	# EDIT Recipients
my $url="http://www.domain.com/wiki/index.php?page=";   # EDIT Wiki URL
my $subject="Wiki Report";				# EDIT Subject
my $title;

my $dbh;
my $db_result;
my $result;
my $wikireport="";

#-------------------#
# Datenbank connect #
#-------------------#
$dbh=DBI->connect($dsn, $dbuser, $dbpass);
if (!$dbh){
	die "Error: " . $dbh->errstr . "\n";
}

$db_result=$dbh->prepare("SELECT DISTINCT(title) FROM pages WHERE time>DATE_SUB(now(), INTERVAL 1 DAY) ORDER BY title");

if (!$db_result){
	die "Error: " . $dbh->errstr . "\n";
}
if (!$db_result->execute()){
	die "Error: " . $dbh->errstr . "\n";
}

while ($result=$db_result->fetchrow_hashref()){
	$title=$result->{'title'};
	$title=~s/\s/+/g;
	$result->{'title'}=~s/^\s+//;
	$wikireport.=$result->{'title'} . "\n -> " . $url . $title . "\n";
}

if ($wikireport!~/^$/){
	open SENDMAIL, "|/usr/sbin/sendmail -f " . $sender . " " . $recipients || die "$0: $!\n";
	$recipients=~s/\s+/, /;
	print SENDMAIL "FROM: " . $sender . "\n";
	print SENDMAIL "TO: " . $recipients . "\n";
	print SENDMAIL "SUBJECT: " . $subject . "\n\n";
	print SENDMAIL $wikireport;
	close SENDMAIL;
}

-- Andreas Weigl