Nes
view release on metacpan or search on metacpan
share/examples/nesblog/en/items/Help.nhtml view on Meta::CPAN
<hr />
<h2><a name="configuration">CONFIGURATION</a></h2>
<p>Nes requires configuration of you cgi-bin and .htaccess for
directory of the Nes templates.</p>
<p>To active and configure Nes use utility: set_nes_site</p>
<p>
</p>
<h2><a name="configured_as_root">Configured as root</a></h2>
<p>Active Nes in /usr/lib/cgi-bin:</p>
<pre>
set_nes_site --cgi_dir=/usr/lib/cgi-bin</pre>
<p>Configure Nes for directory /var/www/myweb:</p>
<pre>
set_nes_site --dir_cfg=/var/www/myweb</pre>
<p>Configure Nes for all site:</p>
<pre>
set_nes_site --dir_cfg=/var/www</pre>
<p>Install hello world and test examples in /var/www/test_nes:</p>
<pre>
set_nes_site --from_exam=hello_nes --to_exam=/var/www/test_nes</pre>
<p>More help:</p>
<pre>
set_nes_site --help</pre>
<p>* Change /usr/lib/cgi-bin and /var/www for you particular path</p>
<p>
</p>
<h2><a name="configured_locally">Configured locally</a></h2>
<p>For configured Nes locally find you path to Nes.pm and add in
iprefix in cgi_dir and from_exam options.</p>
<p>Active Nes in /usr/lib/cgi-bin:</p>
<pre>
set_nes_site --cgi_dir=/usr/lib/cgi-bin --iprefix=/home/USER/path-to-Nes</pre>
<p>More help:</p>
<pre>
set_nes_site --help</pre>
<p>* Change /usr/lib/cgi-bin and /home/USER/path-to-Nes for you particular path</p>
<p>
</p>
<h2><a name="nes_templates__htaccess_configuration">Nes templates .htaccess configuration</a></h2>
<pre>
AddHandler perl-nes .nhtml
AddHandler perl-nes .nhtm
Action perl-nes /cgi-bin/nes/dispatch.cgi
<FilesMatch \.(nsql|nes.cfg)$>
order deny,allow
deny from all
</FilesMatch></pre>
<p>
</p>
<hr />
<h2><a name="_nes_cfg_configuration_files">.nes.cfg configuration files</a></h2>
<p>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.</p>
<p>private_key value that is used to encrypt data, if not changed the script
to launch a warning each time you run Nes.</p>
<p>
</p>
<h2><a name="_nes_cfg_variables">.nes.cfg variables</a></h2>
<pre>
tmp_dir # Temporary directory.
tmp_suffix # Suffix of the temporary files.
tmp_clear # If delete the 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.
# Plugins list separated by commas to load at startup only
# for the file in the URL, in all nhtml directory, eg.:
auto_load_plugin_top_first
# Plugins list separated by commas to load at startup to
# all files included in all nhtml directory, eg.:
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, eg.:
auto_load_plugin_top_last
# Plugins list separated by commas to load at end to
# all files included in all nhtml directory, eg.:
auto_load_plugin_all_last</pre>
<p>
</p>
<h2><a name="use_in_your_script">Use in your script</a></h2>
<p>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:</p>
<pre>
.nes.cfg
private_key = pass3
myscript_var1 = 50
myscript_var2 = 60
myscript_var3 = 70</pre>
<p>You can access these variables from the nhtml template as:</p>
<pre>
{: * cfg_myscript_var1 :}</pre>
<p>And from Perl:</p>
<pre>
use Nes;
my $nes = Nes::Singleton->new();
my $config = $nes->{'CFG'};
my $var1 = $config->{'myscript_var1'};</pre>
<p>
</p>
<h2><a name="perl_syntax_in_the_value">Perl syntax in the value</a></h2>
<p>In the predefined variables, Nes detects the data type automatically:</p>
<pre>
# Is scalar
tmp_dir = /tmp/nes</pre>
<pre>
# It is an array, separated by commas
auto_load_plugin_top_first = plugin1.pl, plugin1.pl</pre>
<p>If we define our own variables with a particular data type:</p>
<pre>
# Scalar, using Perl syntax in the value.
myscript_var1 $= 'scalar'</pre>
<pre>
# Hash
myscript_var2 %= ( 'name' => 'Jason', 'email' => 'jason\@example.com' )</pre>
<pre>
# Array
myscript_var3 @= ( 'one', 'two', 'three' )</pre>
<p>We may also use Perl syntax for variables in the predefined value,
taking care not to change the type:</p>
<pre>
# scalar
tmp_dir $= '/tmp/nes'</pre>
<pre>
# It is an array, ERROR
tmp_dir %= '/tmp/nes'</pre>
<pre>
# Array, separated by commas
auto_load_plugin_top_first = plugin1.pl, plugin2.pl</pre>
<pre>
# Array, Perl syntax
auto_load_plugin_top_first @= ( 'plugin1.pl', 'plugin2.pl' )</pre>
<p>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:</p>
<pre>
# we can not take as value a space like this:
myscript_var1 = ' ' <- error, value is the literal, including quotation
myscript_var1 = <- error, no value</pre>
<pre>
# to give as value a space can do so:
( run in 2.424 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )