.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Jifty::Plugin::Comment 3pm" .TH Jifty::Plugin::Comment 3pm "2009-06-26" "perl v5.12.4" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Jifty::Plugin::Comment \- Add comments to any record .SH "SYNOPSIS" .IX Header "SYNOPSIS" Setup the \fIconfig.yml\fR .PP .Vb 2 \& Plugins: \& \- Comment: \& \& # Set this if you want spam checking by Net::Akismet \& Akismet: \& Key: 1234567890a \& Url: http://example.com \& \& # Set this if you want to customize the HTML scrubbing of comments \& Scrubber: \& message: "Comments may only contain , , and tags." \& allow: \& \- strong \& \- em \& \- a \& default: \& \- 0 \& \- \& \*(Aq*\*(Aq: 0 \& href: !!perl/regexp: \& REGEXP: \*(Aq^(?!(?:java)?script)\*(Aq \& MODIFIERS: i .Ve .PP Setup a model that has comments: .PP .Vb 1 \& package App::Model::Fooble; \& \& use Jifty::DBI::Schema; \& use App::Record schema { \& column scribble => type is \*(Aqtext\*(Aq; \& column wobble => type is \*(Aqint\*(Aq; \& }; \& \& use Jifty::Plugin::Comment::Mixin::Model::Commented; \& \& sub allow_owner_update_delete { \& my $self = shift; \& my ($right, %args) = @_; \& \& if ($right eq \*(Aqcreate\*(Aq) { \& return \*(Aqallow\*(Aq ;#if $self\->current_user\->id; \& } \& \& if ($right eq \*(Aqupdate\*(Aq || $right eq \*(Aqdelete\*(Aq) { \& return \*(Aqallow\*(Aq if $self\->current_user\->id; \& } \& \& if ($right eq \*(Aqread\*(Aq) { \& return \*(Aqallow\*(Aq; \& } \& \& return \*(Aqdeny\*(Aq; \& }; \& \& App::Model::FoobleComment\->add_trigger( name => \*(Aqbefore_access\*(Aq, callback => \e&allow_owner_update_delete); \& App::Model::Comment\->add_trigger( name => \*(Aqbefore_access\*(Aq, callback => \e&allow_owner_update_delete); .Ve .PP Setup a view for creating, viewing, and managing the comments: .PP .Vb 3 \& # assuming $fooble here isa App::Action::UpdateFooble object \& template \*(Aqfooble/view\*(Aq => page { \& my $fooble = get \*(Aqfooble\*(Aq; \& \& render_action $fooble, undef, { render_mode => \*(Aqread\*(Aq }; \& \& render_region \& name => \*(Aqfooble\-comments\*(Aq, \& path => \*(Aq_\|_comment/list_and_add\*(Aq, \& defaults => { \& comment_upon => $fooble\->record\->for_commenting, \& initial_title => \*(AqRe: \*(Aq.substr($fooble\->scribble, 0, 20).\*(Aq...\*(Aq, \& }, \& ; \& }; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This plugin allows you to attach comments to any model. You do this using the three steps listed in the synopsis. For variations on these steps, see the other classes that handle the individual parts. .SH "COMMENTED RECORDS" .IX Header "COMMENTED RECORDS" To set up a commented model, you will need to do the following: .IP "1 Add ths plugin to your project by modifying your \fIconfig.yml\fR." 4 .IX Item "1 Add ths plugin to your project by modifying your config.yml." .PD 0 .IP "1 Add the Jifty::Plugin::Comment::Mixin::Model::Commented mixin to the model or models that you want to have comments attached to. See that class for details on how it works. You may also want to examine Jifty::Plugin::Comment::Model::Comment on how to customize that class for your application." 4 .IX Item "1 Add the Jifty::Plugin::Comment::Mixin::Model::Commented mixin to the model or models that you want to have comments attached to. See that class for details on how it works. You may also want to examine Jifty::Plugin::Comment::Model::Comment on how to customize that class for your application." .IP "1 Create a view that appends a comment editor to your edit form (or on a separate page or wherever you feel like comments work best in your application). You should be able to use these views from either Template::Declare or HTML::Mason templates. See Jifty::Plugin::Comment::View for additional details on what views are available." 4 .IX Item "1 Create a view that appends a comment editor to your edit form (or on a separate page or wherever you feel like comments work best in your application). You should be able to use these views from either Template::Declare or HTML::Mason templates. See Jifty::Plugin::Comment::View for additional details on what views are available." .PD .SH "METHODS" .IX Header "METHODS" .SS "init" .IX Subsection "init" Called during initialization. This will setup the Net::Akismet object if it is configured and available. .SS "akismet" .IX Subsection "akismet" This returns an instance of Net::Akismet that is used to check to see if a new comment posted contains spam. No such checking is performed if this returns \f(CW\*(C`undef\*(C'\fR, which indicates that \f(CW\*(C`Net::Akismet\*(C'\fR is unavailable, wasn't configured, or there was an error configuring it (e.g., the Akismet server was unavailable during Jifty startup). .SS "scrubber" .IX Subsection "scrubber" This returns an instance of HTML::Scrubber that is used to clean up \s-1HTML\s0 submitted in comments. .SH "TO DO" .IX Header "TO DO" Right now the module depends directly upon HTML::Scrubber to do the work of cleaning up the text. You might want to use something else to do this. It also provides no mechanism for customizing any other aspect of the formatting. For example, your application might want to use Markdown, or BBCode, or just turn line breaks in the BR-tags, or anything else to format the comment text. .PP In the future, I'd like to consider something like Text::Pipe or a similar \s-1API\s0 to allow these formats to be customized more easily. .SH "SEE ALSO" .IX Header "SEE ALSO" Net::Akismet, HTML::Scrubber .SH "AUTHOR" .IX Header "AUTHOR" Andrew Sterling Hanenkamp, \f(CW\*(C`\*(C'\fR .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2007 Boomer Consulting, Inc. All Rights Reserved. .PP This program is free software and may be modified and distributed under the same terms as Perl itself.