| 1 | package MojoMojo::Schema::Result::Comment; | ||
| 2 | |||
| 3 | 40 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 40 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 40 | ▶ | use parent qw/MojoMojo::Schema::Base::Result/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 40 | ▶ | use Text::Textile; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 40 | my $textile = Text::Textile->new( | |
| 10 | disable_html => 1, | ||
| 11 | flavor => 'xhtml2', | ||
| 12 | charset => 'utf8', | ||
| 13 | char_encoding => 1 | ||
| 14 | ); | ||
| 15 | |||
| 16 | 40 | __PACKAGE__->load_components( | |
| 17 | qw/DateTime::Epoch TimeStamp Core/); | ||
| 18 | 40 | __PACKAGE__->table("comment"); | |
| 19 | 40 | __PACKAGE__->add_columns( | |
| 20 | "id", | ||
| 21 | { | ||
| 22 | data_type => "INTEGER", | ||
| 23 | is_nullable => 0, | ||
| 24 | size => undef, | ||
| 25 | is_auto_increment => 1 | ||
| 26 | }, | ||
| 27 | "poster", | ||
| 28 | { data_type => "INTEGER", is_nullable => 0, size => undef }, | ||
| 29 | "page", | ||
| 30 | { data_type => "INTEGER", is_nullable => 0, size => undef }, | ||
| 31 | "picture", | ||
| 32 | { data_type => "INTEGER", is_nullable => 1, size => undef }, | ||
| 33 | "posted", | ||
| 34 | { | ||
| 35 | data_type => "BIGINT", | ||
| 36 | is_nullable => 0, | ||
| 37 | size => undef, | ||
| 38 | inflate_datetime => 'epoch', | ||
| 39 | set_on_create => 1, | ||
| 40 | }, | ||
| 41 | "body", | ||
| 42 | { data_type => "TEXT", is_nullable => 0, size => undef }, | ||
| 43 | ); | ||
| 44 | 40 | __PACKAGE__->set_primary_key("id"); | |
| 45 | 40 | __PACKAGE__->belongs_to( | |
| 46 | "poster", | ||
| 47 | "MojoMojo::Schema::Result::Person", | ||
| 48 | { id => "poster" } | ||
| 49 | ); | ||
| 50 | 40 | __PACKAGE__->belongs_to( | |
| 51 | "page", | ||
| 52 | "MojoMojo::Schema::Result::Page", | ||
| 53 | { id => "page" } | ||
| 54 | ); | ||
| 55 | 40 | __PACKAGE__->belongs_to( | |
| 56 | "picture", | ||
| 57 | "MojoMojo::Schema::Result::Photo", | ||
| 58 | { id => "picture" } | ||
| 59 | ); | ||
| 60 | |||
| 61 | =head1 NAME | ||
| 62 | |||
| 63 | MojoMojo::Schema::Result::Comment - store comments | ||
| 64 | |||
| 65 | =head1 METHODS | ||
| 66 | |||
| 67 | =head2 formatted | ||
| 68 | |||
| 69 | Returns a Textile formatted version of the given comment. | ||
| 70 | |||
| 71 | TODO: the default formatter may not be Textile. | ||
| 72 | |||
| 73 | =cut | ||
| 74 | |||
| 75 | 0 | ▶ | sub formatted { |
|
Subroutine
formatted: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 76 | 0 | my $self = shift; | |
| 77 | 0 | return $textile->process( $self->body ); | |
| 78 | } | ||
| 79 | |||
| 80 | =head1 AUTHOR | ||
| 81 | |||
| 82 | Marcus Ramberg <mramberg@cpan.org> | ||
| 83 | |||
| 84 | =head1 LICENSE | ||
| 85 | |||
| 86 | This library is free software. You can redistribute it and/or modify | ||
| 87 | it under the same terms as Perl itself. | ||
| 88 | |||
| 89 | =cut | ||
| 90 | |||
| 91 | 40 | 1; | |