028483eaa7f9a16729df6cc36a22071e5e675f52
[scpubgit/SCS.git] / lib / SCSite / Page.pm
1 package SCSite::Page;
2
3 use IO::All;
4 use Time::Local qw(timelocal);
5 use Moo;
6
7 with 'SCSite::PageChildren';
8
9 has $_ => (is => 'ro') for qw(
10   title subtitle description keywords body created path
11 );
12
13 sub published_at {
14   $_[0]->created
15     ? scalar localtime timelocal
16         map +(@{$_}[0..3], $_->[4]-1, $_->[5]-1900),
17           [ reverse split '\D+', $_[0]->created ]
18     : ''
19 }
20
21 has "_$_" => (is => 'ro', init_arg => $_) for qw(page_set);
22
23 sub _page_set_class { ref($_[0]->_page_set) }
24 sub _top_dir { $_[0]->_page_set->top_dir }
25 sub _my_path { io->dir($_[0]->_top_dir)->catdir($_[0]->path) }
26
27 1;