App-ZofCMS

 view release on metacpan or  search on metacpan

bin/zofcms_helper  view on Meta::CPAN

        }
        else {
            my $fh_data;
            unless ( open $fh_data, '>', $data ) {
                warn "Failed to open $data [$!]\n";
            }
            else {
                close $fh_data;
            }
        }

        if ( -e $template ) {
            print "$template file exists, omitting...\n";
        }
        else {
            my $fh_template;
            unless ( open $fh_template, '>', $template ) {
                warn "Failed to open $template [$!]\n";
            }
            else {
                my $body_file = File::Spec->catfile( @dirs );
                my $title = join ' - ', map do { s/-(.)/ \u$1/g; $_ },
                    map ucfirst, grep length, reverse split m{/}, $page;

                print $fh_template <<"END";
use strict;
use warnings;

{
    body => \\'$body_file',
    title => '$title',
    plugins => [
    ],
};

__END__
END
                close $fh_template;
            }
        }
    }
}

exit
    if $opts{nocore};

@opts{ qw/index base index_tmpl index_html_tmpl 404  config_file/ } = (
    File::Spec->catfile( $opts{site}, 'index.pl' ),
    File::Spec->catfile( $opts{core}, 'data', 'base.tmpl' ),
    File::Spec->catfile( $opts{core}, 'templates', 'index.tmpl' ),
    File::Spec->catfile( $opts{core}, 'data', 'index.tmpl' ),
    File::Spec->catfile( $opts{core}, 'templates', '404.tmpl' ),
    File::Spec->catfile( $opts{core}, 'config.txt' ),
);

open my $fh, '>', $opts{index}
    or die "Failed to open/create $opts{index} [$!]";

print $fh make_index_pl( $opts{core} );
close $fh;
chmod 0755, $opts{index};

open $fh, '>', $opts{base}
    or die "Failed to open/create $opts{base} [$!]";

print $fh make_base();

open $fh, '>', $opts{index_tmpl}
    or die "Failed to open/create $opts{index_tmpl} [$!]";

print $fh make_index_tmpl();


open $fh, '>', $opts{index_html_tmpl}
    or die "Failed to open/create $opts{index_html_tmpl} [$!]";

print $fh make_index_html_tmpl();


open $fh, '>', $opts{404}
    or die "Failed to open/create $opts{404} [$!]";

print $fh make_404();


open $fh, '>', $opts{config_file}
    or die "Failed to open/create $opts{config_file} [$!]";

print $fh make_config_file( $opts{core} );


copy_module( $_, $opts{core} )
    for qw/
        App::ZofCMS::Config
        App::ZofCMS::Template
        App::ZofCMS::Output
    /;

sub show_plugins {
    my ( $core, $site ) = @_;

    find(\&show_plugins_plugin_found, File::Spec->catdir($core, 'templates') );

    if ( my $t = do File::Spec->catfile( $core, 'config.txt' ) ) {
        for my $key ( grep /^plugins\d*/, keys %$t ) {
            ref $t->{$key} eq 'ARRAY'
                or next;

            for ( @{ $t->{$key} || [] } ) {
                if ( ref $_ eq 'HASH' ) {
                    $Show_Plugins{ (keys %$_)[0] } = 1;
                    next;
                }
                $Show_Plugins{ $_ } = 1;
            }
        }

        for my $key ( grep /^plugins\d*/, keys %{ $t->{template_defaults} } ) {
            ref $t->{template_defaults}{$key} eq 'ARRAY'
                or next;



( run in 0.882 second using v1.01-cache-2.11-cpan-39bf76dae61 )