[Jifty-commit] r5202 - in jifty/trunk: lib/Jifty/Plugin/Comment lib/Jifty/Plugin/Comment/Action lib/Jifty/Plugin/Comment/Notification

Jifty commits jifty-commit at lists.jifty.org
Sun Mar 9 22:04:51 EDT 2008


Author: sterling
Date: Sun Mar  9 22:04:51 2008
New Revision: 5202

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Plugin/Comment/Action/CreateComment.pm
   jifty/trunk/lib/Jifty/Plugin/Comment/Dispatcher.pm
   jifty/trunk/lib/Jifty/Plugin/Comment/Notification/CommentNeedsModeration.pm
   jifty/trunk/lib/Jifty/Plugin/Comment/Notification/CommentPublished.pm
   jifty/trunk/lib/Jifty/Plugin/Comment/View.pm

Log:
 r15582 at dynpc145:  andrew | 2008-03-09 21:04:02 -0500
 Fix POD coverage failures for the Comment plugin.


Modified: jifty/trunk/lib/Jifty/Plugin/Comment/Action/CreateComment.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Comment/Action/CreateComment.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Comment/Action/CreateComment.pm	Sun Mar  9 22:04:51 2008
@@ -4,6 +4,70 @@
 package Jifty::Plugin::Comment::Action::CreateComment;
 use base qw/ Jifty::Action::Record::Create /;
 
+=head1 NAME
+
+Jifty::Plugin::Comment::Action::CreateComment - custom CreateComment that attaches the comment to the parent
+
+=head1 DESCRIPTION
+
+This is a specialized create action that attaches the comment to the parent object.
+
+=head1 SCHEMA
+
+=head2 parent_class
+
+This is the parent model class. This class must use the L<Jifty::Plugin::Comment::Mixin::Model::Commented> mixin.
+
+=head2 parent_id
+
+This is the ID of the object to attach the comment to.
+
+=head2 title
+
+This is the title the author of the comment has given it.
+
+=head2 your_name
+
+This is the name of the author of the comment.
+
+=head2 web_site
+
+This is the (optional) web site of the author of the comment.
+
+=head2 email
+
+This is the (optional) email address of the author of the comment.
+
+=head2 body
+
+This is the comment message.
+
+=head2 published
+
+This is true if the comment should be published or false if it is only visible to moderators.
+
+=head2 created_on
+
+This is the timestamp of the comment's creation.
+
+=head2 status
+
+This is string with either the value "spam" for a message that has been flagged as spam or "ham" for a message that is not spam.
+
+=head2 http_referer
+
+The referer claimed by the client.
+
+=head2 http_user_agent
+
+The user agent claimed by the client.
+
+=head2 ip_addr
+
+The IP address of the client.
+
+=cut
+
 use Jifty::Param::Schema;
 use Jifty::Action::Record::Create schema {
     param parent_class =>
@@ -101,8 +165,22 @@
 #use Contentment::Util;
 use Regexp::Common qw/ Email::Address URI /;
 
+=head1 METHODS
+
+=head2 record_class
+
+Returns the application's comment class.
+
+=cut
+
 sub record_class { Jifty->app_class('Model', 'Comment') }
 
+=head2 parent
+
+This converts the "parent_id" and "parent_class" arguments into an object.
+
+=cut
+
 sub parent {
     my $self = shift;
 
@@ -115,6 +193,12 @@
     return $parent;
 }
 
+=head2 take_action
+
+Performs the work of attaching the comment to the parent object.
+
+=cut
+
 sub take_action {
     my $self = shift;
 
@@ -173,11 +257,23 @@
     }
 }
 
+=head2 report_success
+
+Reports success or the need for moderation of the message.
+
+=cut
+
 sub report_success {
     my $self = shift;
     $self->result->message(_("Your comment has been added. If it does not immediately appear, it may have been flagged for moderation and should appear shortly."));
 }
 
+=head2 fetch_comment_cookie
+
+Creating a comment this way causes a cookie named "COMMENT_REMEMBORY" to be stored on the client to remember the client's name, email, and web site choice for the next comment.
+
+=cut
+
 my $comment_cookie;
 sub fetch_comment_cookie {
     return $comment_cookie if defined $comment_cookie;
@@ -189,6 +285,12 @@
     return $comment_cookie;
 }
 
+=head2 from_cookie
+
+Loads the name, email, and web site from the stored cookie.
+
+=cut
+
 sub from_cookie {
     my $pos = shift;
 
@@ -217,6 +319,12 @@
     }
 }
 
