App-ZofCMS

 view release on metacpan or  search on metacpan

bin/zofcms_helper  view on Meta::CPAN


    if ( -e $core_mod_file and not $do_overwrite ) {
        print "$core_mod_file already exists. Use `--overwrite_existing_plugins` option to overwrite\n";
    }
    else {
        copy $INC{$mod_file}, $core_mod_file
            or print "ERROR: failed to copy $mod [$!]";
    }
}

sub make_index_pl {
    my $core = '../' . shift;
    if ( substr($core, -1) eq '/' ) {
        $core = substr $core, 0, -1;
    }
    my $code = <<'END_CODE';
#!/usr/bin/env perl

use strict;
use warnings;

use lib qw([{LIB}] [{LIB}]/CPAN);
use App::ZofCMS::Config;
use App::ZofCMS::Template;
use App::ZofCMS::Output;

use CGI::Carp qw/fatalsToBrowser/;

my $config = App::ZofCMS::Config->new;

my $conf = $config->load( '[{CONFIG}]' );

my $template;

RELOADS: {
    $template = App::ZofCMS::Template->new( $config );

    $template->load;
    $template->prepare_defaults;
    $template->execute_before;
    $template->assemble;
    $template->execute
        or redo RELOADS;
}

my $output = App::ZofCMS::Output->new( $config, $template );
print $output->headers;
print $output->output;
exit;
END_CODE

    $code =~ s/\Q[{LIB}]/$core/g;
    $code =~ s|\Q[{CONFIG}]|${core}/config.txt|;
    return $code;
}

sub make_base {
    return <<'END_HTML';
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><tmpl_var name="title"></title>

<link rel="stylesheet" type="text/css" href="/main.css" media="screen,tv,projection">
<link rel="stylesheet" type="text/css" href="/print.css" media="print">

<!--[if IE]>
    <link rel="stylesheet" type="text/css" href="/ie.css" media="screen,tv,projection">
<![endif]-->

<div id="main">
    <tmpl_var name="body">
</div>
END_HTML
}

sub make_index_tmpl {
    return <<'END_CODE';
use strict;
use warnings;

{
    body => \'index.tmpl',
    title => '',
}
END_CODE
}

sub make_index_html_tmpl {
    return 'Fill me up!'
}

sub make_404 {
    return <<'END_CODE';
{
    body => \'404.tmpl',
    title => '404 - Page Not Found',
}
END_CODE
}

sub make_config_file {
    my $core_dir = shift;
    return <<"END_CONFIG";
use strict;
use warnings;

{
    valid_pages => {
        dirs => [
            '/'
        ],
    },
    data_store => '../$core_dir/data',
    templates    => '../$core_dir/templates',
    template_defaults => {
        conf => {
            base => 'base.tmpl',
        },
    },
}



( run in 0.921 second using v1.01-cache-2.11-cpan-6aa56a78535 )