-
Notifications
You must be signed in to change notification settings - Fork 3
/
Comment.pm
89 lines (78 loc) · 1.83 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package RavLog::Schema::DB::Comment;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components( "PK::Auto", "InflateColumn::DateTime", "Core" );
__PACKAGE__->table("comments");
__PACKAGE__->add_columns(
"comment_id",
{
data_type => 'integer',
is_auto_increment => 1,
default_value => undef,
is_nullable => 0,
},
"name",
{
data_type => "character varying",
default_value => undef,
is_nullable => 1,
size => 255,
},
"email",
{
data_type => "character varying",
default_value => undef,
is_nullable => 1,
size => 255,
},
"url",
{
data_type => "character varying",
default_value => undef,
is_nullable => 1,
size => 255,
},
"comment",
{
data_type => "text",
default_value => undef,
is_nullable => 1,
size => undef,
},
"remote_ip",
{
data_type => "character varying",
default_value => undef,
is_nullable => 1,
size => 32,
},
"created_at",
{
data_type => "datetime",
default_value => "now()",
is_nullable => 1,
size => undef,
},
"article_id",
{ data_type => "integer", default_value => undef, is_nullable => 1, size => 4 },
);
use Text::Textile qw(textile);
sub textilize
{
my $self = shift;
my $what = shift;
my $temp = $self->$what;
$temp =~ s/\[code (.*?)\]/==<pre>\[code $1\]/g;
$temp =~ s/\[\/code\]/\[\/code\]<\/pre>==/g;
return textile($temp);
}
sub insert
{
my $self = shift;
$self->created_at( DateTime->now() );
$self->next::method(@_);
}
__PACKAGE__->set_primary_key("comment_id");
__PACKAGE__->belongs_to( 'article', 'RavLog::Schema::DB::Article', 'article_id' );
1;