+=head2 validate_title
+
+Make sure a title is set.
+
+=cut
+
 sub validate_title {
     my $self = shift;
     my $title = shift;
@@ -240,6 +348,12 @@
 #    return $your_name;
 #}
 
+=head2 validate_web_site
+
+Make sure the web site given is valid.
+
+=cut
+
 sub validate_web_site {
     my $self = shift;
     my $web_site = shift;
@@ -257,6 +371,12 @@
     return $self->validation_ok('web_site');
 }
 
+=head2 validate_email
+
+Make sure the email given is valid.
+
+=cut
+
 sub validate_email {
     my $self = shift;
     my $email = shift;
@@ -274,6 +394,12 @@
     return $self->validation_ok('email');
 }
 
+=head2 validate_body
+
+Checks to see if the scrubbed HTML is the same as the given HTML to see if it will be changed on save and reports that to the client.
+
+=cut
+
 sub validate_body {
     my $self = shift;
     my $body = shift;
@@ -294,4 +420,16 @@
     return $self->validation_ok('body');
 }
 
+=head1 AUTHOR
+
+Andrew Sterling Hanenkamp, C<< <hanenkamp at cpan.org> >>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2008 Boomer Consulting, Inc. All Rights Reserved.
+
+This program is free software and may be modified and distributed under the same terms as Perl itself.
+
+=cut
+
 1;

Modified: jifty/trunk/lib/Jifty/Plugin/Comment/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Comment/Dispatcher.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Comment/Dispatcher.pm	Sun Mar  9 22:04:51 2008
@@ -6,6 +6,22 @@
 
 use Scalar::Util qw/ blessed looks_like_number /;
 
+=head1 NAME
+
+Jifty::Plugin::Comment::Dispatcher - dispatcher for the comment plugin
+
+=head1 DESCRIPTION
+
+Handles the dispatch of the C<__comment> paths used by this plugin.
+
+=head1 METHODS
+
+=head2 setup_parent_object
+
+Called internally by the dispatcher rules to create the "parent" dispatcher argument from "comment_upon" or "parent_class" and "parent_id".
+
+=cut
+
 sub setup_parent_object() {
     my $parent;
     unless (get 'parent') {
@@ -40,11 +56,24 @@
 
 }
 
+=head1 RULES
+
+=head2 __comment/list
+
+Sets up the "parent" argument for the list template.
+
+=cut
+
 on '__comment/list' => run {
     setup_parent_object();
-    show '/__comment/list';
 };
 
+=head2 __comment/add
+
+Set up the "parent" argument for the add template and set the "CreateComment" action into the "action" argument.
+
+=cut
+
 on '__comment/add' => run {
     setup_parent_object();
 
@@ -65,6 +94,12 @@
     show '/__comment/add';
 };
 
+=head2 __comment/display
+
+Sets up the "comment" argument and will update the status and published values of the comment if "update_status" or "update_published" are set, respectively.
+
+=cut
+
 on '__comment/display' => run {
     my $id = get 'id';
 
@@ -90,4 +125,20 @@
     set comment => $comment;
 };
 
+=head1 SEE ALSO
+
+L<Jifty::Dispatcher>
+
+=head1 AUTHOR
+
+Andrew Sterling Hanenkamp, C<< <hanenkamp at cpan.org> >>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2008 Boomer Consulting, Inc. All Rights Reserved.
+
+This program is free software and may be modified and distributed under the same terms as Perl itself.
+
+=cut
+
 1;

Modified: jifty/trunk/lib/Jifty/Plugin/Comment/Notification/CommentNeedsModeration.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Comment/Notification/CommentNeedsModeration.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Comment/Notification/CommentNeedsModeration.pm	Sun Mar  9 22:04:51 2008
@@ -6,9 +6,13 @@
 
 __PACKAGE__->mk_accessors(qw/ comment parent /);
 
-=head1 DESCRIPTION
+=head1 NAME
+
+Jifty::Plugin::Comment::Notification::CommentNeedsModeration - new comments made, but not published
 
-If you want to receive these notifications, you must override L</setup> to set your the C<to_list> for your application.
+=head1 SYNOPSIS
+
+To activate this notification, you must override the notification in your application.
 
   use strict;
   use warnings;
@@ -27,8 +31,25 @@
       $self->SUPER::setup(@_);
   }
 
+  sub url {
+      my $self = shift;
+      return Jifty->config->framework('Web')->{'BaseURL'}
+          . $self->parent->permalink
+          . '#comment-'.$self->comment->id;
+  }
+
   1;
 
+=head1 DESCRIPTION
+
+This notificaiton (when properly configured) is sent out to any who need to know when a comment has been created, but not published because L<Net::Akismet> has marked it as spam.
+
+=head1 METHODS
+
+=head2 setup
+
+This method sets up the notification. This method should be overridden to setup L<Jifty::Notification/to_list> to select who will receive this message. See the L</SYNOPSIS>.
+
 =cut
 
 sub setup {
@@ -65,9 +86,39 @@
     ));
 }
 
+=head2 comment
+
+This will contain the L<Jifty::Plugin::Comment::Model::Comment> that has been published.
+
+=head2 parent
+
+This will contain the object that the comment has been attached to.
+
+=head2 url
+
+THis returns the URL that the message will link to. This should be overridden to provide application-specific URLs. The default implementation returns the BaseURL setting for the application.
+
+=cut
+
 sub url {
     my $self = shift;
     return Jifty->config->framework('Web')->{'BaseURL'};
 }
 
