| 1 | package CGI::Application::Demo::Basic::Two; | ||
| 2 | |||
| 3 | # Documentation: | ||
| 4 | # POD-style documentation is at the end. Extract it with pod2html.*. | ||
| 5 | # | ||
| 6 | # Note: | ||
| 7 | # o tab = 4 spaces || die | ||
| 8 | # | ||
| 9 | # Author: | ||
| 10 | # Ron Savage <ron@savage.net.au> | ||
| 11 | # http://savage.net.au/index.html | ||
| 12 | |||
| 13 | use base 'CGI::Application'; | ||
| 14 | use strict; | ||
| 15 | use warnings; | ||
| 16 | |||
| 17 | require 5.005_62; | ||
| 18 | |||
| 19 | use CGI::Simple; | ||
| 20 | |||
| 21 | our $VERSION = '1.06'; | ||
| 22 | |||
| 23 | # ----------------------------------------------- | ||
| 24 | |||
| 25 | sub cgiapp_get_query | ||
| 26 | { | ||
| 27 | my($self) = @_; | ||
| 28 | |||
| 29 | return CGI::Simple -> new; | ||
| 30 | |||
| 31 | } # End of cgiapp_get_query. | ||
| 32 | |||
| 33 | # ----------------------------------------------- | ||
| 34 | |||
| 35 | sub cgiapp_init | ||
| 36 | { | ||
| 37 | my($self) = @_; | ||
| 38 | |||
| 39 | # Warning: When running a CGI script from the command line, omit the 'nfs/' everywhere. | ||
| 40 | |||
| 41 | $self -> param(tmpl_name => 'two.tmpl'); | ||
| 42 | $self -> param(tmpl_path => '/var/www/assets/templates/CGI/Application/Demo/Basic'); | ||
| 43 | |||
| 44 | } # End of cgiapp_init. | ||
| 45 | |||
| 46 | # ----------------------------------------------- | ||
| 47 | |||
| 48 | sub setup | ||
| 49 | { | ||
| 50 | my($self) = @_; | ||
| 51 | |||
| 52 | $self -> run_modes(start => \&start); | ||
| 53 | $self -> tmpl_path($self -> param('tmpl_path') ); | ||
| 54 | |||
| 55 | } # End of setup. | ||
| 56 | |||
| 57 | # ----------------------------------------------- | ||
| 58 | |||
| 59 | sub start | ||
| 60 | { | ||
| 61 | my($self) = shift; | ||
| 62 | my($template) = $self -> load_tmpl($self -> param('tmpl_name') ); | ||
| 63 | my(@content) = | ||
| 64 | ( | ||
| 65 | 'Time: ' . scalar localtime, | ||
| 66 | 'URL: ' . $self -> query -> url, | ||
| 67 | 'PathInfo: ' . $self -> query -> path_info, | ||
| 68 | "CGI::Simple V $CGI::Simple::VERSION", | ||
| 69 | 'Template name: ' . $self -> param('tmpl_name'), | ||
| 70 | 'Template path: ' . $self -> param('tmpl_path'), | ||
| 71 | ); | ||
| 72 | |||
| 73 | $template -> param(li_loop => [map{ {item => $_} } @content]); | ||
| 74 | $template -> param(title => __PACKAGE__); | ||
| 75 | |||
| 76 | return $template -> output; | ||
| 77 | |||
| 78 | } # End of start. | ||
| 79 | |||
| 80 | # ----------------------------------------------- | ||
| 81 | |||
| 82 | 1; |