App-Plog

 view release on metacpan or  search on metacpan

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

=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 ;
confess 'Invalid constructor call!' unless defined $class ;

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

return bless $object, $class ;
}

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

sub generate
{

=head2 generate($self, $entries, $blog_directory, $temporary_directory)

$temporary_directory/rss.xml


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> - None

=cut

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

my $page = $self->{page} ;
my $now_string = strftime '%Y-%m-%dT%H:%M:%SZ',  localtime() ; 

my $xml_atom_feed = XML::Atom::SimpleFeed->new
			(
			id => 0,
			title   => 'Plog Feed',
			link      => $page, 
			updated => $now_string ,
			author  => 'App::Plog',
			) ;

while(my ($name, $entry) = each %{$entries})
	{
	my $entry_date_string = $entry->[0]{date} ;
	$entry_date_string  =~ s/^\s*(\d+-\d+-\d+)\s*/$1T/xsm ;
	$entry_date_string =~ s/(\d+:\d+:\d+).*/$1Z/xsm ;
	
	$xml_atom_feed->add_entry
		(
		title     => $name, #
		link      => "$page#$entry->[-1]{commit}", 
		id        => $entry->[-1]{commit},
		updated   => $entry_date_string ,
		#~ summary   => 'Summary',
		) ;
	}

write_file("$temporary_directory/rss.xml", $xml_atom_feed->as_string()) ;

return ;
}

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

1 ;

=head1 BUGS AND LIMITATIONS

None so far.

=head1 AUTHOR

	Nadim ibn hamouda el Khemir
	CPAN ID: NKH
	mailto: nadim@cpan.org

=head1 COPYRIGHT & LICENSE

Copyright 2009 Nadim Khemir.

This program is free software; you can redistribute it and/or
modify it under the terms of either:

=over 4

=item * the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or

=item * the Artistic License version 2.0.

=back

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc App::Plog

You can also look for information at:

=over 4

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/App-Plog>

=item * RT: CPAN's request tracker

Please report any bugs or feature requests to  L <bug-app-plog@rt.cpan.org>.

We will be notified, and then you'll automatically be notified of progress on
your bug as we make changes.



( run in 2.718 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )