| Catalyst::Plugin::Sitemap - Sitemap support for Catalyst. |
:Sitemap Subroutine Attribute
Catalyst::Plugin::Sitemap - Sitemap support for Catalyst.
version 1.0.0
# in MyApp.pm
use Catalyst qw/ Sitemap /;
# in the controller
sub alone :Local :Sitemap {
...
}
sub with_priority :Local :Sitemap(0.75) {
...
}
sub with_args :Local
:Sitemap( lastmod => 2010-09-27, changefreq => daily ) {
...
}
sub with_function :Local :Sitemap(*) {
...
}
sub with_function_sitemap {
$_[2]->add( 'http://localhost/with_function' );
}
# and then...
sub sitemap : Path('/sitemap') {
my ( $self, $c ) = @_;
$c->res->body( $c->sitemap_as_xml );
}
the Catalyst::Plugin::Sitemap manpage provides a way to semi-automate the creation of the sitemap of a Catalyst application.
sitemap()Returns a the WWW::Sitemap::XML manpage object. The sitemap object is populated by
inspecting the controllers of the application for actions with the
sub attribute :Sitemap.
sitemap_as_xml()Returns the sitemap as a string containing its XML representation.
:Sitemap Subroutine AttributeThe sitemap is populated by actions ear-marked with the <:Sitemap> sub attribute. It can be invoked in different ways:
:Sitemap
sub alone :Local :Sitemap {
...
}
Adds the url of the action to the sitemap.
If the action does not resolves in a single url, this will results in an error.
:Sitemap($priority)
sub with_priority :Local :Sitemap(0.9) {
...
}
Adds the url, with the given number, which has to be between 1 (inclusive) and 0 (exclusive), as its priority.
If the action does not resolves in a single url, this will results in an error.
:Sitemap( %attributes )
sub with_args :Local
:Sitemap( lastmod => 2010-09-27, changefreq => daily ) {
...
}
Adds the url with the given entry attributes (as defined by the WWW::Sitemap::XML::URL manpage).
If the action does not resolves in a single url, this will results in an error.
:Sitemap(*)
sub with_function :Local :Sitemap(*) { }
sub with_function_sitemap {
my ( $self, $c, $sitemap ) = @_;
$sitemap->add( 'http://localhost/with_function' );
}
Calls the function 'action_sitemap', if it exists, and passes it the controller, context and sitemap objects.
This is currently the only way to invoke :Sitemap on an action
resolving to many urls.
Module that Catalyst::Plugin::Sitemap currently uses under the hood.
Original module that this plugin was using under the hood.
Similar plugin for the Dancer framework, which inspired
Catalyst::Plugin::Sitemap.
Blog article introducing Catalyst::Plugin::Sitemap.
Yanick Champoux <yanick@babyl.dyndns.org>
This software is copyright (c) 2010 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| Catalyst::Plugin::Sitemap - Sitemap support for Catalyst. |