]> Dogcows Code - chaz/p5-Catalyst-Plugin-Sitemap/blobdiff - lib/Catalyst/Plugin/Sitemap.pm
Build results of 37c98d0 (on master)
[chaz/p5-Catalyst-Plugin-Sitemap] / lib / Catalyst / Plugin / Sitemap.pm
index 3cadf65c89ae51ea3cdb4192e9cb0e7308d417d2..4730f200a6f8993a4a827fcc6f57b6be16c09366 100644 (file)
@@ -1,6 +1,88 @@
 package Catalyst::Plugin::Sitemap;
+BEGIN {
+  $Catalyst::Plugin::Sitemap::VERSION = '0.0.1';
+}
 # ABSTRACT: Sitemap support for Catalyst.
 
+
+use strict;
+use warnings;
+
+use Moose::Role;
+
+no warnings qw/uninitialized/;
+
+use Search::Sitemap;
+use List::Util qw/ first /;
+
+sub sitemap {
+    my $self = shift;
+
+    my $sitemap = Search::Sitemap->new;
+    $sitemap->pretty(1);
+
+    for my $controller ( $self->controller(qr//) ) {
+      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 );
+
+            next ACTION;
+        }
+
+    }
+
+    return $sitemap;
+}
+
+1;
+
+
+
+=pod
+
+=head1 NAME
+
+Catalyst::Plugin::Sitemap - Sitemap support for Catalyst.
+
+=head1 VERSION
+
+version 0.0.1
+
 =head1 SYNOPSIS
 
     # in MyApp.pm
@@ -71,7 +153,6 @@ resolves in a single url, this will results in an error.
 
 =item C<:Sitemap($priority)>
 
-
     sub with_priority :Local :Sitemap(0.9) {
         ...
     }
@@ -112,7 +193,6 @@ resolving to many urls.
 
 =back
 
-
 =head1 BUGS AND LIMITATIONS
 
 Currently, each invocation of the method C<sitemap()> will 
@@ -120,10 +200,9 @@ re-generate the C<Search::Sitemap> object.  A future version
 of this module might offer a way to only compute the sitemap
 once.
 
-
 =head1 SEE ALSO
 
-=over 
+=over
 
 =item L<Search::Sitemap>
 
@@ -131,72 +210,18 @@ once.
 
 =back
 
-=cut
-
-use strict;
-use warnings;
-
-use Moose::Role;
-
-no warnings qw/uninitialized/;
-
-use Search::Sitemap;
-use List::Util qw/ first /;
-
-sub sitemap {
-    my $self = shift;
-
-    my $sitemap = Search::Sitemap->new;
-    $sitemap->pretty(1);
-
-    for my $controller ( $self->controller(qr//) ) {
-      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];
+=head1 AUTHOR
 
-            my %uri_params;
+  Yanick Champoux <yanick@babyl.dyndns.org>
 
-            if ( @attr == 1 ) {
-                if ( $attr[0] eq '*' ) {
-                    my $sitemap_method = $action->name . "_sitemap";
+=head1 COPYRIGHT AND LICENSE
 
-                    if ( $controller->can($sitemap_method) ) {
-                        $controller->$sitemap_method( $self, $sitemap );
-                        next ACTION;
-                    }
-                }
+This software is copyright (c) 2010 by Yanick Champoux.
 
-                if ( $attr[0] + 0 > 0 ) {
-                    # it's a number
-                    $uri_params{priority} = $attr[0];
-                }
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
 
-            }
-            elsif ( @attr > 0 ) {
-                %uri_params = @attr;
-            }
-
-            $uri_params{loc} = $self->uri_for_action( $action->private_path );
-
-            $sitemap->add( \%uri_params );
-
-            next ACTION;
-        }
-
-    }
-
-    return $sitemap;
-}
+=cut
 
-1;
 
 __END__
This page took 0.025997 seconds and 4 git commands to generate.