diff --git a/Changes b/Changes index 9b66d55..3dffa01 100644 --- a/Changes +++ b/Changes @@ -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. diff --git a/lib/HiD/Generator.pm b/lib/HiD/Generator.pm index 3de4ce7..3c28f0f 100644 --- a/lib/HiD/Generator.pm +++ b/lib/HiD/Generator.pm @@ -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; diff --git a/lib/HiD/Generator/ArchivePage.pm b/lib/HiD/Generator/ArchivePage.pm index fb22400..8c823d1 100644 --- a/lib/HiD/Generator/ArchivePage.pm +++ b/lib/HiD/Generator/ArchivePage.pm @@ -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 => {} , diff --git a/lib/HiD/Generator/CategoryPages.pm b/lib/HiD/Generator/CategoryPages.pm index eb280fb..143d1f1 100644 --- a/lib/HiD/Generator/CategoryPages.pm +++ b/lib/HiD/Generator/CategoryPages.pm @@ -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 , diff --git a/lib/HiD/Generator/TagPages.pm b/lib/HiD/Generator/TagPages.pm index 0a2ef27..0626203 100644 --- a/lib/HiD/Generator/TagPages.pm +++ b/lib/HiD/Generator/TagPages.pm @@ -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 ,