Wiki-Toolkit-Plugin-RSS-Reader-1.6/ 0002755 0001750 0001750 00000000000 11123505730 015126 5 ustar dom dom Wiki-Toolkit-Plugin-RSS-Reader-1.6/README 0000444 0001750 0001750 00000001503 11123505726 016006 0 ustar dom dom NAME
Wiki::Toolkit::Plugin::RSS::Reader - retrieve RSS feeds for inclusion in
Wiki::Toolkit nodes
DESCRIPTION
Use this Wiki::Toolkit plugin to retrieve an RSS feed from a given URL so
that you can include it in a wiki node.
INSTALLATION
perl Build.PL
./Build
./Build test
./Build install
A passthrough Makefile.PL is included for convenience; it will prompt you to
install Module::Build if you don't already have it.
USAGE
This is a plugin for Wiki::Toolkit, a toolkit for building wikis; therefore
please consult the documentation for Wiki::Toolkit for relevant information.
This module can, however, be used standalone if you wish.
AUTHOR
Earle Martin (EMARTIN@cpan.org)
LEGAL
Copyright 2004 Earle Martin.
This module is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Wiki-Toolkit-Plugin-RSS-Reader-1.6/SIGNATURE 0000644 0001750 0001750 00000002247 11123505730 016415 0 ustar dom dom This file contains message digests of all files listed in MANIFEST,
signed via the Module::Signature module, version 0.55.
To verify the content in this distribution, first make sure you have
Module::Signature installed, then type:
% cpansign -v
It will check each file's integrity, as well as the signature's
validity. If "==> Signature verified OK! <==" is not displayed,
the distribution may already have been compromised, and you should
not run its Makefile.PL or Build.PL.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
SHA1 61244c442b685ba429220943446a3f54b6fd9358 Build.PL
SHA1 f0c0d1fb04076eafa1b0f5f5646cb9f7b9099b14 CHANGES
SHA1 b97098d27809b2f51fbdfddbe8dd194b29c110df MANIFEST
SHA1 5216088c6a5ba2693cdf9d0d6ad0dc8fad69d3ef META.yml
SHA1 9fac6f034ce9889fcc0916351df871264de7b8f8 Makefile.PL
SHA1 cb46d19e200ef909ef4d73cad2e5de37fd10a613 README
SHA1 e45d2a44f5b633789e1874f9b358e1add7f99721 lib/Wiki/Toolkit/Plugin/RSS/Reader.pm
SHA1 c34dd7748ee3116d54b4318781cb2d63b78772c3 t/rss.t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iD8DBQFJTovWYzuFKFF44qURAv4eAJ0Y+qPGjNMv2Osr0sHFup+o3S55jwCg5ARF
OWa/dsUBHLFuL+jVq28/gLM=
=+poB
-----END PGP SIGNATURE-----
Wiki-Toolkit-Plugin-RSS-Reader-1.6/META.yml 0000444 0001750 0001750 00000001110 11123505726 016371 0 ustar dom dom ---
name: Wiki-Toolkit-Plugin-RSS-Reader
version: 1.6
author:
- |-
Earle Martin (EMARTIN@cpan.org)
The Wiki::Toolkit team, (http://www.wiki-toolkit.org/)
abstract: retrieve RSS feeds for inclusion in Wiki::Toolkit nodes
license: perl
resources:
license: http://dev.perl.org/licenses/
requires:
LWP::Simple: 0
XML::RSS: 0
provides:
Wiki::Toolkit::Plugin::RSS::Reader:
file: lib/Wiki/Toolkit/Plugin/RSS/Reader.pm
version: 1.6
generated_by: Module::Build version 0.280801
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
Wiki-Toolkit-Plugin-RSS-Reader-1.6/MANIFEST 0000444 0001750 0001750 00000000215 11123505726 016256 0 ustar dom dom Build.PL
CHANGES
lib/Wiki/Toolkit/Plugin/RSS/Reader.pm
MANIFEST
Makefile.PL
META.yml
README
t/rss.t
SIGNATURE Added here by Module::Build
Wiki-Toolkit-Plugin-RSS-Reader-1.6/CHANGES 0000444 0001750 0001750 00000001073 11123505726 016123 0 ustar dom dom 2008-12-12: 1.6
* Ensure that the unit test cleans up its temporary file
(RT #41500; thanks ANDK)
2006-05-14: 1.5
* Move to Wiki::Toolkit name.
2004-10-21: 1.4
* Add descriptions to RSS items as per request from Kake Pugh.
2004-06-03: 1.3
* Fixed a bug with handling of RSS 2.0 GUIDs that was spotted by
Dominic Hargreaves.
2004-05-07: 1.2
* Added support for RSS 2.0.
2004-05-06: 1.1
* Improved error reporting a bit.
2004-05-04: 1
* Initial release.
Wiki-Toolkit-Plugin-RSS-Reader-1.6/t/ 0002755 0001750 0001750 00000000000 11123505726 015376 5 ustar dom dom Wiki-Toolkit-Plugin-RSS-Reader-1.6/t/rss.t 0000555 0001750 0001750 00000005266 11123505726 016402 0 ustar dom dom #!/usr/bin/perl
use warnings;
use strict;
# -------------------------------------------------
# Here we fake connecting to the Net and getting
# back an RSS file. Thanks to Mark Fowler for this.
package LWP::Simple;
use vars qw(@EXPORT $RSS);
use base qw(Exporter);
@EXPORT = qw(get);
$RSS = qq{
Example
http://example.com/
Example item 1
http://example.com/1.html
The first example.Example item 2
http://example.com/2.html
The second example.Example item 3
http://example.com/3.html
The third example.};
sub get
{
return $RSS;
}
$INC{"LWP/Simple.pm"} = 1;
# -------------------------------------------------
package main;
use Test::More tests => 9;
# Create a temporary file, fill it with the RSS we defined
# earlier in the fake LWP::Simple.
use File::Temp;
# Use OO version of File::Temp; file will be unlinked when $tmp goes
# out of scope
my $tmp = new File::Temp;
my $rss_file = $tmp->filename;
print $tmp $LWP::Simple::RSS;
close $tmp;
#1
use_ok("Wiki::Toolkit::Plugin::RSS::Reader");
my $rss = Wiki::Toolkit::Plugin::RSS::Reader->new(
file => $rss_file,
);
#2
isa_ok($rss, "Wiki::Toolkit::Plugin");
my @items = $rss->retrieve;
#3
is($items[0]{title}, 'Example item 1', 'Got local title');
#4
is($items[0]{link}, 'http://example.com/1.html', 'Got local link');
#5
is($items[0]{description}, 'The first example.', 'Got local description');
$rss = Wiki::Toolkit::Plugin::RSS::Reader->new(
url => 'http://example.com/example.rss',
);
@items = $rss->retrieve;
#6
is($items[0]{title}, 'Example item 1', 'Got remote title');
#7
is($items[0]{link}, 'http://example.com/1.html', 'Got remote link');
#8
is($items[0]{description}, 'The first example.', 'Got remote description');
my $died;
eval {
local $SIG{__DIE__} = sub { $died = 1; };
# Illegal usage.
$rss = Wiki::Toolkit::Plugin::RSS::Reader->new(
url => 'http://example.com/example.rss',
file => $rss_file,
);
};
#9
is($died, 1, 'Caught illegal config options');
Wiki-Toolkit-Plugin-RSS-Reader-1.6/Makefile.PL 0000444 0001750 0001750 00000001602 11123505726 017100 0 ustar dom dom unless (eval "use Module::Build::Compat 0.02; 1" ) {
print "This module requires Module::Build to install itself.\n";
require ExtUtils::MakeMaker;
my $yn = ExtUtils::MakeMaker::prompt
(' Install Module::Build now from CPAN?', 'y');
unless ($yn =~ /^y/i) {
warn " *** Cannot install without Module::Build. Exiting ...\n";
exit 1;
}
require Cwd;
require File::Spec;
require CPAN;
# Save this 'cause CPAN will chdir all over the place.
my $cwd = Cwd::cwd();
my $makefile = File::Spec->rel2abs($0);
CPAN::Shell->install('Module::Build::Compat');
chdir $cwd or die "Cannot chdir() back to $cwd: $!";
exec $^X, $makefile, @ARGV; # Redo now that we have Module::Build
}
Module::Build::Compat->run_build_pl(args => \@ARGV);
Module::Build::Compat->write_makefile(); Wiki-Toolkit-Plugin-RSS-Reader-1.6/lib/ 0002755 0001750 0001750 00000000000 11123505726 015701 5 ustar dom dom Wiki-Toolkit-Plugin-RSS-Reader-1.6/lib/Wiki/ 0002755 0001750 0001750 00000000000 11123505726 016604 5 ustar dom dom Wiki-Toolkit-Plugin-RSS-Reader-1.6/lib/Wiki/Toolkit/ 0002755 0001750 0001750 00000000000 11123505726 020231 5 ustar dom dom Wiki-Toolkit-Plugin-RSS-Reader-1.6/lib/Wiki/Toolkit/Plugin/ 0002755 0001750 0001750 00000000000 11123505726 021467 5 ustar dom dom Wiki-Toolkit-Plugin-RSS-Reader-1.6/lib/Wiki/Toolkit/Plugin/RSS/ 0002755 0001750 0001750 00000000000 11123505726 022136 5 ustar dom dom Wiki-Toolkit-Plugin-RSS-Reader-1.6/lib/Wiki/Toolkit/Plugin/RSS/Reader.pm 0000444 0001750 0001750 00000007514 11123505726 023701 0 ustar dom dom package Wiki::Toolkit::Plugin::RSS::Reader;
use warnings;
use strict;
use vars qw( $VERSION @ISA );
$VERSION = '1.6';
@ISA = qw(Wiki::Toolkit::Plugin);
use Carp qw(croak);
use LWP::Simple;
use XML::RSS;
my $feed;
my $rss = XML::RSS->new;
sub new
{
my $class = shift;
my %params = @_;
my $self = {};
bless $self, $class;
return $self->_init(%params);
}
sub _init
{
my $self = shift;
my %params = @_;
return unless $params{url} || $params{file};
croak "'url' and 'file' cannot both be specified" if $params{url} && $params{file};
$self->{_url} = $params{url} if $params{url};
$self->{_file} = $params{file} if $params{file};
$self->{_debug} = 1 if $params{debug} && $params{debug} == 1;
return $self;
}
sub retrieve
{
my $self = shift;
my $content;
# Retrieve the RSS from the Net or open a local
# file depending on how we were invoked.
if ($self->{_url})
{
$content = get($self->{_url});
}
else
{
if (open RSS, $self->{_file})
{
$content .= $_ while ;
close RSS;
}
}
my $location;
if ($self->{_url})
{
$location = $self->{_url};
}
else
{
$location = $self->{_file};
}
# If we couldn't get the RSS, fail silently or not?
if (!defined $content)
{
return unless $self->{_debug};
croak "Couldn't retrieve RSS from [$location]: $!";
}
my @rss_items;
$rss->parse($content);
foreach (@{$rss->{'items'}})
{
my $link;
# RSS 2.0 has GUIDs, which may or may not be the item's URL. Read
# http://diveintomark.org/archives/2004/02/04/incompatible-rss
# and weep. May I take the soapbox for a moment here and state
# publically that I think Dave Winer sucks? Thank you.
if ($_->{guid} && $_->{link})
{
$link = $_->{link};
}
elsif ($_->{guid})
{
$link = $_->{guid};
}
else
{
$link = $_->{link};
}
push @rss_items, {
title => $_->{title},
link => $link,
description => $_->{description},
};
}
return @rss_items;
}
1;
__END__
=head1 NAME
Wiki::Toolkit::Plugin::RSS::Reader - retrieve RSS feeds for inclusion in Wiki::Toolkit nodes
=head1 DESCRIPTION
Use this L plugin to retrieve an RSS feed from a given URL so
that you can include it in a wiki node.
=head1 SYNOPSIS
use Wiki::Toolkit::Plugin::RSS::Reader;
my $rss = Wiki::Toolkit::Plugin::RSS::Reader->new(
url => 'http://example.com/feed.rss'
);
my @items = $rss->retrieve;
=head1 USAGE
This is a plugin for L, a toolkit for building wikis; therefore
please consult the documentation for L for relevant information.
This module can, however, be used standalone if you wish.
=head1 METHODS
=head2 C
my $rss = Wiki::Toolkit::Plugin::RSS::Reader->new([options]);
Create a new RSS reader. Valid options are C or C (a path to an
RSS file); only one can be specified.
=head2 C
my @items = $rss->retrieve;
C will return an array of hashes, one for each item in the RSS
feed. The hashes contain three items, C, C, and C.
If the URL or file you specified cannot be retrieved/read, C will
return undef rather than blowing up and surprising the person reading your
wiki. If you want, you can specify C to be 1 in the options to
C, which will cause the module to croak instead of failing silently.
=head1 AUTHOR
Earle Martin (EMARTIN@cpan.org)
The Wiki::Toolkit team, (http://www.wiki-toolkit.org/)
=head1 LEGAL
Copyright 2004 Earle Martin.
Copyright 2006 the Wiki::Toolkit team.
This module is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
Wiki-Toolkit-Plugin-RSS-Reader-1.6/Build.PL 0000444 0001750 0001750 00000000465 11123505726 016430 0 ustar dom dom #!/usr/bin/perl
use strict;
use Module::Build;
Module::Build->new(
module_name => 'Wiki::Toolkit::Plugin::RSS::Reader',
requires => {
'LWP::Simple' => 0,
'XML::RSS' => 0,
},
license => 'perl',
sign => 1
)->create_build_script;