El Lunes 16 Mayo 2005 02:53, Brian Ingerson escribi�: > There is something about this patch that doesn't sit right with me... > > Why can't you just do a pre/page:store hook to grab the old content, > save it in memory, and then diff it with current content in a > post/page:store hook?
Or use data from archive and compare it with the new content. With this way I
can make the message body in a subscription to changes plugin [1]
my $revisions = $self->revision_numbers;
if ($#$revisions == 0) {
$subscription_obj->body($self->content);
} else {
my $revision_id = $#$revisions -1;
my $archive = $self->hub->archive;
# now the diff
my $current = [ split /\n/, $self->content ];
my $this_revision = [ split /\n/, $archive->fetch( $self,
$revision_id ) ];
my $body;
my @diff = Algorithm::Diff::diff( $this_revision, $current );
foreach my $chunk (@diff) {
foreach my $line (@$chunk) {
my ($sign, $lineno, $text) = @$line;
$body .= sprintf "%4d$sign %s\n", $lineno+1, $text;
}
$body .= "--------\n";
}
$subscription_obj->body($body);
}
[1]
https://barcelona.pm.org:8000/kwiki-subscription/trunk/lib/Kwiki/Subscription/Changes.pm
(in progress)
pgpLMVo6JH5uE.pgp
Description: signature
