.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Wiki::Toolkit::Plugin::Diff 3pm" .TH Wiki::Toolkit::Plugin::Diff 3pm "2022-06-14" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Wiki::Toolkit::Plugin::Diff \- format differences between two Wiki::Toolkit pages .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 6 \& 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 => \*(AqImperial College\*(Aq, \& left_version => 3, \& right_version => 5); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A plug-in for Wiki::Toolkit sites, which provides a nice extract of differences between two versions of a node. .SH "BASIC USAGE" .IX Header "BASIC USAGE" \&\fBdifferences\fR .PP .Vb 5 \& my %diff_vars = $plugin\->differences( \& node => "Home Page", \& left_version => 3, \& right_version => 5 \& ); .Ve .PP Takes a series of key/value pairs: .IP "\(bu" 4 \&\fBleft_version\fR .Sp The node version whose content we're considering canonical. .IP "\(bu" 4 \&\fBright_version\fR .Sp The node version that we're showing the differences from. .IP "\(bu" 4 \&\fBmeta_include\fR .Sp Filter the list of metadata fields to only include a certain list in the diff output. The default is to include all metadata fields. .IP "\(bu" 4 \&\fBmeta_exclude\fR .Sp 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: \f(CW\*(C`qw( username comment _\|_categories_\|_checksum _\|_locales_\|_checksum )\*(C'\fR .Sp 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. .PP The differences method returns a list of key/value pairs, which can be assigned to a hash: .IP "\fBleft_version\fR" 4 .IX Item "left_version" The node version whose content we're considering canonical. .IP "\fBright_version\fR" 4 .IX Item "right_version" The node version that we're showing the differences from. .IP "\fBcontent\fR" 4 .IX Item "content" The (formatted) contents of the \fILeft\fR version of the node. .IP "\fBdiff\fR" 4 .IX Item "diff" An array of hashrefs of \f(CW\*(C`hunks\*(C'\fR of differences between the versions. It is assumed that the display will be rendered in \s-1HTML,\s0 and \s-1SPAN\s0 tags are inserted with a class of diff1 or diff2, to highlight which individual words have actually changed. Display the contents of diff using a , with each member of the array corresponding to a row <\s-1TR\s0>, and keys {left} and {right} being two columns <\s-1TD\s0>. .Sp Usually you will want to feed this through a templating system, such as Template Toolkit, which makes iterating the AoH very easy. .SH "ADVANCED" .IX Header "ADVANCED" Wiki::Toolkit::Plugin::Diff allows for a more flexible approach than \s-1HTML\s0 only rendering of pages. In particular, there are optional parameters to the constructor which control fine detail of the resultant output. .PP If this is not sufficient, the module is also subclassable, and the programmer can supply alternative methods. .SS "\s-1METHODS\s0" .IX Subsection "METHODS" Most of these are called internally by the plugin, but provide hooks for alternative code if the module is subclassed. .IP "\fBnew\fR" 4 .IX Item "new" .Vb 1 \& my $plugin = Wiki::Toolkit::Plugin::Diff\->new( option => value, option => value...); .Ve .Sp Here, \fIoption\fR can be one of the following: .RS 4 .IP "\fBmetadata_separator\fR" 4 .IX Item "metadata_separator" A string which is inserted between each metadata field, and also between the contents and the metadata. This defaults to \&\*(L"
\en\*(R" so as to render each metadata field on a new line. .IP "\fBline_number_format\fR" 4 .IX Item "line_number_format" Used to lay out the head line number for a difference hunk. The string is eval'ed with \f(CW$_\fR containing the line number. Default is \*(L"== Line \e$_ ==\*(R" . .IP "\fBword_matcher\fR" 4 .IX Item "word_matcher" is a regular expression, used to tokenize the input string. This is the way of grouping together atomic sequences, so as to give a readable result. The default is the following: .Sp .Vb 4 \& &.+?; #HTML special characters e.g. < \& | #Line breaks \& |\ew+\es* #Word with trailing spaces \& |. #Any other single character .Ve .RE .RS 4 .RE .IP "\fBdifferences\fR" 4 .IX Item "differences" see above. .IP "\fBline_number\fR" 4 .IX Item "line_number" This method is called to format a line number into a suitable string. The supplied routine performs the necessary substitution of \&\f(CW$self\fR\->{line_number_format} using eval. .IP "\fBserialise_metadata\fR" 4 .IX Item "serialise_metadata" The purpose of this method is to turn a metadata hash into a string suitable for diffing. .IP "\fBcontent_escape\fR" 4 .IX Item "content_escape" This method is used to apply the necessary quoting or escaping of characters that could appear in the content body, that could interfere with the rendering of the diff text. .IP "\fBintradiff\fR" 4 .IX Item "intradiff" This method turns an array of hunks as returned by VCS::Lite::Delta\->hunks into a side by side diff listing, with highlights indicating different words and punctuation. .Sp Currently, this is hardcoded to present the differences with \s-1HTML\s0 tags. .Sp This module is a prime candidate for migration into VCS::Lite, where this functionality really belongs. .IP "\fBget_token\fR" 4 .IX Item "get_token" This allows the \*(L"false positive\*(R" bug discovered by Earle Martin to be solved (rt.cpan.org #6284). Effectively, the input strings (diff1 and diff2) are tokenised using the word_matcher regexp (see above), and turned into arrays of tokens. .Sp 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. .Sp The get_token method supplied removes trailing whitespace from the key values before they are compared. .SH "TODO" .IX Header "TODO" Move intradiff functionality into VCS::Lite. .SH "BUGS AND ENHANCEMENTS" .IX Header "BUGS AND ENHANCEMENTS" 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). .SH "AUTHOR" .IX Header "AUTHOR" I. P. Williams (ivorw_openguides [at] xemaps {dot} com) The Wiki::Toolkit team (http://www.wiki\-toolkit.org/) .SH "COPYRIGHT" .IX Header "COPYRIGHT" .Vb 3 \& 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. .Ve .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" VCS::Lite, Wiki::Toolkit, Wiki::Toolkit::Plugin, OpenGuides