diff -Nru libperlanet-perl-1.1.3/bin/perlanet libperlanet-perl-2.0.5/bin/perlanet --- libperlanet-perl-1.1.3/bin/perlanet 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/bin/perlanet 2021-01-15 15:12:48.000000000 +0000 @@ -7,11 +7,7 @@ use Getopt::Std; use File::Basename; -use vars qw{$VERSION}; - -BEGIN { - $VERSION = $Perlanet::VERSION; -} +our $VERSION = $Perlanet::VERSION; my %opts; getopts('hv', \%opts); @@ -138,6 +134,19 @@ the entries in a feed. It can be one of the two values C or C. If this option is omitted, then C is used. +=item cutoff_duration + +Sometimes you might want your generated feed to only contain entries from, +say, the last month. You can do that with the C configuration +option. This takes the form of sub-parameters which are in the same format +as you would use when calling the constructor for +L (which isn't surprising as that's what happens to +them). For example the to exclude entries that are more than a month old, +you would use: + + cutoff_duration: + months: 1 + =item opml The system can optionally create an OPML file containing details of the @@ -172,13 +181,15 @@ This mandatory option gives details of the web feeds to be aggregated. Each item on the list has one mandatory sub-option and two optional sub-options. The mandatory sub-option is C which gives the URL of the feed. The -optional sub-option C gives a title which will be prepended to all of -the entry titles taken from that feed. If no title is given, then the title -will be taken from the feed title. The optional C<web> sub-option gives a -web site URL associated with the feed (often the address of the web site that -the feed comes from). This can be used to create a list of the aggregated -sites. The C<web> sub-option becomes mandatory if you are creating an OPML -file. +optional sub-option C<title> gives a title to the feed which can be used +to identify the entries that originate from this feed. The optional C<web> +sub-option gives a web site URL associated with the feed (often the address +of the web site that the feed comes from). This can be used to create a list +of the aggregated sites. The C<web> sub-option becomes mandatory if you are +creating an OPML file. You can also add a C<max_entries> option which will +override the global C<entries_per_feed> setting. If this setting exists +and is set to zero, then the output feed will contain all of the entries +from this input feed. =back @@ -285,7 +296,7 @@ =head1 AUTHOR -Dave Cross, <dave@mag-sol.com> +Dave Cross, <dave@perlhacks.com> =head1 COPYRIGHT AND LICENSE diff -Nru libperlanet-perl-1.1.3/Build.PL libperlanet-perl-2.0.5/Build.PL --- libperlanet-perl-1.1.3/Build.PL 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/Build.PL 2021-01-15 15:12:48.000000000 +0000 @@ -5,7 +5,7 @@ my $build = Module::Build->new( license => 'perl', - dist_author => 'Dave Cross <dave@mag-sol.com>', + dist_author => 'Dave Cross <dave@perlhacks.com>', module_name => 'Perlanet', requires => { 'perl' => '5.6.0', @@ -23,6 +23,8 @@ 'Try::Tiny' => 0, 'MooseX::Traits' => 0, 'namespace::autoclean' => 0, + 'MooseX::ConfigFromFile' => 0, + 'DateTime::Format::Strptime' => 0, }, recommends => { 'CHI' => 0, @@ -31,10 +33,11 @@ 'MooseX::ConfigFromFile' => 0, }, build_requires => { - 'Test::More' => 0, - 'File::Path' => 0, + 'Test::More' => 0, + 'File::Path' => 0, 'MooseX::ConfigFromFile' => 0, - 'Alien::Tidyp' => 0, + 'Alien::Tidyp' => 0, + 'XML::OPML::SimpleGen' => 0, }, build_recommends => { 'Test::Pod' => 0, @@ -50,6 +53,9 @@ url => 'git://github.com/davorg/perlanet.git', web => 'https://github.com/davorg/perlanet', }, + bugtracker => { + web => 'https://github.com/davorg/perlanet/issues', + }, homepage => "http://perlanet.mag-sol.com/", }, keywords => [ qw( diff -Nru libperlanet-perl-1.1.3/Changes libperlanet-perl-2.0.5/Changes --- libperlanet-perl-1.1.3/Changes 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/Changes 2021-01-15 15:12:48.000000000 +0000 @@ -1,10 +1,32 @@ -2018-06-20 Dave Cross <dave@dave.org.uK> +2021-01-15 2.0.5 Dave Cross <dave@perlhacks.com> -Release 1.1.3 + * Added bugtracker to metadata + * CI improvements + * Code refactoring - * Various code clean-ups +2020-09-24 2.0.4 Dave Cross <dave@perlhacks.com> - * Remove unnecessarry TT filter from example template + * Added missing new library to MANIFEST + +2020-09-24 2.0.3 Dave Cross <dave@perlhacks.com> + + * Added "cutoff_duration" config option for feeds + + * Fixed a long-standing bug in date cutoff + +2020-09-24 2.0.2 Dave Cross <dave@perlhacks.com> + + * Added "max_entries" config option for feeds + +2020-09-22 2.0.1 Dave Cross <dave@perlhacks.com> + + * Require OPML module for testing. + +2020-09-21 2.0.0 Dave Cross <dave@perlhacks.com> + + * Catch up on a few years of packaging and CI fixes. + + * Stop prepending feed name to entry titles. 2018-03-04 Dave Cross <dave@dave.org.uk> diff -Nru libperlanet-perl-1.1.3/debian/changelog libperlanet-perl-2.0.5/debian/changelog --- libperlanet-perl-1.1.3/debian/changelog 2019-02-21 19:22:16.000000000 +0000 +++ libperlanet-perl-2.0.5/debian/changelog 2021-02-25 02:11:22.000000000 +0000 @@ -1,3 +1,21 @@ +libperlanet-perl (2.0.5-1) unstable; urgency=medium + + [ upstream ] + * new release(s) + + [ Debian Janitor ] + * build-depend on debhelper-compat (not debhelper) + * set upstream metadata fields: + Bug-Database Repository Repository-Browse Bug-Submit + + [ Jonas Smedegaard ] + * declare compliance with Debian Policy 4.5.1 + * use debhelper compatibility level 13 (not 9) + * (build-)depend on libdatetime-format-strptime-perl + * copyright info: update coverage + + -- Jonas Smedegaard <dr@jones.dk> Thu, 25 Feb 2021 03:11:22 +0100 + libperlanet-perl (1.1.3-1) unstable; urgency=medium [ upstream ] diff -Nru libperlanet-perl-1.1.3/debian/compat libperlanet-perl-2.0.5/debian/compat --- libperlanet-perl-1.1.3/debian/compat 2019-02-21 18:50:07.000000000 +0000 +++ libperlanet-perl-2.0.5/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru libperlanet-perl-1.1.3/debian/control libperlanet-perl-2.0.5/debian/control --- libperlanet-perl-1.1.3/debian/control 2019-02-21 19:17:12.000000000 +0000 +++ libperlanet-perl-2.0.5/debian/control 2021-02-25 02:07:29.000000000 +0000 @@ -6,9 +6,10 @@ Testsuite: autopkgtest-pkg-perl Priority: optional Build-Depends: - debhelper, + debhelper-compat (= 13), libchi-perl <!nocheck>, libdatetime-perl <!nocheck>, + libdatetime-format-strptime-perl <!nocheck>, libhtml-scrubber-perl <!nocheck>, libhtml-tidy-perl <!nocheck>, libmodule-build-perl, @@ -25,7 +26,7 @@ libxml-opml-simplegen-perl <!nocheck>, libyaml-perl <!nocheck>, perl, -Standards-Version: 4.3.0 +Standards-Version: 4.5.1 Vcs-Browser: https://salsa.debian.org/perl-team/modules/packages/libperlanet-perl Vcs-Git: https://salsa.debian.org/perl-team/modules/packages/libperlanet-perl.git Homepage: https://perlanet.mag-sol.com/ @@ -35,6 +36,7 @@ Architecture: all Depends: libdatetime-perl, + libdatetime-format-strptime-perl, libhtml-scrubber-perl, libhtml-tidy-perl, libmoose-perl, diff -Nru libperlanet-perl-1.1.3/debian/copyright libperlanet-perl-2.0.5/debian/copyright --- libperlanet-perl-1.1.3/debian/copyright 2019-02-21 18:49:13.000000000 +0000 +++ libperlanet-perl-2.0.5/debian/copyright 2021-02-25 02:11:01.000000000 +0000 @@ -4,7 +4,8 @@ Source: https://metacpan.org/release/Perlanet Files: * -Copyright: 2008,2010, Magnum Solutions Ltd +Copyright: + 2008,2010,2020, Magnum Solutions Ltd License-Grant: This module is free software; you can redistribute it and/or modify it @@ -15,7 +16,8 @@ or the GNU General Public License version 1 or later. Files: debian/* -Copyright: 2011-2013,2016-2019, Jonas Smedegaard <dr@jones.dk> +Copyright: + 2011-2013,2016-2019,2021, Jonas Smedegaard <dr@jones.dk> License-Grant: This program is free software; you can redistribute it and/or modify it diff -Nru libperlanet-perl-1.1.3/debian/copyright_hints libperlanet-perl-2.0.5/debian/copyright_hints --- libperlanet-perl-1.1.3/debian/copyright_hints 2019-02-21 19:14:32.000000000 +0000 +++ libperlanet-perl-2.0.5/debian/copyright_hints 2021-02-25 02:09:24.000000000 +0000 @@ -10,13 +10,13 @@ META.json META.yml Makefile.PL - debian/compat debian/control debian/docs debian/examples debian/gbp.conf debian/rules debian/source/format + debian/upstream debian/watch examples/index.tt examples/perlanetrc @@ -29,6 +29,11 @@ t/04_mps.t t/05_cache.t t/06_youtube.t + t/07_page.t + t/08_opml.t + t/09_entries.t + t/5entriesrc + t/allentriesrc t/cacherc t/data/davblog.xml t/data/stevebaker.xml @@ -40,6 +45,7 @@ t/pod.t t/pod_coverage.t t/testrc + t/testrc_no_opml t/youtube2rc t/youtuberc Copyright: NONE @@ -55,14 +61,11 @@ lib/Perlanet/Trait/TemplateToolkit.pm lib/Perlanet/Trait/Tidy.pm lib/Perlanet/Trait/YAMLConfig.pm + lib/Perlanet/Types.pm Copyright: 2008, Magnum Solutions Ltd. 2010, Magnum Solutions Ltd. -License: Artistic or GPL-1+ - FIXME - -Files: README -Copyright: Copyright (C) 2008, Magnum Solutions Ltd. -License: Artistic or GPL-1+ + 2020, Magnum Solutions Ltd. +License: UNKNOWN FIXME Files: debian/copyright-check @@ -81,3 +84,8 @@ License: UNKNOWN FIXME +Files: README +Copyright: Copyright (C) 2008, Magnum Solutions Ltd. +License: UNKNOWN + FIXME + diff -Nru libperlanet-perl-1.1.3/debian/rules libperlanet-perl-2.0.5/debian/rules --- libperlanet-perl-1.1.3/debian/rules 2019-02-20 19:29:02.000000000 +0000 +++ libperlanet-perl-2.0.5/debian/rules 2021-02-24 22:12:13.000000000 +0000 @@ -1,8 +1,7 @@ #!/usr/bin/make -f # fix hashbang -override_dh_auto_install: - dh_auto_install +execute_after_dh_auto_install: find debian/lib*/usr/bin -type f -print0 | \ xargs -r0 sed -i -e '1s|^#!/usr/bin/env perl|#!/usr/bin/perl|' diff -Nru libperlanet-perl-1.1.3/debian/upstream/metadata libperlanet-perl-2.0.5/debian/upstream/metadata --- libperlanet-perl-1.1.3/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ libperlanet-perl-2.0.5/debian/upstream/metadata 2021-02-24 22:04:00.000000000 +0000 @@ -0,0 +1,5 @@ +--- +Bug-Database: https://github.com/davorg/perlanet/issues +Bug-Submit: https://github.com/davorg/perlanet/issues/new +Repository: https://github.com/davorg/perlanet.git +Repository-Browse: https://github.com/davorg/perlanet diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Feed.pm libperlanet-perl-2.0.5/lib/Perlanet/Feed.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Feed.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Feed.pm 2021-01-15 15:12:48.000000000 +0000 @@ -60,6 +60,11 @@ is => 'rw', ); +has 'max_entries' => ( + is => 'ro', + isa => 'Int', +); + has 'entries' => ( isa => 'ArrayRef', is => 'rw', @@ -79,7 +84,8 @@ =cut sub as_xml { - my ($self, $format) = @_; + my $self = shift; + my ($format) = @_; my $feed = XML::Feed->new($format); $feed->title($self->title); diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Simple.pm libperlanet-perl-2.0.5/lib/Perlanet/Simple.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Simple.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Simple.pm 2021-01-15 15:12:48.000000000 +0000 @@ -69,7 +69,10 @@ around clean_html => sub { my $orig = shift; - my ($self, $html) = @_; + my $self = shift; + my ($html) = @_; + + warn __PACKAGE__, '::clean_html' if $ENV{PERLANET_DEBUG}; # hack to remove a particularly nasty piece of blogspot HTML $html = $self->$orig($html); diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Trait/Cache.pm libperlanet-perl-2.0.5/lib/Perlanet/Trait/Cache.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Trait/Cache.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Trait/Cache.pm 2021-01-15 15:12:48.000000000 +0000 @@ -37,7 +37,8 @@ around 'fetch_page' => sub { my $orig = shift; - my ($self, $url) = @_; + my $self = shift; + my ($url) = @_; return URI::Fetch->fetch( $url, UserAgent => $self->ua, @@ -48,7 +49,7 @@ =head1 AUTHOR -Dave Cross, <dave@mag-sol.com> +Dave Cross, <dave@perlhacks.com> =head1 COPYRIGHT AND LICENSE diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Trait/FeedFile.pm libperlanet-perl-2.0.5/lib/Perlanet/Trait/FeedFile.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Trait/FeedFile.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Trait/FeedFile.pm 2021-01-15 15:12:48.000000000 +0000 @@ -47,7 +47,8 @@ ); after 'render' => sub { - my ($self, $feed) = @_; + my $self = shift; + my ($feed) = @_; return unless $self->feed->{file}; open my $feedfile, '>', $self->feed->{file} diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Trait/OPML.pm libperlanet-perl-2.0.5/lib/Perlanet/Trait/OPML.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Trait/OPML.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Trait/OPML.pm 2021-01-15 15:12:48.000000000 +0000 @@ -36,8 +36,9 @@ has 'opml_generator' => ( is => 'rw', isa => 'Maybe[XML::OPML::SimpleGen]', - lazy_build => 1, - predicate => 'has_opml' + builder => '_build_opml_generator', + predicate => 'has_opml', + required => 1, ); sub _build_opml_generator { @@ -48,7 +49,7 @@ if ($@) { carp 'You need to install XML::OPML::SimpleGen to enable OPML ' . 'support'; - $self->opml(undef); + $self->opml_file(undef); return; } @@ -69,7 +70,7 @@ =cut -has 'opml' => ( +has 'opml_file' => ( isa => 'Maybe[Str]', is => 'rw', ); @@ -78,18 +79,20 @@ =head2 update_opml -Updates the OPML file of all contributers to this planet. If the L<opml> +Updates the OPML file of all contributers to this planet. If the L<opml_file> attribute does not have a value, this method does nothing, otherwise it inserts each author into the OPML file and saves it to disk. =cut sub update_opml { - my ($self, $feeds) = @_; - - return unless $self->has_opml; + my $self = shift; + my ($feeds) = @_; foreach my $f (@$feeds) { + + return unless $self->opml_file and $self->has_opml; + $self->opml_generator->insert_outline( title => $f->title, text => $f->title, @@ -109,12 +112,13 @@ sub save_opml { my $self = shift; - $self->opml_generator->save($self->opml); + $self->opml_generator->save($self->opml_file); } around 'fetch_feeds' => sub { my $orig = shift; - my ($self, $feeds) = @_; + my $self = shift; + my ($feeds) = @_; $feeds = $self->$orig($feeds); $self->update_opml($feeds) if $self->has_opml; return $feeds; @@ -122,7 +126,7 @@ =head1 AUTHOR -Dave Cross, <dave@mag-sol.com> +Dave Cross, <dave@perlhacks.com> =head1 COPYRIGHT AND LICENSE diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Trait/Scrubber.pm libperlanet-perl-2.0.5/lib/Perlanet/Trait/Scrubber.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Trait/Scrubber.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Trait/Scrubber.pm 2021-01-15 15:12:48.000000000 +0000 @@ -102,13 +102,18 @@ my $scrub = HTML::Scrubber->new; $scrub->rules(%scrub_rules); $scrub->default(1, \%scrub_def); + $scrub->script(0); return $scrub; } around 'clean_html' => sub { my $orig = shift; - my ($self, $html) = @_; + my $self = shift; + my ($html) = @_; + + warn __PACKAGE__, '::clean_html' if $ENV{PERLANET_DEBUG}; + $html = $self->$orig($html); my $scrubbed = $self->scrubber->scrub($html); return $scrubbed; @@ -116,7 +121,7 @@ =head1 AUTHOR -Dave Cross, <dave@mag-sol.com> +Dave Cross, <dave@perlhacks.com> =head1 COPYRIGHT AND LICENSE diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Trait/TemplateToolkit.pm libperlanet-perl-2.0.5/lib/Perlanet/Trait/TemplateToolkit.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Trait/TemplateToolkit.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Trait/TemplateToolkit.pm 2021-01-15 15:12:48.000000000 +0000 @@ -55,7 +55,8 @@ ); after 'render' => sub { - my ($self, $feed) = @_; + my $self = shift; + my ($feed) = @_; my $tt = Template->new; $tt->process( $self->page->{template}, diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Trait/Tidy.pm libperlanet-perl-2.0.5/lib/Perlanet/Trait/Tidy.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Trait/Tidy.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Trait/Tidy.pm 2021-01-15 15:12:48.000000000 +0000 @@ -23,7 +23,7 @@ =head1 DESCRIPTION -Before a post is added to the aggregated feed, it will be ran through +Before a post is added to the aggregated feed, it will be run through HTML::Tidy. =head2 Configuring @@ -68,7 +68,10 @@ around 'clean_html' => sub { my $orig = shift; - my ($self, $html) = @_; + my $self = shift; + my ($html) = @_; + + warn __PACKAGE__, '::clean_html' if $ENV{PERLANET_DEBUG}; $html = $self->$orig($html); diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Trait/YAMLConfig.pm libperlanet-perl-2.0.5/lib/Perlanet/Trait/YAMLConfig.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Trait/YAMLConfig.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Trait/YAMLConfig.pm 2021-01-15 15:12:48.000000000 +0000 @@ -77,7 +77,8 @@ use constant THIRTY_DAYS => 30 * 24 * 60 * 60; sub get_config_from_file { - my ($self, $file) = @_; + my $class = shift; + my ($file) = @_; open my $cfg_file, '<:encoding(UTF-8)', $file or croak "Cannot open file $file: $!"; diff -Nru libperlanet-perl-1.1.3/lib/Perlanet/Types.pm libperlanet-perl-2.0.5/lib/Perlanet/Types.pm --- libperlanet-perl-1.1.3/lib/Perlanet/Types.pm 1970-01-01 00:00:00.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet/Types.pm 2021-01-15 15:12:48.000000000 +0000 @@ -0,0 +1,74 @@ +=head1 NAME + +Perlanet::Types - Various types for the Perlanet system. + +=head1 SYNOPSIS + + # n/a + +=head1 DESCRIPTION + +This class acts as a repository of types used at various places in +Perlanet. + +=cut + +package Perlanet::Types; + +use Moose::Util::TypeConstraints; + +use DateTime; +use DateTime::Duration; +use DateTime::Format::Strptime; + +=head1 TYPES + +=head2 Perlanet::DateTime + +Our subclass of DateTime (along with a coercion to automatically create +it from a string). + +=cut + +subtype 'Perlanet::DateTime', + as 'DateTime'; + +coerce 'Perlanet::DateTime', + from 'Str', + via { + DateTime::Format::Strptime->new( + pattern => '%Y-%m-%dT%H:%M%S', + )->parse_datetime($_); + }; + +=head2 Perlanet::DateTime::Duration + +Our subtype of DateTime::Duration (along with a coercion to automatically +create it from a hash reference). + +=cut + +subtype 'Perlanet::DateTime::Duration', + as 'DateTime::Duration'; + +coerce 'Perlanet::DateTime::Duration', + from 'HashRef', + via { + DateTime::Duration->new($_); + }; + +=head1 AUTHOR + +Dave Cross, <dave@perlhacks.com> + +=head1 COPYRIGHT AND LICENSE + +Copyright (c) 2020 by Magnum Solutions Ltd. + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.10.0 or, +at your option, any later version of Perl 5 you may have available. + +=cut + +1; diff -Nru libperlanet-perl-1.1.3/lib/Perlanet.pm libperlanet-perl-2.0.5/lib/Perlanet.pm --- libperlanet-perl-1.1.3/lib/Perlanet.pm 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/lib/Perlanet.pm 2021-01-15 15:12:48.000000000 +0000 @@ -15,11 +15,9 @@ use URI::Fetch; use XML::Feed; -use vars qw{$VERSION}; +use Perlanet::Types; -BEGIN { - $VERSION = '1.1.3'; -} +our $VERSION = '2.0.5'; with 'MooseX::Traits'; @@ -42,14 +40,28 @@ return $ua; } +has 'cutoff_duration' => ( + isa => 'Perlanet::DateTime::Duration', + is => 'rw', + lazy_build => 1, + coerce => 1, +); + +sub _build_cutoff_duration { + return { years => 1_000 }; +} + has 'cutoff' => ( - isa => 'DateTime', + isa => 'Perlanet::DateTime', is => 'ro', - default => sub { - DateTime->now + DateTime::Duration->new(weeks => 1); - } + lazy_build => 1, + coerce => 1, ); +sub _build_cutoff { + return DateTime->now - shift->cutoff_duration; +} + has 'entries' => ( isa => 'Int', is => 'rw', @@ -153,7 +165,8 @@ =cut sub fetch_page { - my ($self, $url) = @_; + my $self = shift; + my ($url) = @_; return URI::Fetch->fetch( $url, UserAgent => $self->ua, @@ -174,7 +187,8 @@ =cut sub fetch_feeds { - my ($self, $feeds) = @_; + my $self = shift; + my ($feeds) = @_; my @valid_feeds; for my $feed (@$feeds) { @@ -219,32 +233,47 @@ =cut sub select_entries { - my ($self, $feeds) = @_; + my $self = shift; + my ($feeds) = @_; + + + my $date_zero = DateTime->from_epoch(epoch => 0); my @feed_entries; for my $feed (@$feeds) { my @entries = $feed->_xml_feed->entries; + for (@entries) { + # "Fix" entries with no dates + unless ($_->issued or $_->modified) { + $_->issued($date_zero); + $_->modified($date_zero); + } + + # Problem with XML::Feed's conversion of RSS to Atom + if ($_->issued && ! $_->modified) { + $_->modified($_->issued); + } + } + @entries = @{ $self->sort_entries(\@entries) }; + @entries = @{ $self->cutoff_entries(\@entries) }; - if ($self->entries_per_feed and @entries > $self->entries_per_feed) { - $#entries = $self->entries_per_feed - 1; - } + my $number_of_entries = + defined $feed->max_entries ? $feed->max_entries + : $self->entries_per_feed; - push @feed_entries, - map { - $_->title($feed->title . ': ' . $_->title); - - # Problem with XML::Feed's conversion of RSS to Atom - if ($_->issued && ! $_->modified) { - $_->modified($_->issued); - } + if ($number_of_entries and @entries > $number_of_entries) { + $#entries = $number_of_entries - 1; + } + for (@entries) { + push @feed_entries, Perlanet::Entry->new( _entry => $_, feed => $feed ); - } @entries; + } } return \@feed_entries; @@ -263,35 +292,47 @@ =cut sub sort_entries { - my ($self, $entries) = @_; - my $day_zero = DateTime->from_epoch(epoch => 0); + my $self = shift; + my ($entries) = @_; my @entries; if ($self->entry_sort_order eq 'modified') { - @entries = grep { - ($_->modified || $_->issued || $day_zero) < $self->cutoff - } sort { - ($b->modified || $b->issued || $day_zero) + @entries = sort { + ($b->modified || $b->issued) <=> - ($a->modified || $a->issued || $day_zero) + ($a->modified || $a->issued) } @$entries; } elsif ($self->entry_sort_order eq 'issued') { - @entries = grep { - ($_->issued || $_->modified || $day_zero) < $self->cutoff - } sort { - ($b->issued || $b->modified || $day_zero) + @entries = sort { + ($b->issued || $b->modified) <=> - ($a->issued || $a->modified || $day_zero) + ($a->issued || $a->modified) } @$entries; } else { die 'Invalid entry sort order: ' . $self->entry_sort_order; } - # Only need so many entries - if ($self->entries && @entries > $self->entries) { - $#entries = $self->entries - 1; - } + return \@entries; +} + +=head2 cutoff_entries + +Called internally by L</run> and passed the list of entries from +L</sort_entries>. + +Removes any entries that were published earlier than the cut-off +date for this feed. + +=cut + +sub cutoff_entries { + my $self = shift; + my ($entries) = @_; + + my @entries = grep { + ($_->issued || $_->modified) > $self->cutoff + } @$entries; return \@entries; } @@ -307,7 +348,8 @@ =cut sub build_feed { - my ($self, $entries) = @_; + my $self = shift; + my ($entries) = @_; my $self_url = $self->self_link; @@ -336,7 +378,8 @@ =cut sub clean_html { - my ($self, $entry) = @_; + my $self = shift; + my ($entry) = @_; return $entry; } @@ -350,7 +393,8 @@ =cut sub clean_entries { - my ($self, $entries) = @_; + my $self = shift; + my ($entries) = @_; my @clean_entries; @@ -384,7 +428,8 @@ =cut sub render { - my ($self, $feed) = @_; + my $self = shift; + my ($feed) = @_; } =head2 run @@ -435,7 +480,7 @@ =head1 AUTHOR -Dave Cross, <dave@mag-sol.com> +Dave Cross, <dave@perlhacks.com> =head1 COPYRIGHT AND LICENSE diff -Nru libperlanet-perl-1.1.3/Makefile.PL libperlanet-perl-2.0.5/Makefile.PL --- libperlanet-perl-1.1.3/Makefile.PL 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/Makefile.PL 2021-01-15 15:12:48.000000000 +0000 @@ -1,34 +1,36 @@ -# Note: this file was auto-generated by Module::Build::Compat version 0.4224 +# Note: this file was auto-generated by Module::Build::Compat version 0.4231 require 5.006000; use ExtUtils::MakeMaker; WriteMakefile ( - 'EXE_FILES' => [ - 'bin/perlanet' - ], - 'INSTALLDIRS' => 'site', 'NAME' => 'Perlanet', - 'PL_FILES' => {}, + 'VERSION_FROM' => 'lib/Perlanet.pm', 'PREREQ_PM' => { + 'Alien::Tidyp' => 0, 'DateTime' => 0, - 'MooseX::Traits' => 0, - 'Try::Tiny' => 0, 'DateTime::Duration' => 0, + 'DateTime::Format::Strptime' => 0, + 'Encode' => 0, + 'File::Path' => 0, 'HTML::Scrubber' => 0, - 'URI::Fetch' => 0, - 'Alien::Tidyp' => 0, 'HTML::Tidy' => 0, - 'XML::Feed' => '0.22', - 'YAML' => 0, + 'List::Util' => 0, 'Moose' => 0, 'MooseX::ConfigFromFile' => 0, + 'MooseX::Traits' => 0, 'Template' => 0, - 'File::Path' => 0, - 'List::Util' => 0, 'Test::More' => 0, - 'namespace::autoclean' => 0, - 'Encode' => 0 + 'Try::Tiny' => 0, + 'URI::Fetch' => 0, + 'XML::Feed' => '0.22', + 'XML::OPML::SimpleGen' => 0, + 'YAML' => 0, + 'namespace::autoclean' => 0 }, - 'VERSION_FROM' => 'lib/Perlanet.pm' + 'INSTALLDIRS' => 'site', + 'EXE_FILES' => [ + 'bin/perlanet' + ], + 'PL_FILES' => {} ) ; diff -Nru libperlanet-perl-1.1.3/MANIFEST libperlanet-perl-2.0.5/MANIFEST --- libperlanet-perl-1.1.3/MANIFEST 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/MANIFEST 2021-01-15 15:12:48.000000000 +0000 @@ -6,6 +6,7 @@ lib/Perlanet/Entry.pm lib/Perlanet/Feed.pm lib/Perlanet/Simple.pm +lib/Perlanet/Types.pm lib/Perlanet/Trait/Cache.pm lib/Perlanet/Trait/OPML.pm lib/Perlanet/Trait/TemplateToolkit.pm @@ -22,14 +23,20 @@ t/04_mps.t t/05_cache.t t/06_youtube.t +t/07_page.t +t/08_opml.t +t/09_entries.t t/pod.t t/pod_coverage.t t/testrc +t/testrc_no_opml t/perlanetrc t/cacherc t/mprc t/youtuberc t/youtube2rc +t/allentriesrc +t/5entriesrc t/index.tt README Changes diff -Nru libperlanet-perl-1.1.3/META.json libperlanet-perl-2.0.5/META.json --- libperlanet-perl-1.1.3/META.json 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/META.json 2021-01-15 15:12:48.000000000 +0000 @@ -1,10 +1,10 @@ { "abstract" : "A program for creating programs that aggregate web feeds (both", "author" : [ - "Dave Cross <dave@mag-sol.com>" + "Dave Cross <dave@perlhacks.com>" ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.4224", + "generated_by" : "Module::Build version 0.4231", "keywords" : [ "aggregate", "aggregator", @@ -28,7 +28,8 @@ "Alien::Tidyp" : "0", "File::Path" : "0", "MooseX::ConfigFromFile" : "0", - "Test::More" : "0" + "Test::More" : "0", + "XML::OPML::SimpleGen" : "0" } }, "configure" : { @@ -46,11 +47,13 @@ "requires" : { "DateTime" : "0", "DateTime::Duration" : "0", + "DateTime::Format::Strptime" : "0", "Encode" : "0", "HTML::Scrubber" : "0", "HTML::Tidy" : "0", "List::Util" : "0", "Moose" : "0", + "MooseX::ConfigFromFile" : "0", "MooseX::Traits" : "0", "Template" : "0", "Try::Tiny" : "0", @@ -65,7 +68,7 @@ "provides" : { "Perlanet" : { "file" : "lib/Perlanet.pm", - "version" : "v1.1.3" + "version" : "v2.0.5" }, "Perlanet::Entry" : { "file" : "lib/Perlanet/Entry.pm" @@ -96,10 +99,16 @@ }, "Perlanet::Trait::YAMLConfig" : { "file" : "lib/Perlanet/Trait/YAMLConfig.pm" + }, + "Perlanet::Types" : { + "file" : "lib/Perlanet/Types.pm" } }, "release_status" : "stable", "resources" : { + "bugtracker" : { + "web" : "https://github.com/davorg/perlanet/issues" + }, "homepage" : "http://perlanet.mag-sol.com/", "license" : [ "http://dev.perl.org/licenses/" @@ -110,6 +119,6 @@ "web" : "https://github.com/davorg/perlanet" } }, - "version" : "v1.1.3", - "x_serialization_backend" : "JSON::PP version 2.97001" + "version" : "v2.0.5", + "x_serialization_backend" : "JSON::PP version 4.04" } diff -Nru libperlanet-perl-1.1.3/META.yml libperlanet-perl-2.0.5/META.yml --- libperlanet-perl-1.1.3/META.yml 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/META.yml 2021-01-15 15:12:48.000000000 +0000 @@ -1,16 +1,17 @@ --- abstract: 'A program for creating programs that aggregate web feeds (both' author: - - 'Dave Cross <dave@mag-sol.com>' + - 'Dave Cross <dave@perlhacks.com>' build_requires: Alien::Tidyp: '0' File::Path: '0' MooseX::ConfigFromFile: '0' Test::More: '0' + XML::OPML::SimpleGen: '0' configure_requires: Module::Build: '0.42' dynamic_config: 1 -generated_by: 'Module::Build version 0.4224, CPAN::Meta::Converter version 2.150010' +generated_by: 'Module::Build version 0.4231, CPAN::Meta::Converter version 2.150010' keywords: - aggregate - aggregator @@ -27,7 +28,7 @@ provides: Perlanet: file: lib/Perlanet.pm - version: v1.1.3 + version: v2.0.5 Perlanet::Entry: file: lib/Perlanet/Entry.pm Perlanet::Feed: @@ -48,6 +49,8 @@ file: lib/Perlanet/Trait/Tidy.pm Perlanet::Trait::YAMLConfig: file: lib/Perlanet/Trait/YAMLConfig.pm + Perlanet::Types: + file: lib/Perlanet/Types.pm recommends: CHI: '0' Compress::Zlib: '0' @@ -56,11 +59,13 @@ requires: DateTime: '0' DateTime::Duration: '0' + DateTime::Format::Strptime: '0' Encode: '0' HTML::Scrubber: '0' HTML::Tidy: '0' List::Util: '0' Moose: '0' + MooseX::ConfigFromFile: '0' MooseX::Traits: '0' Template: '0' Try::Tiny: '0' @@ -70,8 +75,9 @@ namespace::autoclean: '0' perl: v5.6.0 resources: + bugtracker: https://github.com/davorg/perlanet/issues homepage: http://perlanet.mag-sol.com/ license: http://dev.perl.org/licenses/ repository: git://github.com/davorg/perlanet.git -version: v1.1.3 +version: v2.0.5 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -Nru libperlanet-perl-1.1.3/README libperlanet-perl-2.0.5/README --- libperlanet-perl-1.1.3/README 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/README 2021-01-15 15:12:48.000000000 +0000 @@ -62,5 +62,5 @@ AUTHOR - Dave Cross <dave@mag-sol.com> + Dave Cross <dave@perlhacks.com> diff -Nru libperlanet-perl-1.1.3/t/01_basic.t libperlanet-perl-2.0.5/t/01_basic.t --- libperlanet-perl-1.1.3/t/01_basic.t 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/t/01_basic.t 2021-01-15 15:12:48.000000000 +0000 @@ -12,8 +12,8 @@ 'Object created'); isa_ok($p, 'Perlanet'); -if (-e $p->opml) { - unlink $p->opml; +if (-e $p->opml_file) { + unlink $p->opml_file; } if (-e $p->feed->{file}) { @@ -30,11 +30,11 @@ ok(-e $p->page->{file}, 'Page created'); SKIP: { skip 'XML::OPML::SimpleGen not installed', 1 unless $p->has_opml; - ok(-e $p->opml, 'OPML created'); + ok(-e $p->opml_file, 'OPML created'); } -if (-e $p->opml) { - unlink $p->opml; +if (-e $p->opml_file) { + unlink $p->opml_file; } if (-e $p->feed->{file}) { diff -Nru libperlanet-perl-1.1.3/t/02_phases.t libperlanet-perl-2.0.5/t/02_phases.t --- libperlanet-perl-1.1.3/t/02_phases.t 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/t/02_phases.t 2021-01-15 15:12:48.000000000 +0000 @@ -5,7 +5,9 @@ use_ok('Perlanet::Simple'); chdir $Bin; -ok(my $p = Perlanet::Simple->new_with_config(configfile => 'testrc'), +ok(my $p = Perlanet::Simple->new_with_config( + configfile => 'testrc_no_opml', +), 'Object created'); isa_ok($p, 'Perlanet'); diff -Nru libperlanet-perl-1.1.3/t/07_page.t libperlanet-perl-2.0.5/t/07_page.t --- libperlanet-perl-1.1.3/t/07_page.t 1970-01-01 00:00:00.000000000 +0000 +++ libperlanet-perl-2.0.5/t/07_page.t 2021-01-15 15:12:48.000000000 +0000 @@ -0,0 +1,13 @@ +use strict; +use warnings; +use Test::More; +use_ok('Perlanet'); + +# Test fetching a page without the cache trait. +ok(my $p = Perlanet->new(), 'Object created'); +isa_ok($p, 'Perlanet'); +ok(my $page = $p->fetch_page('http://blogs.dave.org.uk/rss.xml'), + 'Page fetched'); +isa_ok($page, 'URI::Fetch::Response'); + +done_testing(); diff -Nru libperlanet-perl-1.1.3/t/08_opml.t libperlanet-perl-2.0.5/t/08_opml.t --- libperlanet-perl-1.1.3/t/08_opml.t 1970-01-01 00:00:00.000000000 +0000 +++ libperlanet-perl-2.0.5/t/08_opml.t 2021-01-15 15:12:48.000000000 +0000 @@ -0,0 +1,35 @@ +use strict; +use warnings; +use Test::More; +use FindBin qw($Bin); +use File::Temp qw(tempfile); +use_ok('Perlanet::Simple'); + +chdir $Bin; +ok(my $p = Perlanet::Simple->new_with_config(configfile => 'testrc'), + 'Object created'); +isa_ok($p,'Perlanet'); + +SKIP: { + skip 'XML::OPML::SimpleGen not installed', 1 unless $p->has_opml; + + my (undef, $opml_file) = tempfile(OPEN => 0); + $p->opml_file($opml_file); + $p->run(); + $p->save_opml(); + ok(-e $opml_file, 'OPML file created'); + + if (-e $p->opml_file) { + unlink $p->opml_file; + } + + if (-e $p->feed->{file}) { + unlink $p->feed->{file}; + } + + if (-e $p->page->{file}) { + unlink $p->page->{file}; + } +} + +done_testing(); diff -Nru libperlanet-perl-1.1.3/t/09_entries.t libperlanet-perl-2.0.5/t/09_entries.t --- libperlanet-perl-1.1.3/t/09_entries.t 1970-01-01 00:00:00.000000000 +0000 +++ libperlanet-perl-2.0.5/t/09_entries.t 2021-01-15 15:12:48.000000000 +0000 @@ -0,0 +1,25 @@ +use strict; +use warnings; +use Test::More; +use FindBin qw($Bin); +use Perlanet::Simple; + +chdir $Bin; + +my @tests = ({ + rc => '5', + count => 5, +}, { + rc => 'all', + count => 15, +}); + +for (@tests) { + my $p = Perlanet::Simple->new_with_config(configfile => "$_->{rc}entriesrc"); + + my $feeds = $p->fetch_feeds($p->feeds); + my $selected = $p->select_entries($feeds); + is(@$selected, $_->{count}, "Override to get $_->{rc} selected entries"); +} + +done_testing(); diff -Nru libperlanet-perl-1.1.3/t/5entriesrc libperlanet-perl-2.0.5/t/5entriesrc --- libperlanet-perl-1.1.3/t/5entriesrc 1970-01-01 00:00:00.000000000 +0000 +++ libperlanet-perl-2.0.5/t/5entriesrc 2021-01-15 15:12:48.000000000 +0000 @@ -0,0 +1,22 @@ +title: planet test +description: Testing stuff +url: http://theplanetarium.org/ +self_link: http://theplanetarium.org/ +agent: Testing Perlanet +entries_per_feed: 1 +author: + name: Dave Cross + email: dave@dave.org.uk +max_entries: 20 +page: + file: index.html + template: index.tt +feed: + file: rss.xml + format: Atom +feeds: + - url: file:data/davblog.xml + title: davblog + web: http://blogs.dave.org.uk/ + max_entries: 5 + diff -Nru libperlanet-perl-1.1.3/t/allentriesrc libperlanet-perl-2.0.5/t/allentriesrc --- libperlanet-perl-1.1.3/t/allentriesrc 1970-01-01 00:00:00.000000000 +0000 +++ libperlanet-perl-2.0.5/t/allentriesrc 2021-01-15 15:12:48.000000000 +0000 @@ -0,0 +1,22 @@ +title: planet test +description: Testing stuff +url: http://theplanetarium.org/ +self_link: http://theplanetarium.org/ +agent: Testing Perlanet +entries_per_feed: 1 +author: + name: Dave Cross + email: dave@dave.org.uk +max_entries: 20 +page: + file: index.html + template: index.tt +feed: + file: rss.xml + format: Atom +feeds: + - url: file:data/davblog.xml + title: davblog + web: http://blogs.dave.org.uk/ + max_entries: 0 + diff -Nru libperlanet-perl-1.1.3/t/testrc libperlanet-perl-2.0.5/t/testrc --- libperlanet-perl-1.1.3/t/testrc 2018-06-20 12:33:20.000000000 +0000 +++ libperlanet-perl-2.0.5/t/testrc 2021-01-15 15:12:48.000000000 +0000 @@ -8,7 +8,7 @@ name: Dave Cross email: dave@dave.org.uk max_entries: 20 -opml: opml.xml +opml_file: opml.xml page: file: index.html template: index.tt diff -Nru libperlanet-perl-1.1.3/t/testrc_no_opml libperlanet-perl-2.0.5/t/testrc_no_opml --- libperlanet-perl-1.1.3/t/testrc_no_opml 1970-01-01 00:00:00.000000000 +0000 +++ libperlanet-perl-2.0.5/t/testrc_no_opml 2021-01-15 15:12:48.000000000 +0000 @@ -0,0 +1,21 @@ +title: planet test +description: Testing stuff +url: http://theplanetarium.org/ +self_link: http://theplanetarium.org/ +agent: Testing Perlanet +entries_per_feed: 1 +author: + name: Dave Cross + email: dave@dave.org.uk +max_entries: 20 +page: + file: index.html + template: index.tt +feed: + file: rss.xml + format: Atom +feeds: + - url: file:data/davblog.xml + title: davblog + web: http://blogs.dave.org.uk/ +