+=head1 SEE ALSO
+
+L<Jifty::Notification>, L<Jifty::Plugin::Comment::Notification::CommentPublished>
+
+=head1 AUTHOR
+
+Andrew Sterling Hanenkamp, C<< <hanenkamp at cpan.org> >>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2008 Boomer Consulting, Inc. All Rights Reserved.
+
+This program is free software and may be modified and distributed under the same terms as Perl itself.
+
+=cut
+
 1;

Modified: jifty/trunk/lib/Jifty/Plugin/Comment/Notification/CommentPublished.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Comment/Notification/CommentPublished.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Comment/Notification/CommentPublished.pm	Sun Mar  9 22:04:51 2008
@@ -6,9 +6,13 @@
 
 __PACKAGE__->mk_accessors(qw/ comment parent /);
 
-=head1 DESCRIPTION
+=head1 NAME
+
+Jifty::Plugin::Comment::Notification::CommentPublished - new comments made
 
-If you want to receive these notifications, you must override L</setup> to set your the C<to_list> for your application.
+=head1 SYNOPSIS
+
+To activate this notification, you must override the notification in your application.
 
   use strict;
   use warnings;
@@ -25,8 +29,25 @@
       $self->SUPER::setup(@_);
   }
 
+  sub url {
+      my $self = shift;
+      return Jifty->config->framework('Web')->{'BaseURL'}
+          . $self->parent->permalink
+          . '#comment-'.$self->comment->id;
+  }
+
   1;
 
+=head1 DESCRIPTION
+
+This notification (when properly configured) is sent out to any who need to know when a comment has been published.
+
+=head1 METHODS
+
+=head2 setup
+
+This method sets up the notification. This method should be overridden to setup L<Jifty::Notification/to_list> to select who will receive this message. See the L</SYNOPSIS>.
+
 =cut
 
 sub setup {
@@ -61,9 +82,39 @@
     ));
 }
 
+=head2 comment
+
+This will contain the L<Jifty::Plugin::Comment::Model::Comment> that has been published.
+
+=head2 parent
+
+This will contain the object that the comment has been attached to.
+
+=head2 url
+
+This returns the URL that the message will link to. This should be overridden to provide application-specific URLs. The default implementation returns the BaseURL setting for the application.
+
+=cut
+
 sub url {
     my $self = shift;
     return Jifty->config->framework('Web')->{'BaseURL'};
 }
 
+=head1 SEE ALSO
+
+L<Jifty::Notification>, L<Jifty::Plugin::Comment::Notification::CommentNeedsModeration>
+
+=head1 AUTHOR
+
+Andrew Sterling Hanenkamp, C<< <hanenkamp at cpan.org> >>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2008 Boomer Consulting, Inc. All Rights Reserved.
+
+This program is free software and may be modified and distributed under the same terms as Perl itself.
+
+=cut
+
 1;

Modified: jifty/trunk/lib/Jifty/Plugin/Comment/View.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Comment/View.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Comment/View.pm	Sun Mar  9 22:04:51 2008
@@ -6,6 +6,20 @@
 
 use Jifty::DateTime;
 
+=head1 NAME
+
+Jifty::Plugin::Comment::View - the templates for the comment plugin
+
+=head1 DESCRIPTION
+
+=head1 METHODS
+
+=head2 scrub_html
+
+This is a utility used internally for cleaning up the input which might come from a malicious source.
+
+=cut
+
 sub scrub_html($) {
     my $text = shift;
 
@@ -13,6 +27,14 @@
     return $plugin->scrubber->scrub($text);
 }
 
+=head1 TEMPLATES
+
+=head2 __comment/view
+
+This displays a single comment in a page.
+
+=cut
+
 template '__comment/view' => page {
     my $comment = get 'comment';
 
@@ -34,6 +56,12 @@
     show '/advertisement';
 };
 
+=head2 __comment/display
+
+Display a comment in a page region.
+
+=cut
+
 template '__comment/display' => sub {
     my $comment = get 'comment';
     my $top     = get 'top';
@@ -115,6 +143,12 @@
     };
 };
 
+=head2 __comment/add
+
+This presents the form for adding a new comment.
+
+=cut
+
 template '__comment/add' => sub {
     my $collapsed = get 'collapsed';
     my $region    = get 'region';
@@ -223,6 +257,12 @@
     }
 };
 
+=head2 __comment/list
+
+This presents a list of comments attached to a particular comment and the form for adding one more.
+
+=cut
+
 template '__comment/list' => sub {
     my $parent   = get 'parent';
     my $title    = get 'initial_title';
@@ -274,4 +314,20 @@
     }
 };
 
+=head1 SEE ALSO
+
+L<Jifty::View::Declare>
+
+=head1 AUTHOR
+
+Andrew Sterling Hanenkamp, C<< <hanenkamp at cpan.org> >>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2008 Boomer Consulting, Inc. All Rights Reserved.
+
+This program is free software and may be modified and distributed under the same terms as Perl itself.
+
+=cut
+
 1;


More information about the Jifty-commit mailing list