Nes

 view release on metacpan or  search on metacpan

lib/Nes/nes.cfg.pod  view on Meta::CPAN


=head1 NAME

Nes::nes.cfg - .nes.cfg Nes configuration files.

=head1 SYNOPSIS

    use Nes;
    my $nes    = Nes::Singleton->new('template.nhtml');
    my $config = $nes->{'CFG'};

    my $var1   = $config->{'myscript_var1'};
    my $objdir = $config->{'obj_top_dir'};

Access by template:

    {: * cfg_myscript_var1 :}
    {: * cfg_obj_top_dir :}

=head1 DESCRIPTION

The .nes.cfg is placed in the directory where you installed your 
nhtml templates, it overwrites Setting and the plugins configuration.
Level rises, until the root directory of the Web, to read .nes.cfg files.  

private_key value that is used to encrypt data, if not changed the script
to launch a warning each time you run Nes.

=head1 Variables

    tmp_dir        # Temporary directory.
    tmp_suffix     # Suffix of the temporary files. 
    tmp_clear      # Delete temporary files or 0 and does not delete
                   # time suffix: s: seconds,
                   # m: minutes h: hours d: days, M: months, y: years
                   # 24h is 24 hours. 
    top_dir        # Root directory of your site.
    nes_dir        # Directory of Nes.
    nes_top_dir    # Absolute path to the Nes directory.
    plugin_dir     # Directory of the Plugin, top_dir relative.
    obj_dir        # Directory of the Object, top_dir relative.
    plugin_top_dir # Absolute path to the Plugin directory.
    obj_top_dir    # Absolute path to the Object directory.
    time_zone      # *** unimplemented ***
    locale         # locale, ej.: es_ES.utf8
    session_prefix # Name cookie used for user session.
    private_key    # Private key used to encrypt data.
    DB_base        # Database name.
    DB_user        # Database user.
    DB_pass        # Database password.
    DB_driver      # Database driver, default 'mysql' 
    DB_host        # Database host, default 'localhost'
    DB_port        # Database port, default '3306' 
    php_cline      # Command line for PHP CLI
    php_cgi_cline  # Command line for PHP CGI
    perl_cline     # Command line for Perl
    shell_cline    # Command line for Shell
    python_cline   # Command line for Python
    max_post       # Max kB. maximum size of POST.
    max_upload     # Max kB. maximum size of the upload, 0 none
    tmp_upload     # In big upload, memory consumption is high,
                   # this defined from that kB. using a temporary
                   # file in the upload, preventing these are 
                   # loaded into memory. 
                   # * If tmp_upload is 0 or is greater than max_post, 
                   # max_upload limit will be equal to max_post. Therefore, 
                   # max_upload to take value, tmp_upload to be equal to or 
                   # less than max_post.

    # Plugins list separated by commas to load at startup only
    # for the file in the URL, in all nhtml directory.
    auto_load_plugin_top_first

    # Plugins list separated by commas to load at startup to
    # all files included in all nhtml directory.
    auto_load_plugin_all_first

    # Plugins list separated by commas to load at end only
    # for the file in the URL, in all nhtml directory.
    auto_load_plugin_top_last

    # Plugins list separated by commas to load at end to
    # all files included in all nhtml directory.
    auto_load_plugin_all_last

=head1 Use in your script

You can use .nes.cfg to add configuration variables to your script. We 
recommend using a notation that clearly distinguishes Nes variables, 
for example using prefixes the name of your application, 
.nes.cfg content:
    
    private_key   = pass
    myscript_var1 = 50

You can access these variables from the nhtml template as:

    {: * cfg_myscript_var1 :}

And from Perl:

    use Nes;
    my $nes    = Nes::Singleton->new();
    my $config = $nes->{'CFG'};
    my $var1   = $config->{'myscript_var1'};

=head1 Perl syntax in the value

In the predefined variables, Nes detects the data type automatically:

    # Is scalar
    tmp_dir = /tmp/nes

    # It is an array, separated by commas
    auto_load_plugin_top_first = plugin1.pl, plugin1.pl

If we define our own variables with a particular data type:

    # Scalar, using Perl syntax in the value.
    myscript_var1 $= 'scalar'

    # Hash
    myscript_var2 %= ( 'name' => 'Jason', 'email' => 'jason\@example.com' )

    # Array
    myscript_var3 @= ( 'one', 'two', 'three' )

We may also use Perl syntax for variables in the predefined value,
taking care not to change the type:

    # scalar
    tmp_dir $= '/tmp/nes'

    # It is an array, ERROR
    tmp_dir %= '/tmp/nes'

    # Array, separated by commas
    auto_load_plugin_top_first = plugin1.pl, plugin2.pl

    # Array, Perl syntax
    auto_load_plugin_top_first @= ( 'plugin1.pl', 'plugin2.pl' )

In the predefined variables are all scalar except those allowed 
are comma-separated arrays. If we arrays can be useful if one 
of the values has a coma, or the scalar to define a space:

    # we can not take as value a space like this:
    myscript_var1 = ' '  <- error, value is the literal, including quotation 
    myscript_var1 =      <- error, no value

    # to give as value a space can do so:
    myscript_var1 $= ' ' 



( run in 1.050 second using v1.01-cache-2.11-cpan-98e64b0badf )