From: Yanick Champoux Date: Wed, 1 Dec 2010 02:42:04 +0000 (-0500) Subject: Build results of 0db120e (on www-sitemap-xml) X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-Catalyst-Plugin-Sitemap;a=commitdiff_plain;h=639030276b68892e684b816e90e9df1f23ce7aac;hp=d074ab5a56e8e690399d2a01691724fcaf4bc41f Build results of 0db120e (on www-sitemap-xml) --- diff --git a/Build.PL b/Build.PL index 00dbc32..41817dd 100644 --- a/Build.PL +++ b/Build.PL @@ -25,7 +25,7 @@ my %module_build_args = ( 'Yanick Champoux ' ], 'dist_name' => 'Catalyst-Plugin-Sitemap', - 'dist_version' => '0.0.1', + 'dist_version' => '1.0.0', 'license' => 'perl', 'module_name' => 'Catalyst::Plugin::Sitemap', 'recommends' => {}, @@ -33,7 +33,7 @@ my %module_build_args = ( 'requires' => { 'List::Util' => '0', 'Moose::Role' => '0', - 'Search::Sitemap' => '0' + 'WWW::Sitemap::XML' => '0' }, 'script_files' => [] ); diff --git a/Changes b/Changes index 231a297..50fa6d2 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,8 @@ Revision history for Catalyst-Plugin-Sitemap +1.0.0 2010-11-30 21:41:34 America/Montreal + - Change sitemap object under the hood to WWW::Sitemap::XML. + - Add Dancer::Plugin::SiteMap in the 'SEE ALSO' section. + 0.0.1 2010-09-29 20:19:12 America/Montreal - original version unleashed on an unsuspecting world diff --git a/META.json b/META.json index 68b84c2..3f036fe 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Yanick Champoux " ], "dynamic_config" : 0, - "generated_by" : "Dist::Zilla version 4.101900, CPAN::Meta::Converter version 2.101590", + "generated_by" : "Dist::Zilla version 4.102345, CPAN::Meta::Converter version 2.101590", "license" : [ "perl_5" ], @@ -28,7 +28,7 @@ "requires" : { "List::Util" : 0, "Moose::Role" : 0, - "Search::Sitemap" : 0 + "WWW::Sitemap::XML" : 0 } }, "test" : { @@ -47,7 +47,7 @@ "provides" : { "Catalyst::Plugin::Sitemap" : { "file" : "lib/Catalyst/Plugin/Sitemap.pm", - "version" : "v0.0.1" + "version" : "v1.0.0" } }, "release_status" : "stable", @@ -63,6 +63,6 @@ "web" : "http://github.com/yanick/Catalyst-Plugin-Sitemap/tree" } }, - "version" : "0.0.1" + "version" : "1.0.0" } diff --git a/META.yml b/META.yml index 5cb1a5e..225658e 100644 --- a/META.yml +++ b/META.yml @@ -15,7 +15,7 @@ build_requires: configure_requires: Module::Build: 0.3601 dynamic_config: 0 -generated_by: 'Dist::Zilla version 4.101900, CPAN::Meta::Converter version 2.101590' +generated_by: 'Dist::Zilla version 4.102345, CPAN::Meta::Converter version 2.101590' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -24,13 +24,13 @@ name: Catalyst-Plugin-Sitemap provides: Catalyst::Plugin::Sitemap: file: lib/Catalyst/Plugin/Sitemap.pm - version: v0.0.1 + version: v1.0.0 requires: List::Util: 0 Moose::Role: 0 - Search::Sitemap: 0 + WWW::Sitemap::XML: 0 resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Plugin-Sitemap homepage: http://search.cpan.org/dist/Catalyst-Plugin-Sitemap/ repository: git://github.com/yanick/Catalyst-Plugin-Sitemap.git -version: 0.0.1 +version: 1.0.0 diff --git a/SIGNATURE b/SIGNATURE index 25fc168..ee9b349 100644 --- a/SIGNATURE +++ b/SIGNATURE @@ -14,21 +14,21 @@ not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -SHA1 6e9257c1f0d56e7477a6c3dd0a89aa12da99ee34 Build.PL -SHA1 6c29f09fb70d3a649beeeba49c327c508b8d3f21 Changes +SHA1 ec9d7233b92322084ff257368adcd37e8f392c4f Build.PL +SHA1 a5008ab99697e794fd04d95f623e7862990bb888 Changes SHA1 3ee0d276167c367325eebe1d5ec9877ade504d93 LICENSE SHA1 27dbcf2e21d25049bc4486395d18d7550732f2d3 MANIFEST -SHA1 39b94a4484567596f4e466bc82f30785018cd502 META.json -SHA1 2376cd5a83bdb52d9400ece68d4d7c5d4c7376e7 META.yml -SHA1 659d2f7059534127e8b98ce9b276fec2be7a02a8 lib/Catalyst/Plugin/Sitemap.pm +SHA1 abde2a3863a49bfec78410e7371c8196f4cef1ac META.json +SHA1 7362ebdd1d8b2b1085bd8ead8ba7c574de7bc22b META.yml +SHA1 9d90ff124e267a7a5f7968bad9197ea89d919fe4 lib/Catalyst/Plugin/Sitemap.pm SHA1 050aa113e828a52db3c86065c0c0ed50198b7ce8 t/000-report-versions.t SHA1 bcc4b2250ff00f7dfad036512681c9ee57b9cf5a t/lib/TestApp.pm -SHA1 f2cb7af81edd193cac613e42116d29215e4d2e58 t/lib/TestApp/Controller/Root.pm -SHA1 a3bbccffc4212a277329be0055742310bfd4eebb t/sitemap.t +SHA1 7906b6e31e1e56c59cc970c66332f56cd41635ec t/lib/TestApp/Controller/Root.pm +SHA1 67c7e4f0af7ea5454b0f33fb971675f2be5eb973 t/sitemap.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) -iEYEARECAAYFAkyj14cACgkQ34Hwf+GwC4zEfQCg9EWt7+v9hzOQnvTansbtqmUx -xCAAn32842Ivd3MNl3ek05Jq239wv+Fg -=ct87 +iEYEARECAAYFAkz1teUACgkQ34Hwf+GwC4yskQCdHR3zsy//6fNlszKwS+aF1NxO +lnUAoOaZJ1iW9BZYtNPWsgr+/ALcUm5L +=CqLE -----END PGP SIGNATURE----- diff --git a/lib/Catalyst/Plugin/Sitemap.pm b/lib/Catalyst/Plugin/Sitemap.pm index 4730f20..7b17271 100644 --- a/lib/Catalyst/Plugin/Sitemap.pm +++ b/lib/Catalyst/Plugin/Sitemap.pm @@ -1,7 +1,8 @@ package Catalyst::Plugin::Sitemap; BEGIN { - $Catalyst::Plugin::Sitemap::VERSION = '0.0.1'; + $Catalyst::Plugin::Sitemap::VERSION = '1.0.0'; } + # ABSTRACT: Sitemap support for Catalyst. @@ -12,16 +13,26 @@ use Moose::Role; no warnings qw/uninitialized/; -use Search::Sitemap; +use WWW::Sitemap::XML; use List::Util qw/ first /; -sub sitemap { +has sitemap => ( + is => 'ro', + builder => '_build_sitemap', + lazy => 1, +); + +sub sitemap_as_xml { + my $self = shift; + return $self->sitemap->as_xml->toString; +} + +sub _build_sitemap { my $self = shift; - my $sitemap = Search::Sitemap->new; - $sitemap->pretty(1); + my $sitemap = WWW::Sitemap::XML->new; - for my $controller ( $self->controller(qr//) ) { + for my $controller ( map { $self->controller($_) } $self->controllers ) { ACTION: for my $a ( $controller->get_action_methods ) { @@ -48,6 +59,7 @@ sub sitemap { } if ( $attr[0] + 0 > 0 ) { + # it's a number $uri_params{priority} = $attr[0]; } @@ -59,9 +71,7 @@ sub sitemap { $uri_params{loc} = $self->uri_for_action( $action->private_path ); - $sitemap->add( \%uri_params ); - - next ACTION; + $sitemap->add(%uri_params); } } @@ -81,7 +91,7 @@ Catalyst::Plugin::Sitemap - Sitemap support for Catalyst. =head1 VERSION -version 0.0.1 +version 1.0.0 =head1 SYNOPSIS @@ -117,7 +127,7 @@ version 0.0.1 sub sitemap : Path('/sitemap') { my ( $self, $c ) = @_; - $c->res->body( $c->sitemap->xml ); + $c->res->body( $c->sitemap_as_xml ); } =head1 DESCRIPTION @@ -129,10 +139,14 @@ of the sitemap of a Catalyst application. =head2 sitemap() -Returns a L object. The sitemap object is populated by +Returns a L object. The sitemap object is populated by inspecting the controllers of the application for actions with the sub attribute C<:Sitemap>. +=head2 sitemap_as_xml() + +Returns the sitemap as a string containing its XML representation. + =head1 C<:Sitemap> Subroutine Attribute The sitemap is populated by actions ear-marked with the <:Sitemap> sub @@ -170,7 +184,8 @@ resolves in a single url, this will results in an error. ... } -Adds the url with the given entry attributes (as defined by C). +Adds the url with the given entry attributes (as defined by +L). If the action does not resolves in a single url, this will results in an error. @@ -193,26 +208,32 @@ resolving to many urls. =back -=head1 BUGS AND LIMITATIONS - -Currently, each invocation of the method C will -re-generate the C object. A future version -of this module might offer a way to only compute the sitemap -once. - =head1 SEE ALSO =over +=item L + +Module that C currently uses under the hood. + =item L +Original module that this plugin was using under the hood. + +=item L + +Similar plugin for the L framework, which inspired +C. + =item http://babyl.dyndns.org/techblog/entry/catalyst-plugin-sitemap +Blog article introducing C. + =back =head1 AUTHOR - Yanick Champoux +Yanick Champoux =head1 COPYRIGHT AND LICENSE diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm index 0eb3c6e..34aa0be 100644 --- a/t/lib/TestApp/Controller/Root.pm +++ b/t/lib/TestApp/Controller/Root.pm @@ -7,8 +7,15 @@ use parent 'Catalyst::Controller'; sub sitemap : Path('/sitemap') { my ( $self, $c ) = @_; + $c->res->body( $c->sitemap_as_xml ); +} + +sub dynamic :Path('/dynamic') { + my ( $self, $c ) = @_; + + $c->sitemap->add( "http://localhost/sumfin" ); #''.$c->uri_for( '/sumfin' ) ); - $c->res->body( $c->sitemap->xml ); + $c->res->body( 'dynamic it is' ); } sub alone :Local :Sitemap { } diff --git a/t/sitemap.t b/t/sitemap.t index 10f3efe..2780498 100644 --- a/t/sitemap.t +++ b/t/sitemap.t @@ -5,12 +5,11 @@ use warnings; use Test::More tests => 4; # last test to print use lib 't/lib'; - use Catalyst::Test 'TestApp'; -my $xml = request('/sitemap')->content; +my $xml = get('/sitemap'); -diag $xml; +note $xml; $xml =~ s/\s+//g;