Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Statocles/App/Blog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 4 additions & 0 deletions lib/Statocles/Command/build.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions lib/Statocles/Command/daemon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 22 additions & 0 deletions lib/Statocles/Site.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<YYYY-MM-DD> or C<YYYY-MM-DD HH:MM:SS> 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.
Expand Down