/
Comment.pm
57 lines (44 loc) · 1.41 KB
/
Comment.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package MojoMojo::Schema::Result::Comment;
use strict;
use warnings;
use base qw/MojoMojo::Schema::Base::Result/;
use Text::Textile2();
my $textile = Text::Textile2->new(
disable_html => 1,
flavor => 'xhtml2',
charset => 'utf8',
char_encoding => 1
);
__PACKAGE__->load_components(qw/DateTime::Epoch PK::Auto UTF8Columns Core/);
__PACKAGE__->table("comment");
__PACKAGE__->add_columns(
"id",
{ data_type => "INTEGER", is_nullable => 0, size => undef, is_auto_increment => 1 },
"poster",
{ data_type => "INTEGER", is_nullable => 0, size => undef },
"page",
{ data_type => "INTEGER", is_nullable => 0, size => undef },
"picture",
{ data_type => "INTEGER", is_nullable => 1, size => undef },
"posted",
{ data_type => "BIGINT", is_nullable => 0, size => undef, epoch => 'ctime' },
"body",
{ data_type => "TEXT", is_nullable => 0, size => undef },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to( "poster", "Person", { id => "poster" } );
__PACKAGE__->belongs_to( "page", "Page", { id => "page" } );
__PACKAGE__->belongs_to( "picture", "Photo", { id => "picture" } );
__PACKAGE__->utf8_columns(qw/body/);
=head1 NAME
MojoMojo::Schema::Result::Comment
=head1 METHODS
=over 4
=item formatted
Returns a textile formatted version of the given comment.
=cut
sub formatted {
my $self = shift;
return $textile->process( $self->body );
}
1;