Skip to content

Commit

Permalink
Update plugins to create destination directories as needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
genehack committed Mar 11, 2015
1 parent e140bf8 commit 6ff61e5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Revision history for {{$dist->name}}

{{$NEXT}}

Update plugins to create destination directories as needed.
Update ArchivePage plugin.
Update Tags plugin.
Update AtomFeed plugin.
Expand Down
12 changes: 12 additions & 0 deletions lib/HiD/Generator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,17 @@ requires 'generate';
=cut

sub _create_destination_directory_if_needed {
my( $self , $dest ) = @_;

if ( -e $dest ) {
$self->FATAL( "'$dest' exists and is not a directory!" )
unless -d $dest;
}
else { mkdir $dest }

return 1;
}

no Moose::Role;
1;
1 change: 1 addition & 0 deletions lib/HiD/Generator/ArchivePage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ sub generate {

my $destination = $site->config->{archive_page}{destination} // $site->destination;

$self->_create_destination_directory_if_needed( $destination );

my %archive = (
by_year => {} ,
Expand Down
2 changes: 2 additions & 0 deletions lib/HiD/Generator/CategoryPages.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ sub generate {

my $destination = $self->destination // $site->destination;

$self->_create_destination_directory_if_needed( $destination );

foreach my $category ( keys %{ $site->categories } ) {
my $page = HiD::Page->new({
dest_dir => $destination ,
Expand Down
2 changes: 2 additions & 0 deletions lib/HiD/Generator/TagPages.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ sub generate {

my $destination = $site->config->{tags}{destination} // $site->destination;

$self->_create_destination_directory_if_needed( $destination );

foreach my $tag ( keys %{ $site->tags } ) {
my $page = HiD::Page->new({
dest_dir => $destination ,
Expand Down

0 comments on commit 6ff61e5

Please sign in to comment.