]> Dogcows Code - chaz/p5-Catalyst-Plugin-Sitemap/blobdiff - lib/Catalyst/Plugin/Sitemap.pm
Build results of 0db120e (on www-sitemap-xml)
[chaz/p5-Catalyst-Plugin-Sitemap] / lib / Catalyst / Plugin / Sitemap.pm
index e4a906c981ce501e9753b2cb31e14bbaaa01ec46..7b172711f3807ebe3747a2c7e3768e852f8cd02b 100644 (file)
@@ -1,7 +1,98 @@
 package Catalyst::Plugin::Sitemap;
+BEGIN {
+  $Catalyst::Plugin::Sitemap::VERSION = '1.0.0';
+}
 
 # ABSTRACT: Sitemap support for Catalyst.
 
+
+use strict;
+use warnings;
+
+use Moose::Role;
+
+no warnings qw/uninitialized/;
+
+use WWW::Sitemap::XML;
+use List::Util qw/ first /;
+
+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 = WWW::Sitemap::XML->new;
+
+    for my $controller ( map { $self->controller($_) } $self->controllers ) {
+      ACTION:
+        for my $a ( $controller->get_action_methods ) {
+
+            my $action = $controller->action_for( $a->name );
+
+            my $attr = $action->attributes->{Sitemap} or next ACTION;
+
+            die "more than one attribute 'Sitemap' for sub ",
+              $a->fully_qualified_name
+              if @$attr > 1;
+
+            my @attr = split /\s*(?:,|=>)\s*/, $attr->[0];
+
+            my %uri_params;
+
+            if ( @attr == 1 ) {
+                if ( $attr[0] eq '*' ) {
+                    my $sitemap_method = $action->name . "_sitemap";
+
+                    if ( $controller->can($sitemap_method) ) {
+                        $controller->$sitemap_method( $self, $sitemap );
+                        next ACTION;
+                    }
+                }
+
+                if ( $attr[0] + 0 > 0 ) {
+
+                    # it's a number
+                    $uri_params{priority} = $attr[0];
+                }
+
+            }
+            elsif ( @attr > 0 ) {
+                %uri_params = @attr;
+            }
+
+            $uri_params{loc} = $self->uri_for_action( $action->private_path );
+
+            $sitemap->add(%uri_params);
+        }
+
+    }
+
+    return $sitemap;
+}
+
+1;
+
+
+
+=pod
+
+=head1 NAME
+
+Catalyst::Plugin::Sitemap - Sitemap support for Catalyst.
+
+=head1 VERSION
+
+version 1.0.0
+
 =head1 SYNOPSIS
 
     # in MyApp.pm
@@ -76,7 +167,6 @@ resolves in a single url, this will results in an error.
 
 =item C<:Sitemap($priority)>
 
-
     sub with_priority :Local :Sitemap(0.9) {
         ...
     }
@@ -118,10 +208,9 @@ resolving to many urls.
 
 =back
 
-
 =head1 SEE ALSO
 
-=over 
+=over
 
 =item L<WWW::Sitemap::XML>
 
@@ -131,7 +220,6 @@ Module that C<Catalyst::Plugin::Sitemap> currently uses under the hood.
 
 Original module that this plugin was using under the hood.
 
-
 =item L<Dancer::Plugin::SiteMap>
 
 Similar plugin for the L<Dancer> framework, which inspired
@@ -143,81 +231,18 @@ Blog article introducing C<Catalyst::Plugin::Sitemap>.
 
 =back
 
-=cut
-
-use strict;
-use warnings;
-
-use Moose::Role;
-
-no warnings qw/uninitialized/;
-
-use WWW::Sitemap::XML;
-use List::Util qw/ first /;
-
-has sitemap => (
-    is      => 'ro',
-    builder => '_build_sitemap',
-    lazy    => 1,
-);
-
-sub sitemap_as_xml {
-    my $self = shift;
-    return $self->sitemap->as_xml->toString;
-}
+=head1 AUTHOR
 
-sub _build_sitemap {
-    my $self = shift;
+Yanick Champoux <yanick@babyl.dyndns.org>
 
-    my $sitemap = WWW::Sitemap::XML->new;
-
-    for my $controller ( map { $self->controller($_) } $self->controllers ) {
-      ACTION:
-        for my $a ( $controller->get_action_methods ) {
+=head1 COPYRIGHT AND LICENSE
 
-            my $action = $controller->action_for( $a->name );
+This software is copyright (c) 2010 by Yanick Champoux.
 
-            my $attr = $action->attributes->{Sitemap} or next ACTION;
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
 
-            die "more than one attribute 'Sitemap' for sub ",
-              $a->fully_qualified_name
-              if @$attr > 1;
-
-            my @attr = split /\s*(?:,|=>)\s*/, $attr->[0];
-
-            my %uri_params;
-
-            if ( @attr == 1 ) {
-                if ( $attr[0] eq '*' ) {
-                    my $sitemap_method = $action->name . "_sitemap";
-
-                    if ( $controller->can($sitemap_method) ) {
-                        $controller->$sitemap_method( $self, $sitemap );
-                        next ACTION;
-                    }
-                }
-
-                if ( $attr[0] + 0 > 0 ) {
-
-                    # it's a number
-                    $uri_params{priority} = $attr[0];
-                }
-
-            }
-            elsif ( @attr > 0 ) {
-                %uri_params = @attr;
-            }
-
-            $uri_params{loc} = $self->uri_for_action( $action->private_path );
-
-            $sitemap->add(%uri_params);
-        }
-
-    }
-
-    return $sitemap;
-}
+=cut
 
-1;
 
 __END__
This page took 0.023759 seconds and 4 git commands to generate.