Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (81 sloc) 2.235 kb
b1107bf @tempire initial commit
authored
1 use utf8;
2 package Schema::Result::Blog;
3
4 # Created by DBIx::Class::Schema::Loader
5 # DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7 use strict;
8 use warnings;
9
10 use base 'DBIx::Class::Core';
11 __PACKAGE__->load_components("InflateColumn::DateTime");
12 __PACKAGE__->table("blogs");
13 __PACKAGE__->add_columns(
14 "id",
15 { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
16 "title",
17 { data_type => "char", is_nullable => 0, size => 100 },
18 "subtitle",
19 { data_type => "tinytext", is_nullable => 1 },
20 "content",
21 { data_type => "text", is_nullable => 0 },
22 "created_time",
23 { data_type => "char", is_nullable => 0, size => 20 },
24 "timestamp",
25 {
26 data_type => "timestamp",
27 default_value => \"current_timestamp",
28 is_nullable => 0,
29 },
30 "location",
31 { data_type => "char", is_nullable => 1, size => 100 },
32 );
33 __PACKAGE__->set_primary_key("id");
34 __PACKAGE__->has_many(
35 "blog_tags",
36 "Schema::Result::BlogTag",
37 { "foreign.blog" => "self.id" },
38 { cascade_copy => 0, cascade_delete => 0 },
39 );
40
41
42 # Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-02-05 21:35:07
43 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Pu8So1Y80nFfvuHrqLpqag
44
45 use Time::Duration;
46 use DateTime;
47
48 # Convert date strings to datetime objects, and vice versa
381e6be @tempire cleanup
authored
49 __PACKAGE__->inflate_column(
50 "created_time",
51 { inflate => sub { DateTime->from_epoch(epoch => shift); },
52 deflate => sub { shift->epoch; },
53 }
54 );
b1107bf @tempire initial commit
authored
55
56 __PACKAGE__->has_many(
381e6be @tempire cleanup
authored
57 "tags", "Schema::Result::BlogTag",
58 {"foreign.blog" => "self.id"},
59 {cascade_copy => 0, cascade_delete => 0},
b1107bf @tempire initial commit
authored
60 );
61
62 sub url_title {
381e6be @tempire cleanup
authored
63 my $self = shift;
64 my $title = $self->title;
b1107bf @tempire initial commit
authored
65
381e6be @tempire cleanup
authored
66 $title =~ s/\W/_/g;
b1107bf @tempire initial commit
authored
67
381e6be @tempire cleanup
authored
68 return lc $title;
b1107bf @tempire initial commit
authored
69 }
70
71 sub time_since {
381e6be @tempire cleanup
authored
72 return Time::Duration::ago(time - shift->created_time->epoch);
b1107bf @tempire initial commit
authored
73 }
74
75 sub created_time_string {
381e6be @tempire cleanup
authored
76 return shift->created_time->strftime("%A, %B %e, %Y at %l:%M%p");
b1107bf @tempire initial commit
authored
77 }
78
79 sub snippet {
953f3a8 @tempire removed Lingua::Summarize::EN dep, added pre-requisites to README
authored
80 return shift->content;
b1107bf @tempire initial commit
authored
81 }
82
83 1;
84
85 =head1 RELATIONSHIPS
86
87 =head2 tags
88
89 Type: has_many
90
91 Related object: L<Nempire::Schema::Result::BlogTag>
92
93 Alias for: L<blog_tags/Nempire::Schema::Result::BlogTag>
94
95 =head1 METHODS
96
97 =head2 url_title
98
99 Title for readable URLs
100
101 =head2 time_since
102
103 Time since blog was entered
104
105 =head2 created_time_string
106
107 pretty created time string
108
109 =cut
Something went wrong with that request. Please try again.