diff --git a/lib/Statocles/App/Blog.pm b/lib/Statocles/App/Blog.pm index 757feae8..a561d686 100644 --- a/lib/Statocles/App/Blog.pm +++ b/lib/Statocles/App/Blog.pm @@ -465,7 +465,7 @@ Defaults to the current date. # sub pages around pages => sub { my ( $orig, $self, %opt ) = @_; - $opt{date} ||= DateTime::Moonpig->now( time_zone => 'local' )->ymd; + $opt{date} ||= $self->site->build_date; my $root = $self->url_root; my $is_dated_path = qr{^$root/?(\d{4})/(\d{2})/(\d{2})/}; my @parent_pages = $self->$orig( %opt ); diff --git a/lib/Statocles/Command/build.pm b/lib/Statocles/Command/build.pm index f275dffe..5f1e5125 100644 --- a/lib/Statocles/Command/build.pm +++ b/lib/Statocles/Command/build.pm @@ -12,6 +12,10 @@ sub run { 'base_url|base=s', ); + if ($build_opt{date}) { + $self->site->build_date($build_opt{date}); + } + my $path = Path::Tiny->new( $argv[0] // '.statocles/build' ); $path->mkpath; diff --git a/lib/Statocles/Command/daemon.pm b/lib/Statocles/Command/daemon.pm index a25af9ee..33b75ba0 100644 --- a/lib/Statocles/Command/daemon.pm +++ b/lib/Statocles/Command/daemon.pm @@ -15,6 +15,10 @@ sub run { 'date|d=s', ); + if ($build_opt{date}) { + $self->site->build_date($build_opt{date}); + } + require Mojo::Server::Daemon; my $app = Statocles::Command::daemon::_MOJOAPP->new( site => $self->site, diff --git a/lib/Statocles/Site.pm b/lib/Statocles/Site.pm index 1c0969ae..8b3dac44 100644 --- a/lib/Statocles/Site.pm +++ b/lib/Statocles/Site.pm @@ -10,6 +10,7 @@ use Mojo::Log; use Statocles::Page::Plain; use Statocles::Util qw( derp ); use List::UtilsBy qw( uniq_by ); +use DateTime::Moonpig; =attr title @@ -397,6 +398,27 @@ has _pages => ( clearer => 'clear_pages', ); +=attr build_date + + --- + build_date: 2015-03-27 + build_date: 2015-03-27 12:04:00 + --- + +The date/time of the current build of the site. This is usually set by a build +(or related) command. Defaults to the current date. + +Should be in C or C format. + +=cut + +has build_date => ( + is => 'rw', + isa => DateTimeObj, + coerce => DateTimeObj->coercion, + default => sub { DateTime::Moonpig->now( time_zone => 'local' )->ymd }, +); + =method BUILD Register this site as the global site.