domain support for feeds, factor out sc-specific bits
[scpubgit/SCS.git] / lib / SCSite / Page.pm
index cba4d6a..028483e 100644 (file)
@@ -1,25 +1,27 @@
 package SCSite::Page;
 
 use IO::All;
+use Time::Local qw(timelocal);
 use Moo;
 
-has $_ => (is => 'ro') for qw(title description keywords body created path);
+with 'SCSite::PageChildren';
 
-has "_$_" => (is => 'ro', init_arg => $_) for qw(page_set);
+has $_ => (is => 'ro') for qw(
+  title subtitle description keywords body created path
+);
 
-sub children {
-  my ($self, %args) = @_;
-  if (my $at = delete $args{at_depth}) {
-warn "Here, $at";
-    @args{qw(min_depth max_depth)} = ($at-1, $at);
-  }
-  my $ps = $self->_page_set;
-  (ref $ps)->new(
-    top_dir => $ps->base_dir,
-    base_dir => io->dir($ps->base_dir)->catdir($self->path),
-    max_depth => 1,
-    %args,
-  );
+sub published_at {
+  $_[0]->created
+    ? scalar localtime timelocal
+        map +(@{$_}[0..3], $_->[4]-1, $_->[5]-1900),
+          [ reverse split '\D+', $_[0]->created ]
+    : ''
 }
 
+has "_$_" => (is => 'ro', init_arg => $_) for qw(page_set);
+
+sub _page_set_class { ref($_[0]->_page_set) }
+sub _top_dir { $_[0]->_page_set->top_dir }
+sub _my_path { io->dir($_[0]->_top_dir)->catdir($_[0]->path) }
+
 1;