Catalyst-Plugin-BigSitemap
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/BigSitemap/SitemapBuilder.pm view on Meta::CPAN
package Catalyst::Plugin::BigSitemap::SitemapBuilder;
use Modern::Perl '2010';
use WWW::Sitemap::XML;
use WWW::Sitemap::XML::URL;
use WWW::SitemapIndex::XML;
use Carp;
use Try::Tiny;
use Data::Dumper;
use Moose;
=head1 NAME
Catalyst::Plugin::BigSitemap::SitemapBuilder - Helper object for the BigSitemap plugin
=head1 VERSION
0.02
=head1 DESCRIPTION
This object's role is to accept a collection of L<WWW::Sitemap::XML::URL> objects via the L<add>
method.
=head1 CONSTRUCTOR
There are two required parameters that must be passed to the constructor, L<sitemap_base_uri> and
L<sitemap_name_format>.
=head1 ATTRIBUTES
=shift 4
=item urls - I<ArrayRef> of L<WWW::Sitemap::XML::URL>
A collection of every URL in your application that will be included in the sitemap.
=item sitemap_base_uri - L<URI::http>
The base URI that should be used when resolving the action urls in your application.
You should really specify this manually, in the event that one day you want to start
run this module from a cron job.
=item sitemap_name_format - I<Str>
A sprintf style format for the names of your sitemap files. Note: The names of the sitemap files
will start by inserting the number 1 and incrementing for each sitemap file written. It's important
to note that in code, calls to the sitemap method use a 0-based-index but your sitemap filenames are
1-based. This is just that way so the names of the individual sitemaps match to the examples given
on the L<http://www.sitemaps.org> website.
=item failed_count - I<Int>
A running count of all the URLs that failed validation in the L<WWW::Sitemap::XML::URL> module and could not
be added to the collection.. This should always report zero unless you've screwed something up in your
C<sub my_action_sitemap> controller methods.
=back
=cut
has 'urls' => ( is => 'rw', isa => 'ArrayRef[WWW::Sitemap::XML::URL]', default => sub { [] } );
has 'sitemap_base_uri' => ( is => 'ro', isa => 'URI::http' );
has 'sitemap_name_format'=> ( is => 'ro', isa => 'Str' );
has 'failed_count' => ( is => 'rw', isa => 'Int', default => 0 );
=head1 METHODS
( run in 1.192 second using v1.01-cache-2.11-cpan-5a3173703d6 )