Wiki::Toolkit::Plugin::Diff(3pm) | User Contributed Perl Documentation | Wiki::Toolkit::Plugin::Diff(3pm) |
Wiki::Toolkit::Plugin::Diff - format differences between two Wiki::Toolkit pages
use Wiki::Toolkit::Plugin::Diff; my $plugin = Wiki::Toolkit::Plugin::Diff->new; $wiki->register_plugin( plugin => $plugin ); # called before any node reads my %diff = $plugin->differences( node => 'Imperial College', left_version => 3, right_version => 5);
A plug-in for Wiki::Toolkit sites, which provides a nice extract of differences between two versions of a node.
differences
my %diff_vars = $plugin->differences( node => "Home Page", left_version => 3, right_version => 5 );
Takes a series of key/value pairs:
The node version whose content we're considering canonical.
The node version that we're showing the differences from.
Filter the list of metadata fields to only include a certain list in the diff output. The default is to include all metadata fields.
Filter the list of metadata fields to exclude certain fields
from the diff output. The default is the following list, to match
previous version (OpenGuides) behaviour:
"qw(
username
comment
__categories__checksum
__locales__checksum )"
Agreed this list is hopelessly inadequate, especially for OpenGuides. Hopefully, future wiki designers will use the meta_include parameter to specify exactly what metadata they want to appear on the diff.
The differences method returns a list of key/value pairs, which can be assigned to a hash:
Usually you will want to feed this through a templating system, such as Template Toolkit, which makes iterating the AoH very easy.
Wiki::Toolkit::Plugin::Diff allows for a more flexible approach than HTML only rendering of pages. In particular, there are optional parameters to the constructor which control fine detail of the resultant output.
If this is not sufficient, the module is also subclassable, and the programmer can supply alternative methods.
Most of these are called internally by the plugin, but provide hooks for alternative code if the module is subclassed.
my $plugin = Wiki::Toolkit::Plugin::Diff->new( option => value, option => value...);
Here, option can be one of the following:
&.+?; #HTML special characters e.g. < |<br\s*/> #Line breaks |\w+\s* #Word with trailing spaces |. #Any other single character
Currently, this is hardcoded to present the differences with HTML tags.
This module is a prime candidate for migration into VCS::Lite, where this functionality really belongs.
The default regexp absorbs trailing whitespace, to give a more readable result. However, if a word is followed by differing whitespace or no whitespace at all, this was throwing up a diff.
The get_token method supplied removes trailing whitespace from the key values before they are compared.
Move intradiff functionality into VCS::Lite.
Please use rt.cpan.org to report any bugs in this module. If you have any ideas for how this module could be enhanced, please email the author, or post to the Wiki::Toolkit list (cgi (hyphen) wiki (hyphen) dev (at) earth (dot) li).
I. P. Williams (ivorw_openguides [at] xemaps {dot} com) The Wiki::Toolkit team (http://www.wiki-toolkit.org/)
Copyright (C) 2003-2004 I. P. Williams (ivorw_openguides [at] xemaps {dot} com). Copyright (C) 2006 the Wiki::Toolkit team (http://www.wiki-toolkit.org/) All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
VCS::Lite, Wiki::Toolkit, Wiki::Toolkit::Plugin, OpenGuides
2022-06-14 | perl v5.34.0 |