CGI-Wiki-Plugin-Diff
view release on metacpan or search on metacpan
lib/CGI/Wiki/Plugin/Diff.pm view on Meta::CPAN
sub serialise_metadata {
my $self = shift;
my ($all_meta,$include,$exclude) = validate_pos ( @_,
{ type => HASHREF },
{ type => ARRAYREF | UNDEF, optional => 1 },
{ type => ARRAYREF | UNDEF, optional => 1 },
);
$include ||= [keys %$all_meta];
$exclude ||= [qw(comment username
__categories__checksum __locales__checksum)] ;
my %metadata = map {$_,$all_meta->{$_}} @$include;
delete $metadata{$_} for @$exclude;
join $self->{metadata_separator},
map {"$_='".join (',',sort @{$metadata{$_}})."'"}
sort keys %metadata;
}
sub content_escape {
lib/CGI/Wiki/Plugin/Diff.pm view on Meta::CPAN
=item *
B<meta_exclude>
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:
C<qw(
username
comment
__categories__checksum
__locales__checksum )>
Agreed this list is hopelessly inadequate, especially for L<OpenGuides>.
Hopefully, future wiki designers will use the meta_include parameter to
specify exactly what metadata they want to appear on the diff.
=back
The differences method returns a list of key/value pairs, which can be
assigned to a hash:
t/01_add_test_data.t view on Meta::CPAN
}
);
my %j2 = $wiki->retrieve_node( "Jerusalem Tavern");
$wiki->write_node( "Jerusalem Tavern",
"Tiny pub in Clerkenwell with St Peter's beer.
Near Farringdon station",
$j2{checksum},
{ category => [ "Pubs", "Real Ale" ],
locale => [ "Farringdon" ]
}
);
my %j3 = $wiki->retrieve_node( "Jerusalem Tavern");
$wiki->write_node( "Jerusalem Tavern",
"Tiny pub in Clerkenwell with St Peter's beer but no food.
Near Farringdon station",
$j3{checksum},
{ category => [ "Pubs", "Real Ale" ],
locale => [ "Farringdon" ]
}
);
$wiki->write_node( "IvorW",
"
In real life: Ivor Williams
Ideas & things to work on:
* Threaded discussion wiki
t/02_diff.t view on Meta::CPAN
right_version => 3);
is( @{$metadiff{diff}}, 2, "Differ returns 2 elements for meta diff");
is_deeply( $metadiff{diff}[0], {
left => "== Line 2 ==\n",
right => "== Line 2 ==\n"},
"First element is line number on right");
is_deeply( $metadiff{diff}[1], {
left => "category='Pubs'",
right => "category='Pubs".
'<span class="diff2">,Real Ale\'<br />'.
"\nlocale='Farringdon</span>'",
},
"Differences highlights metadata diff with span tags");
# Another body diff with bracketed content
%bodydiff = $differ->differences(
node => 'IvorW',
left_version => 1,
right_version => 2);
is_deeply( $bodydiff{diff}[0], {
left => "== Line 11 ==\n",
( run in 0.559 second using v1.01-cache-2.11-cpan-ceb78f64989 )