This file is indexed.

/usr/share/perl5/Wiki/Toolkit/Plugin/RSS/Reader.pm is in libwiki-toolkit-plugin-rss-reader-perl 1.6-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
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 <RSS>;
      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<Wiki::Toolkit> 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<Wiki::Toolkit>, a toolkit for building wikis; therefore
please consult the documentation for L<Wiki::Toolkit> for relevant information.
This module can, however, be used standalone if you wish.

=head1 METHODS

=head2 C<new>

    my $rss = Wiki::Toolkit::Plugin::RSS::Reader->new([options]);

Create a new RSS reader. Valid options are C<url> or C<file> (a path to an
RSS file); only one can be specified.

=head2 C<retrieve>

    my @items = $rss->retrieve;

C<retrieve> will return an array of hashes, one for each item in the RSS
feed. The hashes contain three items, C<title>, C<link>, and C<description>.   

If the URL or file you specified cannot be retrieved/read, C<retrieve> will
return undef rather than blowing up and surprising the person reading your
wiki. If you want, you can specify C<debug> to be 1 in the options to
C<new>, 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