App-Plog

 view release on metacpan or  search on metacpan

lib/App/Plog.pm  view on Meta::CPAN


my ($arguments, $configuration, $blog_id, $blog_directory, $blog_configuration_file, $blog_configuration, $temporary_directory) = @_ ;

my $root_directory = "$configuration->{plog_root_directory}/*" ;
my @files = glob($root_directory) ;

for my $file (@files)
	{
	print {*STDOUT} substr($file, (length($root_directory) - 1)),  "\t($file)\n" if -d $file ;
	}

return ;
}

#-------------------------------------------------------------------------------

sub generate_blog ## no critic (Subroutines::ProhibitManyArgs)
{

=head2 generate_blog(...)

Handles the creation of the blog and its feed, including the creation of  the objects defined in the I<plog> configuration.

I<Arguments>- see B<Returns> in sub L<parse_configuration>

I<Returns> - Nothing

I<Exceptions> - Croaks if object needed to generate the blog can't be created

=cut

my ($arguments, $configuration, $blog_id, $blog_directory, $blog_configuration_file, $blog_configuration, $temporary_directory) = @_ ;

# create objects
my $rcs = eval q~$blog_configuration->{rcs}{class}->new($blog_configuration->{rcs})~ ; croak $EVAL_ERROR if $EVAL_ERROR ;
my $renderer = eval q~$blog_configuration->{renderer}{class}->new($blog_configuration->{renderer})~ ; croak $EVAL_ERROR if $EVAL_ERROR ;
my $aggregator = eval q~$blog_configuration->{aggregator}{class}->new($blog_configuration->{aggregator})~ ; croak $EVAL_ERROR if $EVAL_ERROR ;

# create blog
my $entries = $rcs->parse($blog_directory, $temporary_directory) ;
my $rendered_entries = $renderer->render($entries, $blog_directory, $temporary_directory) ;
my $aggregated_entries = $aggregator->aggregate($rendered_entries, $blog_directory, $temporary_directory) ;

if(exists $blog_configuration->{feed})
	{
	my $feed_generator = eval q~$blog_configuration->{feed}{class}->new($blog_configuration->{feed})~ ; croak $EVAL_ERROR if $EVAL_ERROR ;
	$feed_generator->generate($rendered_entries, $blog_directory, $temporary_directory) ; 
	}

my $elements_directory = "$blog_directory/$blog_configuration->{elements_directory}/*" ;

# update the temporary directory with blog element to allo the user to check his blog
# without having to update the web page
dircopy($elements_directory, $temporary_directory) or carp $! ;

return ;
}

#-------------------------------------------------------------------------------

sub update_blog ## no critic (Subroutines::ProhibitManyArgs)
{

=head2 update_blog(...)

Generates the blog and runs the update script defined in I<$blog_configuration->{update_script}>. The update
script usually publishes the blog by copying the necessary data to a web server.

The update script is either a script in the language of your choosing, in which case the following arguments are passed 
on the command line

=over 2

=item * $blog_configuration_file  

=item * $blog_directory 

=item * $temporary_directory

=back 

or a perl sub in which case the following arguments are passed to the sub

=over 2

=item * $blog_configuration

=item * $blog_directory 

=item * $temporary_directory

=back 

I<Arguments>- see B<Returns> in sub L<parse_configuration>

I<Returns> - Nothing

I<Exceptions>

=cut

my ($arguments, $configuration, $blog_id, $blog_directory, $blog_configuration_file, $blog_configuration, $temporary_directory) = @_ ;

generate_blog(@_) ;

if('CODE' eq ref $blog_configuration->{update_script})
	{
	$blog_configuration->{update_script}->($blog_configuration,  $blog_directory, $temporary_directory) ;
	}
else
	{
	print {*STDOUT} run_ipc3("$blog_directory/$blog_configuration->{update_script}", 'to get entry text') ; 
	}

return ;
}

#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------

package App::Plog::RCS::Git ;



( run in 1.214 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )