Enrique F. Castañón > Nes-1.03.4_1 > Nes::nes.cfg

Download:
Nes-1.03.4_1.tar.gz

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Source  

NAME ^

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

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 :}

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.

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

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'};

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 $= ' ' 

    # Array, the name includes a comma
    auto_load_plugin_top_first = plugin,1.pl, plugin,2.pl <- error

    # Array, Perl syntax the name includes a comma
    auto_load_plugin_top_first @= ( 'plugin,1.pl', 'plugin,2.pl' )

Each variable can only occupy one line.

AUTHOR ^

Skriptke: Enrique F. Castanon

VERSION ^

Version 1.04

COPYRIGHT ^

Copyright (c) Enrique F. Castanon Barbero. All rights reserved.

LICENSE ^

This program is free software; you can redistribute it and/or modify it under the same terms and conditions as GNU Public License (GPL).

This means that you can, at your option, redistribute it and/or modify it under either the terms the GNU Public License (GPL), or under the Perl Artistic License.

See http://dev.perl.org/licenses/

DISCLAIMER ^

THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Use of this software in any way or in any form, source or binary, is not allowed in any country which prohibits disclaimers of any implied warranties of merchantability or fitness for a particular purpose or any disclaimers of a similar nature.

IN NO EVENT SHALL I BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION (INCLUDING, BUT NOT LIMITED TO, LOST PROFITS) EVEN IF I HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

SEE ALSO ^

Sample to use Nes; http://nes.sourceforge.net/ Nes, Nes::Tutorial, Nes::Singleton

syntax highlighting: