Commit | Line | Data |
ebd4c292 |
1 | package SCSite::Page; |
2 | |
3 | use IO::All; |
2a19b2a6 |
4 | use Time::Local qw(timelocal); |
ebd4c292 |
5 | use Moo; |
6 | |
2a19b2a6 |
7 | has $_ => (is => 'ro') for qw( |
8 | title subtitle description keywords body created path |
9 | ); |
10 | |
11 | sub published_at { |
12 | $_[0]->created |
13 | ? scalar localtime timelocal |
14 | map +(@{$_}[0..3], $_->[4]-1, $_->[5]-1900), |
15 | [ reverse split '\D+', $_[0]->created ] |
16 | : '' |
17 | } |
ebd4c292 |
18 | |
34597fb2 |
19 | has "_$_" => (is => 'ro', init_arg => $_) for qw(page_set); |
ebd4c292 |
20 | |
21 | sub children { |
fc436d2e |
22 | my ($self, %args) = @_; |
23 | if (my $at = delete $args{at_depth}) { |
221c4151 |
24 | @args{qw(min_depth max_depth)} = ($at, $at); |
fc436d2e |
25 | } |
ebd4c292 |
26 | my $ps = $self->_page_set; |
27 | (ref $ps)->new( |
34597fb2 |
28 | top_dir => $ps->base_dir, |
29 | base_dir => io->dir($ps->base_dir)->catdir($self->path), |
fc436d2e |
30 | max_depth => 1, |
31 | %args, |
ebd4c292 |
32 | ); |
33 | } |
34 | |
35 | 1; |