App-Chronicle

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

The configuration file matches the command line arguments exactly, so given "--foo=bar" the configuration file would allow the same thing to be set via:

    foo = bar

As we've previously noted the blog-generation largely occurs via a series of plugins.  For example the sidebar might show the list of all tags, which can get unwieldy quickly.  If you wished to disable that you could do so via:

    chronicle --exclude-plugins=AllTags,RecentPosts --force ..

> **NOTE**: The plugins which generate output pages are located beneath the `Chronicle::Plugin::Generate` name-space.  The plugins which generate snippets available to all pages are located beneath the `Chronicle::Plugin::Snippets` name-space.

> **NOTE**: Because the snippets are included in every page, in the default themes, we've added `--force` to ensure that the output pages are updated.


User-Visible Changes
--------------------

In an ideal would you should be able to migrate from previous Chronicle releases directly to this codebase, as the purpose and main operation is identical:

* Blog entries are are still read from `data/`, unless you specify a different path via "`--input`".
* We still assume `*.txt` are the blog entries, unless you specify "`--pattern=*.blog`".
* Blog entries are still built up of a header and the entry.

bin/chronicle  view on Meta::CPAN


=head1 ABOUT

Chronicle is a blog-compiler which will convert a directory full of
plain-text blog-posts into a fully-featured HTML website containing
posts, tags, and archives.

All blog-posts from a given input directory are parsed into a SQLite
database which is then used to generate the output pages.

The SQLite database is assumed to persist, such that it will be updated
if new posts are written, or previous posts are updated.  However if
it is removed it will be recreated when needed.

=cut

=head1 DATABASE STRUCTURE

When C<chronicle> is first executed it will create an SQLite database
if it is not already present.  The database will contain two tables,
one for the posts, and one to store the tags associated with the posts,
if you choose to use tags in your entries.

lib/Chronicle/Config/Reader.pm  view on Meta::CPAN

    return $self;
}



=head2 parseFile

Parse a configuration file, and insert any values into the provided
hash-reference.

The two parameters required are a hash-reference, which will be updated
with the configuration-values, and the name of the configuration file
to parse.

If the file specified does not exist no action is taken.

Sample usage:

=for example begin

      $cfg->parse( \%config, "/etc/foo/config" );

lib/Chronicle/Config/Reader.pm  view on Meta::CPAN




=head2 parseLine

Parse a single line.

This method is called internally, but it is exposed in case it might
be useful to other callers.

The two parameters required are a hash-reference, which will be updated
with the configuration-values, and a line of configuration-file content
which should be parsed.

If the line is missing, or consistes entirely of a comment, this is
not a problem. (e.g. C<"# this is a comment"> will result in no update
to the hash-reference, but also raise no error.)

Sample usage:

=for example begin

lib/Chronicle/Plugin/Archived.pm  view on Meta::CPAN

our $VERSION = "5.1.7";


use Date::Format;
use Date::Parse;

=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

In this method we rewrite the link of the pending post such that it
is prefixed with the year and month - turning the link into a dated
one.

=cut

sub on_insert

lib/Chronicle/Plugin/Filter.pm  view on Meta::CPAN



use IPC::Open2;
use Symbol;


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

This plugin will look for a series of headers in the blog-post:

=over 8

=item pre-filter

This will be called first.

lib/Chronicle/Plugin/Filter.pm  view on Meta::CPAN

        #  Get the output
        #
        my $result = "";
        while (<$RDR>)
        {
            $result .= $_;
        }
        waitpid $pid, 0;

        #
        #  Store the updated body.
        #
        $data->{ 'body' } = $result;
    }

    #
    #  Return the updated post.
    #
    return ($data);
}


=head2 _order

We want this plugin to be called I<after> the other plugins which
filter new entries.

lib/Chronicle/Plugin/InPlacePosts.pm  view on Meta::CPAN

use strict;
use warnings;

our $VERSION = "5.1.7";


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog meta-data,
after performing any massaging required.  

If within the config has C<entry_inplace = 1> the posts link meta-data
is changed to reflect the users intent to retain the posts input location.

=cut

