Catalyst-Plugin-BigSitemap

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/BigSitemap.pm  view on Meta::CPAN

package Catalyst::Plugin::BigSitemap;
use Modern::Perl '2010';
use Catalyst::Plugin::BigSitemap::SitemapBuilder;
use WWW::SitemapIndex::XML;
use WWW::Sitemap::XML;
use Path::Class;
use Carp;
use Moose;

BEGIN { $Catalyst::Plugin::BigSitemap::VERSION = '0.9'; }

=encoding utf8

=head1 NAME 

Catalyst::Plugin::BigSitemap - Auto-generated Sitemaps for up to 2.5 billion URLs.

=head1 VERSION

0.02

=head1 DESCRIPTION

A compete drop-in replacement for L<Catalyst::Plugin::Sitemap> but gives you the 
following features as well.

Additional Functionality:

1. Automatic generation of a sitemap index with multiple sitemap files.

2. Writing sitemap files to disk as XML (can be gzipped as well).

3. Configurable naming of sitemap and sitemap index files.  

4. 2,500,000,000 URL maximum

Even if you don't have a site with more than 50,000 URLS, this module can
write (and rewrite) your sitemap files to disk (something the original L<Catalyst::Plugin::Sitemap> 
module lacks), so you may wish to consider this module for no other reason than that.

=head1 SYNOPSIS

    #
    # Actions you want included in your sitemap.  In this example, there's a total of 10 urls that will be written
    #

    # loc will be automatically resolved for this action
    sub single_url_action :Local :Args(0) :Sitemap() { ... }
    
    # see WWW::Sitemap::XML::URL for all the possible attributes 
    sub single_url_with_attrs : Local :Args(0) :Sitemap( changefreq => 'daily', priority => '0.5' ) { ... }
    
    # If you have multiple urls that map to an action, you need to specify the string '*' as it's only attribute
    # then you must specify a method with the same name plus '_sitemap' as your action method.  Within that action,
    # you'll need to call the ->add method on your sitemap.  
    sub multiple_url_action :Local :Args(1) :Sitemap('*') { ... }    
    sub multiple_url_action_sitemap {
        my ( $self, $c, $sitemap ) = @_;
        
        my $a = $c->controller('MyController')->action_for('multiple_url_action');
        for (my $i = 0; $i < 8; $i++) {
            my $uri = $c->uri_for($a, [ $i, ]);

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 2.500 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )