App-Plog

 view release on metacpan or  search on metacpan

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


=over 2 

=item * \%options - the B<aggregator> section from the blog configuration file

=back

I<Returns> - an App::Plog::Aggregator::Template::Inline object

I<Exceptions> -None

=cut

my ($invocant, $options) = @_ ;

my $class = ref($invocant) || $invocant ;
confess 'Invalid constructor call!' unless defined $class ;

my $object = {%{$options}} ;

return bless $object, $class ;
}

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

sub aggregate
{

=head2 aggregate($self, \%entries, $blog_directory, $temporary_directory)

I<Arguments>

=over 2 

=item * $self -

=item * $entries - the entries created by the rcs object and rendered

=item * $blog_directory - the path to the blog directory

=item * $temporary_directory - directory where temporary data can be saved

=back

I<Returns> - Nothing

I<Exceptions> - croaks if template doesn't exist or doesn't contain the tags defined in the configuration.

=cut

my ($self, $entries, $blog_directory, $temporary_directory) = @_ ;

my $html_entries = join "\n", map {$_->[0]{HTML}} values %{$entries};

my $frame = read_file "$blog_directory/$self->{template}" ;

if(exists $self->{feed_tag})
	{
	if	(
		$frame =~ s	{$self->{feed_tag}}
					{<a href="rss.xml">	 <img src="feed-icon-28x28.png"> </a>}xsm
		)
		{
		# replaced feed tag with feed
		}
	else
		{
		croak "Error: Couldn't find feed tag '$self->{feed_tag}' in template!\n" ;
		}
	}
 
if($frame =~ s/$self->{entries_tag}/$html_entries/xsm)
	{
	write_file("$temporary_directory/$self->{result_file}", $frame) ;
	}
else
	{
	croak "Error: Couldn't find entries tag '$self->{entries_tag}' in template!\n" ;
	}

return ;
}

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

package App::Plog::Feed::Atom ;

=head1 App::Plog::Feed::Atom SUBROUTINES/METHODS

=cut

use strict;
use warnings ;
use Carp qw(carp croak confess) ;
use File::Slurp ;
use XML::Atom::SimpleFeed;
use POSIX qw(strftime) ;

sub new
{

=head2 new(\%options)

I<Arguments>

=over 2 

=item * \%options - the B<feed> section from the blog configuration file

=back

I<Returns> - an App::Plog::Feed::Atom object

I<Exceptions> -None

=cut

my ($invocant, $options) = @_ ;

my $class = ref($invocant) || $invocant ;



( run in 2.184 seconds using v1.01-cache-2.11-cpan-df04353d9ac )