App-PFT
view release on metacpan or search on metacpan
bin/pft-init view on Meta::CPAN
use strict;
use warnings;
use utf8;
use v5.16;
use feature 'say';
use PFT::Conf;
use PFT::Tree;
use PFT::Header;
use Encode;
use Encode::Locale;
use File::Spec;
use File::Copy;
use File::ShareDir;
use File::Basename qw/basename/;
use Cwd;
use Getopt::Long;
Getopt::Long::Configure qw/bundling/;
use Pod::Usage;
use App::PFT;
my %opts = (home => 1);
GetOptions(
PFT::Conf::wire_getopt(\my %conf_opts),
'help|h!' => sub {
pod2usage
-exitval => 0,
-verbose => 2,
-input => App::PFT::help_of 'init',
},
) or exit 1;
if (my $root = PFT::Conf::locate) {
say STDERR 'Configuration exists: ', $root;
exit 1;
}
my $conf = PFT::Conf->new_getopt(\%conf_opts);
$conf->save_to(my $root = Cwd::cwd);
my $tree = PFT::Tree->new($root, {create => 1});
my $home = $tree->content->new_entry(PFT::Header->new(
title => $conf->{site}{home},
author => $conf->{site}{author},
));
$home->open('a') unless $home->exists;
my $glob = File::Spec->catdir(
File::ShareDir::module_dir('App::PFT'),
'templates',
'*',
);
foreach (glob encode(locale_fs => $glob)) {
my $outfn = File::Spec->catfile(
encode(locale_fs => $tree->dir_templates),
basename($_)
);
open my $in, '< :encoding(UTF-8)', $_ or do {
say STDERR 'Cannot open ', decode(locale_fs => $_), ": $!";
exit 1;
};
open my $out, '> :encoding(locale_fs)', $outfn or do {
say STDERR 'Cannot open ', decode(locale_fs => $outfn), ": $!";
exit 1;
};
print $out (<$in>);
close $in;
close $out;
};
=head1 CONFIGURATION OPTIONS
=over
=item B<--publish-host>=I<HOST>
Remote host where to publish (see L<pft-pub(1)>).
Defaults to C<example.org>.
=item B<--publish-method>=I<NAME>
Method used for publishing (see L<pft-pub(1)>).
Defaults to C<rsync+ssh>.
=item B<--publish-path>=I<PATH>
Remote path on publishing host (see L<pft-pub(1)>).
Defaults to C</home/$USER/public_html>, as by tradition.
=item B<--publish-port>=I<PORT>
Port for connection on publishing host (see L<pft-pub(1)>).
Defaults to C<22>.
=item B<--publish-user>=I<USER>
User login on publishing host (see L<pft-pub(1)>).
Defaults to $USER (environment variable).
=item B<--site-author>=I<USER>
Global Author, can be overriden by individual entries.
Defaults to C<$USER> (environment variable).
=item B<--site-encoding>=I<ENC>
Charset of the generated web pages.
Defaults to what is defined by L<locale(1)>.
=item B<--site-feed-description>=I<DESC>
Description of the channel (C<E<lt>descriptionE<gt>> in the XML).
Defaults to C<News from a PFT website>.
=item B<--site-feed-length>=I<N>
Number of most recent blog entries to list in the RSS feed.
Defaults to C<10>.
=item B<--site-feed-path>=I<PATH>
File name of the RSS XML to be published by L<pft-gen-rss(1)>.
Defaults to C<feed.rss>.
=item B<--site-home>=I<PAGE_NAME>
First page, where C<index.html> will redirect the browsers.
Defaults to C<Welcome>.
=item B<--site-template>=I<TEMPLATE>
Global HTML template, can be overriden by individual entires.
Defaults to C<default.html>.
=item B<--site-theme>=I<THEME>
Global theme (e.g. C<light> or C<dark>) optionally honored by templates. Specific accepted values depend on the template implementation.
Defaults to C<light>.
=item B<--site-title>=I<TITLE>
Title of the website.
Defaults to C<My PFT website>.
=item B<--site-url>=I<URL>
Base url for the website.
Defaults to C<http://example.org>.
=item B<--system-browser>=I<BROWSER>
Browser to be invoked by B<pft-show(1)>. You may specify an executable, or a L<sh(1)> command where "%s" gets replaced with the file name (e.g. "firefox -profile x '%s'").
Defaults to C<$BROWSER> (environment variable), or C<firefox> if not defined.
=item B<--system-editor>=I<EDITOR>
Editor to be invoked by L<pft-edit(1)>. You may specify an executable, or a L<sh(1)> command where "%s" gets replaced with the file name (e.g. "vim +'set filetype=markdown spell' %s").
Defaults to C<$EDITOR> (environment variable), or C<vi> if not defined.
=back
# END AUTOGEN
=head1 ENVIRONMENT
The following environment variables are honored as sensible defaults unless
some different setting is supplied by command line arguments.
( run in 0.541 second using v1.01-cache-2.11-cpan-ceb78f64989 )