CGI-Application-Plugin-Nes

 view release on metacpan or  search on metacpan

lib/CGI/Application/Plugin/Nes.pm  view on Meta::CPAN

Plugin for use L<Nes> templates in L<CGI::Application>. You can use any Nes 
object or plugin in CGI::Application.

Include Nes Templates, PHP, PYTHON and others live sample: 

  L<http://nes.sourceforge.net/hello_nes/tests-cgiapp/index.cgi?action=Inludes>

Include Nes Objects live sample: 

  L<http://nes.sourceforge.net/hello_nes/tests-cgiapp/index.cgi?action=Objects>

Nes Tags and Debug Info live sample: 

  L<http://nes.sourceforge.net/hello_nes/tests-cgiapp/index.cgi?action=others>

=head1 INPLEMENTATION

In your .pm file instead of:

  use base 'CGI::Application'; 

used:

  use base 'CGI::Application::Plugin::Nes';

In addition to your myapp.cgi file, creates a nhtml file with the same name
for the Top Nes template:

myapp.cgi:

  use MyApp;
  my $app = MyApp->new();
  $app->run();
  1; # in Nes cgi should return 1 as the pm files.

myapp.nhtml:

  {: NES 1.0 ('myapp.cgi') :}
  <html>
    <head>
    ...

If you run your application by the CGI, you need to put the following
variable the full path to Nes cgi-bin directory in your .pm or .cgi file:

  $ENV{CGI_APP_NES_DIR} = '/full/path/to/cgi-bin/nes';

This is necessary for:

  http://example.com/myapp.cgi

It is not necessary for:

  http://example.com/myapp.nhtml

For compatibility with CGI.pm:

  $ENV{CGI_APP_NES_BY_CGI} = 1;

It's a bit slower than letting to Nes handle the query. 
Not support for upload.

=head1 Compare

See L<http://cgi-app.org/index.cgi?LoginLogoutExampleApp>

Code in CGI::Application::Plugin::Nes for a similar result:

  package MinimalAppNes;
  use base 'CGI::Application::Plugin::Nes';
  use strict;

  # require if exec by .cgi
  # $ENV{CGI_APP_NES_DIR} = '/full/path/to/cgi-bin/nes';

  sub setup {
      my $self = shift;
      $self->start_mode('index');
      $self->mode_param('action');
      $self->run_modes(
          'index'  => 'index',
          'logout' => 'logout',
      );
  }

  sub index {
      my $self = shift;
      # only three lines of Perl script is necessary for generate form login
      my %nes_tags;
      $nes_tags{'action'} = 'login.nhtml';
      Nes::Singleton->instance->out(%nes_tags);
  }

  sub logout {
      my $self = shift;
      my %nes_tags;
      $nes_tags{'action'} = 'logout.nhtml';
      Nes::Singleton->instance->out(%nes_tags);
  }


In the instalation package see share/examples/compare directory

=head1 BUGS



=head1 TODO



=head1 AUTHOR

Skriptke: Enrique Castañón

=head1 VERSION

Version 0.01

=head1 COPYRIGHT



( run in 1.032 second using v1.01-cache-2.11-cpan-b16cb0d3907 )