Audbyte/Scratch notes: Difference between revisions
From Federal Burro of Information
< Audbyte
No edit summary |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Create project == | |||
catalyst.pl Audbyte | catalyst.pl Audbyte | ||
Line 23: | Line 24: | ||
BING | BING | ||
== Template == | |||
cd /home/dthornton/tmp/Audbyte | |||
./script/audbyte_create.pl view HTML TT | |||
Creates new file: lib/Hello/View/HTML.pm which is of class Catalyst::View::TT. | |||
This scripts take aruguments: | |||
# is this a model a view or a controller you are creating? In this case we are creating a view | |||
# what is the name of the view , in this case the NAME of the view is "HTML", later we might create a view called "mobile" for example. | |||
# the last argument is the TYPE of view, in this case TT means Template Tookkit, which is a templating system that catalyst plays well with. We needed to have the perl module Template and the catalyst helper Catalyst::Helper::View::TT installed for this to work. | |||
Create the template: root/hello.tt | |||
<p> | |||
This is a TT view template, called '[% template.name %]'. | |||
</p> | |||
then in Root.pm change: | |||
sub hello :Global { | |||
my ( $self, $c ) = @_; | |||
$c->response->body("Hello, World!"); | |||
} | |||
to: | |||
sub hello :Global { | |||
my ( $self, $c ) = @_; | |||
$c->stash(template => 'hello.tt'); | |||
} | |||
== creating a new controller Tracks == | |||
./script/myapp_create.pl controller Tracks | |||
== updating Makefile.PL == | |||
added to Makefile.PL | |||
requires 'Catalyst::Plugin::StackTrace'; | |||
requires 'Catalyst::Helper::View::TT'; |
Latest revision as of 04:04, 30 May 2013
Create project
catalyst.pl Audbyte <snip> cd Audbyte/ script/audbyte_server.pl -r <snip>
surf to http://testsrv.opensitesolutions.com:3000/
vi ./lib/Audbyte/Controller/Root.pm
For example, the URL http://hello.com/admin/articles/create maps to the package Hello::Controller::Admin::Articles, and the create method.
Adding a subroutine:
sub hello :Global { my ( $self, $c ) = @_;
$c->response->body("Hello, World!"); }
code reloads on it's own, now surf to: http://testsrv.opensitesolutions.com:3000/hello
BING
Template
cd /home/dthornton/tmp/Audbyte ./script/audbyte_create.pl view HTML TT
Creates new file: lib/Hello/View/HTML.pm which is of class Catalyst::View::TT.
This scripts take aruguments:
- is this a model a view or a controller you are creating? In this case we are creating a view
- what is the name of the view , in this case the NAME of the view is "HTML", later we might create a view called "mobile" for example.
- the last argument is the TYPE of view, in this case TT means Template Tookkit, which is a templating system that catalyst plays well with. We needed to have the perl module Template and the catalyst helper Catalyst::Helper::View::TT installed for this to work.
Create the template: root/hello.tt
This is a TT view template, called '[% template.name %]'.
then in Root.pm change:
sub hello :Global { my ( $self, $c ) = @_;
$c->response->body("Hello, World!"); }
to:
sub hello :Global { my ( $self, $c ) = @_; $c->stash(template => 'hello.tt'); }
creating a new controller Tracks
./script/myapp_create.pl controller Tracks
updating Makefile.PL
added to Makefile.PL
requires 'Catalyst::Plugin::StackTrace'; requires 'Catalyst::Helper::View::TT';