sub on_insert
{
    my ( $self, %args ) = (@_);

lib/Chronicle/Plugin/Markdown.pm  view on Meta::CPAN

use warnings;


our $VERSION = "5.1.7";


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

If the new entry has a C<format:> header which contains the value C<markdown>
we invoke the L<Text::Markdown> module to perform the HTML conversion.

=cut

sub on_insert
{

lib/Chronicle/Plugin/MultiMarkdown.pm  view on Meta::CPAN

use warnings;


our $VERSION = "5.1.7";


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

If the new entry has a C<format:> header which contains the value C<multimarkdown>
we invoke the L<Text::Multimarkdown> module to perform the HTML conversion.

=cut

sub on_insert
{

lib/Chronicle/Plugin/PostSpooler.pm  view on Meta::CPAN



use Date::Format;
use Date::Parse;


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

If the post we're being invoked upon does not contain a C<publish>
header then this plugin will do nothing.

If there is such a header the post will be ignored unless that header
is in the past - if the post refers to a future time it will be skipped.

=cut

lib/Chronicle/Plugin/SkipDrafts.pm  view on Meta::CPAN

use warnings;


our $VERSION = "5.1.7";


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

Here we look for a C<draft:1> header in the post, if one is found then
the method returns undef which causes it to be excluded from the blog
generation process.

=cut

sub on_insert

lib/Chronicle/Plugin/StaticPages.pm  view on Meta::CPAN

If your blog-post contains a "C<page: 1>" header then it will
treat the post as a non-blog static page.

You can manually specify the output path, via a header such as
C<output: about/index.html>.

This contains all the methods to handle the storing and generating of
non-blog pages.

* on_db_create: creates a table within the blog database to store the pages.
* on_insert: inserts new and updated pages.
* on_generate: generates the page.
=cut

=head1 METHODS

Now follows documentation on the available methods.

=cut

package Chronicle::Plugin::StaticPages;

lib/Chronicle/Plugin/Textile.pm  view on Meta::CPAN

use warnings;


our $VERSION = "5.1.7";


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

If the new entry has a C<format:> header which contains the value C<textile>
we invoke the L<Text::Textile> module to perform the HTML conversion.

=cut

sub on_insert
{

lib/Chronicle/Plugin/Tidy.pm  view on Meta::CPAN

use warnings;


our $VERSION = "5.1.7";


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

Here we walk the HTML entry, which might have been written by hand
or which might have been created via L<Chronicle::Plugin::Markdown>,
or some other plugin, and try to ensure it is well-formed.

=cut

sub on_insert

lib/Chronicle/Plugin/Tidy.pm  view on Meta::CPAN

            $node->delete();
        }
        else
        {
            $txt .= $node;
        }
    }
    $tree->delete();

    #
    #  Update the body and return the updated post.
    #
    $data->{ 'body' } = $txt;
    return ($data);
}


=head2 _order

We want this plugin to be called I<after> the other plugins which
filter new entries - so that we can fix their broken HTML.

lib/Chronicle/Plugin/TruncatedBody.pm  view on Meta::CPAN

use strict;
use warnings;

our $VERSION = "5.1.7";


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

If the new entry has a C<__CUT__> on its own line, the text before the
cut is marked as part of the truncated body and a link pointing the
reader to the rest of the article.

The body text is then cleaned by removing C<__CUT__>.

:B<NOTE> If there are multiple __CUT__'s within a file, only the first

lib/Chronicle/Plugin/YouTube.pm  view on Meta::CPAN

use warnings;


our $VERSION = "5.1.7";


=head2 on_insert

The C<on_insert> method is automatically invoked when a new blog post
must be inserted into the SQLite database, that might be because a post
is new, or because it has been updated.

The method is designed to return an updated blog-post structure,
after performing any massaging required.  If the method returns undef
then the post is not inserted.

This plugin will look for lines of the form:

=for example begin

    <youtube>$ID</youtube>

=for example end

lib/Chronicle/Plugin/YouTube.pm  view on Meta::CPAN

{
    my ( $self, %args ) = (@_);

    my $conf = $args{ 'config' };
    my $data = $args{ 'data' };

    # get the body
    my $old_body = $data->{ 'body' };
    my $new_body = "";

    my $updated = 0;

    # tokenize by line
    foreach my $line ( split( /[\r\n]/, $old_body ) )
    {
        while ( $line =~ /^(.*)<youtube>([^<]+)<\/youtube>(.*)$/i )
        {
            my $pre  = $1;
            my $vid  = $2;
            my $post = $3;

            $line = $1;
            $line .= <<EOF;
<iframe src="http://www.youtube.com/embed/$vid" width="560" height="315" frameborder="0" allowfullscreen></iframe>
EOF
            $line .= $3;

            $updated += 1;
        }

        $new_body .= $line . "\n";
    }

    if ($updated)
    {
        $data->{ 'body' } = $new_body;

        if ( $data->{ 'tags' } )
        {
            $data->{ 'tags' } .= ",youtube";
        }
        else
        {
            $data->{ 'tags' } .= "youtube";
        }
    }

    #
    #  Return the updated post.
    #
    return ($data);
}


1;


=head1 LICENSE

t/test-archive-links.t  view on Meta::CPAN

#
foreach my $key (qw! body date title !)
{
    is( $out->{ $key }, $data{ $key }, "The blog field is unchanged $key" );
}


#
#  But the link should have done
#
isnt( $out->{ 'link' }->as_string, $link, "The link is updated" );


#
#  We should expect NNNN/MM/$title
#
my $YEAR = substr( $data{ 'link' }->as_string, 0, 4 );
my $MON  = substr( $data{ 'link' }->as_string, 5, 2 );

#
#  Test they're numeric.

t/test-config-reader.t  view on Meta::CPAN

is( $VARS{ 'steve' }, "kemp", "Setting a single key works" );


#
#  Unsetting a previously set value.
#
is( $VARS{ 'foo' }, "bar", "Initial value is OK" );
$c->parseLine( \%VARS, "foo =" );
is( $VARS{ 'foo' }, "", "The value has been removed" );
$c->parseLine( \%VARS, "foo = meow" );
is( $VARS{ 'foo' }, "meow", "The value has been updated" );

#
#  Expand ENV
#
SKIP:
{
    skip "No USER environment setup", 1 unless ( $ENV{ 'USER' } );

    $c->parseLine( \%VARS, 'user = $USER' );
    is( $VARS{ 'user' }, $ENV{ 'USER' }, "Environmental variable updated" );
}

#
#  Test for command.
#
SKIP:
{
    skip "No /bin/ls", 2 unless ( -x "/bin/ls" );

    $c->parseLine( \%VARS, 'ls = `/bin/ls /bin/ls`' );



( run in 0.475 second using v1.01-cache-2.11-cpan-05444aca049 )