App-Chronicle
view release on metacpan or search on metacpan
bin/chronicle view on Meta::CPAN
--entry-count=N Number of posts to show on the index.
--rss-count=N Number of posts to include on the RSS index feed.
Optional Features:
--author Specify the author's email address.
--blog-subtitle Set the title of the blog.
--blog-title Set the title of the blog.
--force Always regenerate pages.
--lower-case Write only lower-case post-files.
--unicode=<yes|no|mac>
Allow non-ASCII characters in file names. Default is
`no'. Use `mac' if serving files off an HFS+ volume.
Help Options:
--help Show the help information for this script.
--list-plugins List the available plugins.
--list-themes List the available themes.
--manual Read the manual for this script.
--verbose Show useful debugging information.
bin/chronicle view on Meta::CPAN
$CONFIG{ 'input' } = "./data";
$CONFIG{ 'pattern' } = "*.txt";
$CONFIG{ 'output' } = "./output";
$CONFIG{ 'database' } = "./blog.db";
$CONFIG{ 'comment-days' } = 10;
$CONFIG{ 'entry-count' } = 10;
$CONFIG{ 'rss-count' } = 10;
$CONFIG{ 'theme-dir' } = File::ShareDir::dist_dir('App-Chronicle');
$CONFIG{ 'theme' } = "default";
$CONFIG{ 'unicode' } = "no";
$CONFIG{ 'verbose' } = 0;
$CONFIG{ 'top' } = "/";
$CONFIG{ 'exclude-plugins' } =
"Chronicle::Plugin::Archived,Chronicle::Plugin::Verbose";
$CONFIG{ 'template-engine' } = "HTMLTemplate";
our %DATABASE_SCHEMA = (
blog => {
columns =>
[qw/ id file date title link mtime body truncatedbody template /],
bin/chronicle view on Meta::CPAN
#
# If we have a configuration file then read it.
#
$cnf->parseFile( \%CONFIG, $CONFIG{ 'config' } )
if ( defined $CONFIG{ 'config' } );
#
# Switch on Mac quirks for Unicode file names if required
#
Chronicle::URI::i_use_hfs if $CONFIG{ 'unicode' } eq 'mac';
#
# If Unicode is on, also keep HTML::Element from encoding non-ASCII as entities
#
if ( $CONFIG{ 'unicode' } ne 'no' )
{
$HTML::Element::encoded_content = 1;
}
#
# Get the database handle, creating the database on-disk if necessary.
#
my $dbh = getDatabase();
bin/chronicle view on Meta::CPAN
$meta{ 'truncatedbody' } = '';
# initiate the template and change if there is a template is supplied.
$meta{ 'template' } = "entry.tmpl" unless defined $meta{ 'template' };
#
# Generate the link from the title of the post.
#
my $suffix = $CONFIG{ 'entry_suffix' } // ".html";
my $link = $meta{ 'title' };
if ( $CONFIG{ 'unicode' } eq 'no' )
{
# Unicode off, only use 7-bit alphanumerics from titles
$link =~ s/[^a-zA-Z0-9]/_/gi;
}
else
{
# Allow everything alphanumeric in any Unicode block
$link =~ s/[^[:alnum:]]/_/gi;
}
$meta{ 'link' } = Chronicle::URI->new( $link . $suffix );
bin/chronicle view on Meta::CPAN
=cut
sub get_database_handle
{
my ($filename) = (@_);
my $dbh =
DBI->connect( "dbi:SQLite:dbname=$filename", "", "",
{ AutoCommit => 1, RaiseError => 0 } ) or
die "Could not open SQLite database: $DBI::errstr";
$dbh->{ sqlite_unicode } = 1;
return $dbh;
}
=begin doc
Create a database handle, if necessary creating the tables first.
=end doc
=cut
bin/chronicle view on Meta::CPAN
# limits
"entry-count=s", \$CONFIG{ 'entry-count' },
"rss-count=s", \$CONFIG{ 'rss-count' },
# optional
"config=s", \$CONFIG{ 'config' },
"database=s", \$CONFIG{ 'database' },
"author=s", \$CONFIG{ 'author' },
"comment-days=s", \$CONFIG{ 'comment-days' },
"force", \$CONFIG{ 'force' },
"unicode=s", \$CONFIG{ 'unicode' },
"lower-case", \$CONFIG{ 'lower-case' },
# plugins
"list-plugins", \$CONFIG{ 'list-plugins' },
"exclude-plugins=s", \$CONFIG{ 'exclude-plugins' },
# title
"blog-title=s", \$CONFIG{ 'blog_title' },
"blog-subtitle=s", \$CONFIG{ 'blog_subtitle' },
bin/chronicle view on Meta::CPAN
if ( $plugin->can($method) )
{
print "\t$method\n";
}
}
}
}
exit 0;
}
# Show an error if 'unicode' is not an allowed value
$CONFIG{ 'unicode' } = lc $CONFIG{ 'unicode' };
unless ( grep {$_ eq $CONFIG{ 'unicode' }} qw/ no yes mac / )
{
print STDERR "--unicode must be one of `yes', `no' or `mac'";
exit 1;
}
}
=begin doc
Return an array of plugins that implement the given method.
( run in 0.466 second using v1.01-cache-2.11-cpan-88abd93f124 )