[Catalyst-commits] r7797 - in trunk/examples/Tutorial:
Final_Tarball Final_Tarballs_Per_Part MyApp MyApp/lib
MyApp/lib/MyApp MyApp/lib/MyApp/Controller
MyApp/lib/MyApp/Model MyApp/lib/MyApp/Schema
MyApp/lib/MyApp/View MyApp/root/lib/config
MyApp/root/lib/site MyApp/root/src MyApp/root/src/books
MyApp/script MyApp/t
hkclark at dev.catalyst.perl.org
hkclark at dev.catalyst.perl.org
Mon May 26 13:20:55 BST 2008
Author: hkclark
Date: 2008-05-26 13:20:53 +0100 (Mon, 26 May 2008)
New Revision: 7797
Added:
trunk/examples/Tutorial/Final_Tarballs_Per_Part/Hello_Part2.tgz
trunk/examples/Tutorial/MyApp/lib/MyApp/Model/DB.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Schema.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/
trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Authors.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/BookAuthors.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Books.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Roles.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/UserRoles.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Users.pm
trunk/examples/Tutorial/MyApp/myapp.conf
trunk/examples/Tutorial/MyApp/t/model_DB.t
Removed:
trunk/examples/Tutorial/MyApp/lib/FormElementContainer.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Model/MyAppDB.pm
trunk/examples/Tutorial/MyApp/lib/MyAppDB.pm
trunk/examples/Tutorial/MyApp/lib/MyAppDB/
trunk/examples/Tutorial/MyApp/myapp.yml
trunk/examples/Tutorial/MyApp/root/src/books/hw_form.tt2
trunk/examples/Tutorial/MyApp/t/model_MyAppDB.t
Modified:
trunk/examples/Tutorial/Final_Tarball/MyApp_Part8.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part3.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part4.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part5.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part6.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part7.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part8.tgz
trunk/examples/Tutorial/MyApp/Changes
trunk/examples/Tutorial/MyApp/Makefile.PL
trunk/examples/Tutorial/MyApp/README
trunk/examples/Tutorial/MyApp/lib/MyApp.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Books.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Login.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Logout.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Root.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/View/TT.pm
trunk/examples/Tutorial/MyApp/myapp.db
trunk/examples/Tutorial/MyApp/myapp01.sql
trunk/examples/Tutorial/MyApp/myapp02.sql
trunk/examples/Tutorial/MyApp/myapp03.sql
trunk/examples/Tutorial/MyApp/myappTEST.db
trunk/examples/Tutorial/MyApp/root/lib/config/col
trunk/examples/Tutorial/MyApp/root/lib/config/main
trunk/examples/Tutorial/MyApp/root/lib/config/url
trunk/examples/Tutorial/MyApp/root/lib/site/footer
trunk/examples/Tutorial/MyApp/root/lib/site/header
trunk/examples/Tutorial/MyApp/root/lib/site/html
trunk/examples/Tutorial/MyApp/root/lib/site/layout
trunk/examples/Tutorial/MyApp/root/lib/site/wrapper
trunk/examples/Tutorial/MyApp/root/src/books/create_done.tt2
trunk/examples/Tutorial/MyApp/root/src/books/form_create.tt2
trunk/examples/Tutorial/MyApp/root/src/books/list.tt2
trunk/examples/Tutorial/MyApp/root/src/error.tt2
trunk/examples/Tutorial/MyApp/root/src/login.tt2
trunk/examples/Tutorial/MyApp/root/src/message.tt2
trunk/examples/Tutorial/MyApp/root/src/ttsite.css
trunk/examples/Tutorial/MyApp/root/src/welcome.tt2
trunk/examples/Tutorial/MyApp/script/myapp_cgi.pl
trunk/examples/Tutorial/MyApp/script/myapp_create.pl
trunk/examples/Tutorial/MyApp/script/myapp_fastcgi.pl
trunk/examples/Tutorial/MyApp/script/myapp_server.pl
trunk/examples/Tutorial/MyApp/script/myapp_test.pl
trunk/examples/Tutorial/MyApp/t/01app.t
trunk/examples/Tutorial/MyApp/t/02pod.t
trunk/examples/Tutorial/MyApp/t/03podcoverage.t
trunk/examples/Tutorial/MyApp/t/controller_Books.t
trunk/examples/Tutorial/MyApp/t/controller_Login.t
trunk/examples/Tutorial/MyApp/t/controller_Logout.t
trunk/examples/Tutorial/MyApp/t/live_app01.t
Log:
Update example code/tarballs after conversion to Config::General and MyApp::Schema & DB for model
Modified: trunk/examples/Tutorial/Final_Tarball/MyApp_Part8.tgz
===================================================================
(Binary files differ)
Added: trunk/examples/Tutorial/Final_Tarballs_Per_Part/Hello_Part2.tgz
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Tutorial/Final_Tarballs_Per_Part/Hello_Part2.tgz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part3.tgz
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part4.tgz
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part5.tgz
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part6.tgz
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part7.tgz
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part8.tgz
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/MyApp/Changes
===================================================================
--- trunk/examples/Tutorial/MyApp/Changes 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/Changes 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,4 +1,4 @@
-This file documents the revision history for Perl extension MyApp.
-
-0.01 2008-05-21 11:44:15
- - initial revision, generated by Catalyst
+This file documents the revision history for Perl extension MyApp.
+
+0.01 2008-05-21 14:05:46
+ - initial revision, generated by Catalyst
Modified: trunk/examples/Tutorial/MyApp/Makefile.PL
===================================================================
--- trunk/examples/Tutorial/MyApp/Makefile.PL 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/Makefile.PL 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,16 +1,16 @@
-use inc::Module::Install;
-
-name 'MyApp';
-all_from 'lib/MyApp.pm';
-
-requires 'Catalyst::Runtime' => '5.7011';
-requires 'Catalyst::Plugin::ConfigLoader';
-requires 'Catalyst::Plugin::Static::Simple';
-requires 'Catalyst::Action::RenderView';
-requires 'YAML'; # This should reflect the config file format you've chosen
- # See Catalyst::Plugin::ConfigLoader for supported formats
-catalyst;
-
-install_script glob('script/*.pl');
-auto_install;
-WriteAll;
+use inc::Module::Install;
+
+name 'MyApp';
+all_from 'lib/MyApp.pm';
+
+requires 'Catalyst::Runtime' => '5.7011';
+requires 'Catalyst::Plugin::ConfigLoader';
+requires 'Catalyst::Plugin::Static::Simple';
+requires 'Catalyst::Action::RenderView';
+requires 'YAML'; # This should reflect the config file format you've chosen
+ # See Catalyst::Plugin::ConfigLoader for supported formats
+catalyst;
+
+install_script glob('script/*.pl');
+auto_install;
+WriteAll;
Modified: trunk/examples/Tutorial/MyApp/README
===================================================================
--- trunk/examples/Tutorial/MyApp/README 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/README 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,6 +1 @@
-Run script/myapp_server.pl to test the application.
-
-
-IMPORTANT NOTE: Because there will be multiple options for Step 9
-(AdvancedCRUD), this directory only contains the complete code through
-Step 8 (Testing).
+Run script/myapp_server.pl to test the application.
Deleted: trunk/examples/Tutorial/MyApp/lib/FormElementContainer.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/FormElementContainer.pm 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/lib/FormElementContainer.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,22 +0,0 @@
-package FormElementContainer;
-
-use base 'HTML::Widget::Container';
-
-sub _build_element {
- my ($self, $element) = @_;
-
- return () unless $element;
- if (ref $element eq 'ARRAY') {
- return map { $self->_build_element($_) } @{$element};
- }
- my $e = $element->clone;
- my $class = $e->attr('class') || '';
- $e = new HTML::Element('span', class => 'fields_with_errors')->push_content($e)
- if $self->error && $e->tag eq 'input';
-
- return $e ? ($e) : ();
-}
-
-1;
-
-
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Books.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Books.pm 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Books.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,204 +1,205 @@
-package MyApp::Controller::Books;
-
-use strict;
-use warnings;
-use base 'Catalyst::Controller';
-
-=head1 NAME
-
-MyApp::Controller::Books - Catalyst Controller
-
-=head1 DESCRIPTION
-
-Catalyst Controller.
-
-=head1 METHODS
-
-=cut
-
-
-=head2 index
-
-=cut
-
-sub index : Private {
-my ( $self, $c ) = @_;
-
- $c->response->body('Matched MyApp::Controller::Books in Books.');
-}
-
-
-=head2 list
-
-Fetch all book objects and pass to books/list.tt2 in stash to be displayed
-
-=cut
-
-sub list : Local {
- # Retrieve the usual perl OO '$self' for this object. $c is the Catalyst
- # 'Context' that's used to 'glue together' the various components
- # that make up the application
- my ($self, $c) = @_;
-
-#$DB::single=1;
-
- # Retrieve all of the book records as book model objects and store in the
- # stash where they can be accessed by the TT template
- $c->stash->{books} = [$c->model('MyAppDB::Books')->all];
-
- # Set the TT template to use. You will almost always want to do this
- # in your action methods (actions methods respond to user input in
- # your controllers).
- $c->stash->{template} = 'books/list.tt2';
-}
-
-
-
-=head2 url_create
-
-Create a book with the supplied title and rating,
-with manual authorization
-
-=cut
-
-sub url_create : Local {
- # In addition to self & context, get the title, rating & author_id args
- # from the URL. Note that Catalyst automatically puts extra information
- # after the "/<controller_name>/<action_name/" into @_
- my ($self, $c, $title, $rating, $author_id) = @_;
-
- # Check the user's roles
- if ($c->check_user_roles('admin')) {
- # Call create() on the book model object. Pass the table
- # columns/field values we want to set as hash values
- my $book = $c->model('MyAppDB::Books')->create({
- title => $title,
- rating => $rating
- });
-
- # Add a record to the join table for this book, mapping to
- # appropriate author
- $book->add_to_book_authors({author_id => $author_id});
- # Note: Above is a shortcut for this:
- # $book->create_related('book_authors', {author_id => $author_id});
-
- # Assign the Book object to the stash for display in the view
- $c->stash->{book} = $book;
-
- # This is a hack to disable XSUB processing in Data::Dumper
- # (it's used in the view). This is a work-around for a bug in
- # the interaction of some versions or Perl, Data::Dumper & DBIC.
- # You won't need this if you aren't using Data::Dumper (or if
- # you are running DBIC 0.06001 or greater), but adding it doesn't
- # hurt anything either.
- $Data::Dumper::Useperl = 1;
-
- # Set the TT template to use
- $c->stash->{template} = 'books/create_done.tt2';
- } else {
- # Provide very simple feedback to the user
- $c->response->body('Unauthorized!');
- }
-}
-
-
-
-
-=head2 form_create
-
-Display form to collect information for book to create
-
-=cut
-
-sub form_create : Local {
- my ($self, $c) = @_;
-
- # Set the TT template to use
- $c->stash->{template} = 'books/form_create.tt2';
-}
-
-
-=head2 form_create_do
-
-Take information from form and add to database
-
-=cut
-
-sub form_create_do : Local {
- my ($self, $c) = @_;
-
- # Retrieve the values from the form
- my $title = $c->request->params->{title} || 'N/A';
- my $rating = $c->request->params->{rating} || 'N/A';
- my $author_id = $c->request->params->{author_id} || '1';
-
- # Create the book
- my $book = $c->model('MyAppDB::Books')->create({
- title => $title,
- rating => $rating,
- });
- # Handle relationship with author
- $book->add_to_book_authors({author_id => $author_id});
-
- # Store new model object in stash
- $c->stash->{book} = $book;
-
- # Avoid Data::Dumper issue mentioned earlier
- # You can probably omit this
- $Data::Dumper::Useperl = 1;
-
- # Set the TT template to use
- $c->stash->{template} = 'books/create_done.tt2';
-}
-
-
-=head2 delete
-
-Delete a book
-
-=cut
-
-sub delete : Local {
- # $id = primary key of book to delete
- my ($self, $c, $id) = @_;
-
- # Search for the book and then delete it
- $c->model('MyAppDB::Books')->search({id => $id})->delete_all;
-
- # Use 'flash' to save information across requests until it's read
- $c->flash->{status_msg} = "Book deleted";
-
- # Redirect the user back to the list page
- $c->response->redirect($c->uri_for('/books/list'));
-}
-
-
-=head2 access_denied
-
-Handle Catalyst::Plugin::Authorization::ACL access denied exceptions
-
-=cut
-
-sub access_denied : Private {
- my ($self, $c) = @_;
-
- # Set the error message
- $c->stash->{error_msg} = 'Unauthorized!';
-
- # Display the list
- $c->forward('list');
-}
-
-
-=head1 AUTHOR
-
-A clever guy
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
+package MyApp::Controller::Books;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+=head1 NAME
+
+MyApp::Controller::Books - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 index
+
+=cut
+
+sub index : Private {
+ my ( $self, $c ) = @_;
+
+ $c->response->body('Matched MyApp::Controller::Books in Books.');
+}
+
+
+
+=head2 list
+
+Fetch all book objects and pass to books/list.tt2 in stash to be displayed
+
+=cut
+
+sub list : Local {
+ # Retrieve the usual Perl OO '$self' for this object. $c is the Catalyst
+ # 'Context' that's used to 'glue together' the various components
+ # that make up the application
+ my ($self, $c) = @_;
+
+ # Retrieve all of the book records as book model objects and store in the
+ # stash where they can be accessed by the TT template
+ $c->stash->{books} = [$c->model('DB::Books')->all];
+
+ # Set the TT template to use. You will almost always want to do this
+ # in your action methods (action methods respond to user input in
+ # your controllers).
+ $c->stash->{template} = 'books/list.tt2';
+}
+
+
+
+=head2 url_create
+
+Create a book with the supplied title and rating,
+with manual authorization
+
+=cut
+
+sub url_create : Local {
+ # In addition to self & context, get the title, rating & author_id args
+ # from the URL. Note that Catalyst automatically puts extra information
+ # after the "/<controller_name>/<action_name/" into @_
+ my ($self, $c, $title, $rating, $author_id) = @_;
+
+ # Check the user's roles
+ if ($c->check_user_roles('admin')) {
+ # Call create() on the book model object. Pass the table
+ # columns/field values we want to set as hash values
+ my $book = $c->model('DB::Books')->create({
+ title => $title,
+ rating => $rating
+ });
+
+ # Add a record to the join table for this book, mapping to
+ # appropriate author
+ $book->add_to_book_authors({author_id => $author_id});
+ # Note: Above is a shortcut for this:
+ # $book->create_related('book_authors', {author_id => $author_id});
+
+ # Assign the Book object to the stash for display in the view
+ $c->stash->{book} = $book;
+
+ # This is a hack to disable XSUB processing in Data::Dumper
+ # (it's used in the view). This is a work-around for a bug in
+ # the interaction of some versions or Perl, Data::Dumper & DBIC.
+ # You won't need this if you aren't using Data::Dumper (or if
+ # you are running DBIC 0.06001 or greater), but adding it doesn't
+ # hurt anything either.
+ $Data::Dumper::Useperl = 1;
+
+ # Set the TT template to use
+ $c->stash->{template} = 'books/create_done.tt2';
+ } else {
+ # Provide very simple feedback to the user
+ $c->response->body('Unauthorized!');
+ }
+}
+
+
+
+=head2 form_create
+
+Display form to collect information for book to create
+
+=cut
+
+sub form_create : Local {
+ my ($self, $c) = @_;
+
+ # Set the TT template to use
+ $c->stash->{template} = 'books/form_create.tt2';
+}
+
+
+
+=head2 form_create_do
+
+Take information from form and add to database
+
+=cut
+
+sub form_create_do : Local {
+ my ($self, $c) = @_;
+
+ # Retrieve the values from the form
+ my $title = $c->request->params->{title} || 'N/A';
+ my $rating = $c->request->params->{rating} || 'N/A';
+ my $author_id = $c->request->params->{author_id} || '1';
+
+ # Create the book
+ my $book = $c->model('DB::Books')->create({
+ title => $title,
+ rating => $rating,
+ });
+ # Handle relationship with author
+ $book->add_to_book_authors({author_id => $author_id});
+
+ # Store new model object in stash
+ $c->stash->{book} = $book;
+
+ # Avoid Data::Dumper issue mentioned earlier
+ # You can probably omit this
+ $Data::Dumper::Useperl = 1;
+
+ # Set the TT template to use
+ $c->stash->{template} = 'books/create_done.tt2';
+}
+
+
+
+=head2 delete
+
+Delete a book
+
+=cut
+
+sub delete : Local {
+ # $id = primary key of book to delete
+ my ($self, $c, $id) = @_;
+
+ # Search for the book and then delete it
+ $c->model('DB::Books')->search({id => $id})->delete_all;
+
+ # Use 'flash' to save information across requests until it's read
+ $c->flash->{status_msg} = "Book deleted";
+
+ # Redirect the user back to the list page
+ $c->response->redirect($c->uri_for('/books/list'));
+}
+
+
+
+=head2 access_denied
+
+Handle Catalyst::Plugin::Authorization::ACL access denied exceptions
+
+=cut
+
+sub access_denied : Private {
+ my ($self, $c) = @_;
+
+ # Set the error message
+ $c->stash->{error_msg} = 'Unauthorized!';
+
+ # Display the list
+ $c->forward('list');
+}
+
+
+=head1 AUTHOR
+
+A clever guy
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Login.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Login.pm 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Login.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,63 +1,66 @@
-package MyApp::Controller::Login;
-
-use strict;
-use warnings;
-use base 'Catalyst::Controller';
-
-=head1 NAME
-
-MyApp::Controller::Login - Catalyst Controller
-
-=head1 DESCRIPTION
-
-Catalyst Controller.
-
-=head1 METHODS
-
-=cut
-
-
-=head2 index
-
-Login logic
-
-=cut
-
-sub index : Private {
- my ($self, $c) = @_;
-
- # Get the username and password from form
- my $username = $c->request->params->{username} || "";
- my $password = $c->request->params->{password} || "";
-
- # If the username and password values were found in form
- if ($username && $password) {
- # Attempt to log the user in
- if ($c->authenticate({ username => $username,
- password => $password} )) {
- # If successful, then let them use the application
- $c->response->redirect($c->uri_for('/books/list'));
- return;
- } else {
- # Set an error message
- $c->stash->{error_msg} = "Bad username or password.";
- }
- }
-
- # If either of above don't work out, send to the login page
- $c->stash->{template} = 'login.tt2';
-}
-
-
-=head1 AUTHOR
-
-A clever guy
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
+package MyApp::Controller::Login;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+=head1 NAME
+
+MyApp::Controller::Login - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+
+=head2 index
+
+Login logic
+
+=cut
+
+sub index : Private {
+ my ($self, $c) = @_;
+
+$DB::single=1;
+
+ # Get the username and password from form
+ my $username = $c->request->params->{username} || "";
+ my $password = $c->request->params->{password} || "";
+
+ # If the username and password values were found in form
+ if ($username && $password) {
+ # Attempt to log the user in
+ if ($c->authenticate({ username => $username,
+ password => $password} )) {
+ # If successful, then let them use the application
+ $c->response->redirect($c->uri_for('/books/list'));
+ return;
+ } else {
+ # Set an error message
+ $c->stash->{error_msg} = "Bad username or password.";
+ }
+ }
+
+ # If either of above don't work out, send to the login page
+ $c->stash->{template} = 'login.tt2';
+}
+
+
+=head1 AUTHOR
+
+A clever guy
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Logout.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Logout.pm 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Logout.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,48 +1,48 @@
-package MyApp::Controller::Logout;
-
-use strict;
-use warnings;
-use base 'Catalyst::Controller';
-
-=head1 NAME
-
-MyApp::Controller::Logout - Catalyst Controller
-
-=head1 DESCRIPTION
-
-Catalyst Controller.
-
-=head1 METHODS
-
-=cut
-
-
-=head2 index
-
-Logout logic
-
-=cut
-
-sub index : Private {
- my ($self, $c) = @_;
-
- # Clear the user's state
- $c->logout;
-
- # Send the user to the starting point
- $c->response->redirect($c->uri_for('/'));
-}
-
-
-=head1 AUTHOR
-
-A clever guy
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
+package MyApp::Controller::Logout;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+=head1 NAME
+
+MyApp::Controller::Logout - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 index
+
+Logout logic
+
+=cut
+
+sub index : Private {
+ my ($self, $c) = @_;
+
+ # Clear the user's state
+ $c->logout;
+
+ # Send the user to the starting point
+ $c->response->redirect($c->uri_for('/'));
+}
+
+
+=head1 AUTHOR
+
+A clever guy
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Root.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Root.pm 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Root.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,94 +1,94 @@
-package MyApp::Controller::Root;
-
-use strict;
-use warnings;
-use base 'Catalyst::Controller';
-
-#
-# Sets the actions in this controller to be registered with no prefix
-# so they function identically to actions created in MyApp.pm
-#
-__PACKAGE__->config->{namespace} = '';
-
-=head1 NAME
-
-MyApp::Controller::Root - Root Controller for MyApp
-
-=head1 DESCRIPTION
-
-[enter your description here]
-
-=head1 METHODS
-
-=cut
-
-=head2 default
-
-=cut
-
-sub default : Private {
- my ( $self, $c ) = @_;
-
- # Hello World
- $c->response->body( $c->welcome_message );
-}
-
-=head2 end
-
-Attempt to render a view, if needed.
-
-=cut
-
-sub end : ActionClass('RenderView') {}
-
-
-=head2 auto
-
-Check if there is a user and, if not, forward to login page
-
-=cut
-
-# Note that 'auto' runs after 'begin' but before your actions and that
-# 'auto' "chain" (all from application path to most specific class are run)
-# See the 'Actions' section of 'Catalyst::Manual::Intro' for more info.
-sub auto : Private {
- my ($self, $c) = @_;
-
- # Allow unauthenticated users to reach the login page. This
- # allows anauthenticated users to reach any action in the Login
- # controller. To lock it down to a single action, we could use:
- # if ($c->action eq $c->controller('Login')->action_for('index'))
- # to only allow unauthenticated access to the C<index> action we
- # added above.
- if ($c->controller eq $c->controller('Login')) {
- return 1;
- }
-
- # If a user doesn't exist, force login
- if (!$c->user_exists) {
- # Dump a log message to the development server debug output
- $c->log->debug('***Root::auto User not found, forwarding to /login');
- # Redirect the user to the login page
- $c->response->redirect($c->uri_for('/login'));
- # Return 0 to cancel 'post-auto' processing and prevent use of application
- return 0;
- }
-
- # User found, so return 1 to continue with processing after this 'auto'
- return 1;
-}
-
-
-
-=head1 AUTHOR
-
-Catalyst developer
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
+package MyApp::Controller::Root;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+#
+# Sets the actions in this controller to be registered with no prefix
+# so they function identically to actions created in MyApp.pm
+#
+__PACKAGE__->config->{namespace} = '';
+
+=head1 NAME
+
+MyApp::Controller::Root - Root Controller for MyApp
+
+=head1 DESCRIPTION
+
+[enter your description here]
+
+=head1 METHODS
+
+=cut
+
+=head2 default
+
+=cut
+
+sub default : Private {
+ my ( $self, $c ) = @_;
+
+ # Hello World
+ $c->response->body( $c->welcome_message );
+}
+
+=head2 end
+
+Attempt to render a view, if needed.
+
+=cut
+
+sub end : ActionClass('RenderView') {}
+
+
+
+=head2 auto
+
+Check if there is a user and, if not, forward to login page
+
+=cut
+
+# Note that 'auto' runs after 'begin' but before your actions and that
+# 'auto' "chain" (all from application path to most specific class are run)
+# See the 'Actions' section of 'Catalyst::Manual::Intro' for more info.
+sub auto : Private {
+ my ($self, $c) = @_;
+
+ # Allow unauthenticated users to reach the login page. This
+ # allows anauthenticated users to reach any action in the Login
+ # controller. To lock it down to a single action, we could use:
+ # if ($c->action eq $c->controller('Login')->action_for('index'))
+ # to only allow unauthenticated access to the C<index> action we
+ # added above.
+ if ($c->controller eq $c->controller('Login')) {
+ return 1;
+ }
+
+ # If a user doesn't exist, force login
+ if (!$c->user_exists) {
+ # Dump a log message to the development server debug output
+ $c->log->debug('***Root::auto User not found, forwarding to /login');
+ # Redirect the user to the login page
+ $c->response->redirect($c->uri_for('/login'));
+ # Return 0 to cancel 'post-auto' processing and prevent use of application
+ return 0;
+ }
+
+ # User found, so return 1 to continue with processing after this 'auto'
+ return 1;
+}
+
+
+=head1 AUTHOR
+
+Catalyst developer
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/Tutorial/MyApp/lib/MyApp/Model/DB.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Model/DB.pm (rev 0)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Model/DB.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,36 @@
+package MyApp::Model::DB;
+
+use strict;
+use base 'Catalyst::Model::DBIC::Schema';
+
+my $dsn = $ENV{MYAPP_DSN} ||= 'dbi:SQLite:myapp.db';
+__PACKAGE__->config(
+ schema_class => 'MyApp::Schema',
+ connect_info => [
+ $dsn,
+ ],
+);
+
+=head1 NAME
+
+MyApp::Model::DB - Catalyst DBIC Schema Model
+=head1 SYNOPSIS
+
+See L<MyApp>
+
+=head1 DESCRIPTION
+
+L<Catalyst::Model::DBIC::Schema> Model using schema L<MyApp::Schema>
+
+=head1 AUTHOR
+
+A clever guy
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Deleted: trunk/examples/Tutorial/MyApp/lib/MyApp/Model/MyAppDB.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Model/MyAppDB.pm 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Model/MyAppDB.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,37 +0,0 @@
-package MyApp::Model::MyAppDB;
-
-use strict;
-use base 'Catalyst::Model::DBIC::Schema';
-
-my $dsn = $ENV{MYAPP_DSN} ||= 'dbi:SQLite:myapp.db';
-__PACKAGE__->config(
- schema_class => 'MyApp::Schema::MyAppDB',
- connect_info => [
- $dsn,
-
- ],
-);
-
-=head1 NAME
-
-MyApp::Model::MyAppDB - Catalyst DBIC Schema Model
-=head1 SYNOPSIS
-
-See L<MyApp>
-
-=head1 DESCRIPTION
-
-L<Catalyst::Model::DBIC::Schema> Model using schema L<MyApp::Schema::MyAppDB>
-
-=head1 AUTHOR
-
-A clever guy
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
Added: trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Authors.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Authors.pm (rev 0)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Authors.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,46 @@
+package MyApp::Schema::Authors;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("authors");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "first_name",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "last_name",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-05-21 14:30:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DfIsoG+LQfk77HxGolevUw
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+#
+# Set relationships:
+#
+
+# has_many():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of the model class referenced by this relationship
+# 3) Column name in *foreign* table
+__PACKAGE__->has_many(book_author => 'MyApp::Schema::BookAuthors', 'author_id');
+
+# many_to_many():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of has_many() relationship this many_to_many() is shortcut for
+# 3) Name of belongs_to() relationship in model class of has_many() above
+# You must already have the has_many() defined to use a many_to_many().
+__PACKAGE__->many_to_many(books => 'book_author', 'book');
+
+1;
Added: trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/BookAuthors.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/BookAuthors.pm (rev 0)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/BookAuthors.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,43 @@
+package MyApp::Schema::BookAuthors;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("book_authors");
+__PACKAGE__->add_columns(
+ "book_id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "author_id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("book_id", "author_id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-05-21 14:30:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/aRHB2aLI/Dv25J3a4Sj2w
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+#
+# Set relationships:
+#
+
+# belongs_to():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of the model class referenced by this relationship
+# 3) Column name in *this* table
+__PACKAGE__->belongs_to(book => 'MyApp::Schema::Books', 'book_id');
+
+# belongs_to():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of the model class referenced by this relationship
+# 3) Column name in *this* table
+__PACKAGE__->belongs_to(author => 'MyApp::Schema::Authors', 'author_id');
+
+1;
Added: trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Books.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Books.pm (rev 0)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Books.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,48 @@
+package MyApp::Schema::Books;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("books");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "title",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "rating",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-05-21 14:30:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XWpZZAuhgCiJg1z4feBxVQ
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+
+#
+# Set relationships:
+#
+
+# has_many():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of the model class referenced by this relationship
+# 3) Column name in *foreign* table
+__PACKAGE__->has_many(book_authors => 'MyApp::Schema::BookAuthors', 'book_id');
+
+# many_to_many():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of has_many() relationship this many_to_many() is shortcut for
+# 3) Name of belongs_to() relationship in model class of has_many() above
+# You must already have the has_many() defined to use a many_to_many().
+__PACKAGE__->many_to_many(authors => 'book_authors', 'author');
+
+
+1;
Added: trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Roles.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Roles.pm (rev 0)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Roles.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,38 @@
+package MyApp::Schema::Roles;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("roles");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "role",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-05-21 14:30:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AzLydgGnvXEaIxTlmescDQ
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+
+#
+# Set relationships:
+#
+
+# has_many():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of the model class referenced by this relationship
+# 3) Column name in *foreign* table
+__PACKAGE__->has_many(map_user_role => 'MyApp::Schema::UserRoles', 'role_id');
+
+
+1;
Added: trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/UserRoles.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/UserRoles.pm (rev 0)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/UserRoles.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,43 @@
+package MyApp::Schema::UserRoles;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("user_roles");
+__PACKAGE__->add_columns(
+ "user_id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "role_id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("user_id", "role_id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-05-21 14:30:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nd6Oki5kNXgWFKXrRf0LjQ
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+#
+# Set relationships:
+#
+
+# belongs_to():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of the model class referenced by this relationship
+# 3) Column name in *this* table
+__PACKAGE__->belongs_to(user => 'MyApp::Schema::Users', 'user_id');
+
+# belongs_to():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of the model class referenced by this relationship
+# 3) Column name in *this* table
+__PACKAGE__->belongs_to(role => 'MyApp::Schema::Roles', 'role_id');
+
+1;
Added: trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Users.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Users.pm (rev 0)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Schema/Users.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,54 @@
+package MyApp::Schema::Users;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("users");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "username",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "password",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "email_address",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "first_name",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "last_name",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "active",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-05-21 14:30:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:MG0zfz0tQVnD0y5g28UHOg
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+#
+# Set relationships:
+#
+
+# has_many():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of the model class referenced by this relationship
+# 3) Column name in *foreign* table
+__PACKAGE__->has_many(map_user_role => 'MyApp::Schema::UserRoles', 'user_id');
+
+# many_to_many():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of has_many() relationship this many_to_many() is shortcut for
+# 3) Name of belongs_to() relationship in model class of has_many() above
+# You must already have the has_many() defined to use a many_to_many().
+__PACKAGE__->many_to_many(roles => 'map_user_role', 'role');
+
+1;
Added: trunk/examples/Tutorial/MyApp/lib/MyApp/Schema.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Schema.pm (rev 0)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Schema.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,16 @@
+package MyApp::Schema;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_classes;
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-05-21 14:30:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mZKNg2V3xfGlogSwtwo7/w
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/View/TT.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/View/TT.pm 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/View/TT.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,42 +1,43 @@
-package MyApp::View::TT;
-
-use strict;
-use base 'Catalyst::View::TT';
-
-__PACKAGE__->config({
- CATALYST_VAR => 'Catalyst',
- INCLUDE_PATH => [
- MyApp->path_to( 'root', 'src' ),
- MyApp->path_to( 'root', 'lib' )
- ],
- PRE_PROCESS => 'config/main',
- WRAPPER => 'site/wrapper',
- ERROR => 'error.tt2',
- TIMER => 0,
-});
-
-=head1 NAME
-
-MyApp::View::TT - Catalyst TTSite View
-
-=head1 SYNOPSIS
-
-See L<MyApp>
-
-=head1 DESCRIPTION
-
-Catalyst TTSite View.
-
-=head1 AUTHOR
-
-A clever guy
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
-
+package MyApp::View::TT;
+
+use strict;
+use base 'Catalyst::View::TT';
+
+__PACKAGE__->config({
+ CATALYST_VAR => 'Catalyst',
+ INCLUDE_PATH => [
+ MyApp->path_to( 'root', 'src' ),
+ MyApp->path_to( 'root', 'lib' )
+ ],
+ PRE_PROCESS => 'config/main',
+ WRAPPER => 'site/wrapper',
+ ERROR => 'error.tt2',
+ TIMER => 0,
+ TEMPLATE_EXTENSION => '.tt2',
+});
+
+=head1 NAME
+
+MyApp::View::TT - Catalyst TTSite View
+
+=head1 SYNOPSIS
+
+See L<MyApp>
+
+=head1 DESCRIPTION
+
+Catalyst TTSite View.
+
+=head1 AUTHOR
+
+A clever guy
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp.pm 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,91 +1,91 @@
-package MyApp;
-
-use strict;
-use warnings;
-
-use Catalyst::Runtime '5.70';
-
-# Set flags and add plugins for the application
-#
-# -Debug: activates the debug mode for very useful log messages
-# ConfigLoader: will load the configuration from a YAML file in the
-# application's home directory
-# Static::Simple: will serve static files from the application's root
-# directory
-
-use Catalyst qw/
- -Debug
- ConfigLoader
- Static::Simple
-
- StackTrace
-
- Authentication
- Authorization::Roles
- Authorization::ACL
-
- Session
- Session::Store::FastMmap
- Session::State::Cookie
- /;
-
-our $VERSION = '0.01';
-
-# Configure the application.
-#
-# Note that settings in myapp.yml (or other external
-# configuration file that you set up manually) take precedence
-# over this when using ConfigLoader. Thus configuration
-# details given here can function as a default configuration,
-# with a external configuration file acting as an override for
-# local deployment.
-
-__PACKAGE__->config( name => 'MyApp' );
-
-# Start the application
-__PACKAGE__->setup;
-
-
-# Authorization::ACL Rules
-__PACKAGE__->deny_access_unless(
- "/books/form_create",
- [qw/admin/],
- );
-__PACKAGE__->deny_access_unless(
- "/books/form_create_do",
- [qw/admin/],
- );
-__PACKAGE__->deny_access_unless(
- "/books/delete",
- [qw/user admin/],
- );
-
-
-=head1 NAME
-
-MyApp - Catalyst based application
-
-=head1 SYNOPSIS
-
- script/myapp_server.pl
-
-=head1 DESCRIPTION
-
-[enter your description here]
-
-=head1 SEE ALSO
-
-L<MyApp::Controller::Root>, L<Catalyst>
-
-=head1 AUTHOR
-
-Catalyst developer
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
+package MyApp;
+
+use strict;
+use warnings;
+
+use Catalyst::Runtime '5.70';
+
+# Set flags and add plugins for the application
+#
+# -Debug: activates the debug mode for very useful log messages
+# ConfigLoader: will load the configuration from a YAML file in the
+# application's home directory
+# Static::Simple: will serve static files from the application's root
+# directory
+
+use Catalyst qw/
+ -Debug
+ ConfigLoader
+ Static::Simple
+
+ StackTrace
+
+ Authentication
+ Authorization::Roles
+ Authorization::ACL
+
+ Session
+ Session::Store::FastMmap
+ Session::State::Cookie
+ /;
+
+our $VERSION = '0.01';
+
+# Configure the application.
+#
+# Note that settings in myapp.yml (or other external
+# configuration file that you set up manually) take precedence
+# over this when using ConfigLoader. Thus configuration
+# details given here can function as a default configuration,
+# with a external configuration file acting as an override for
+# local deployment.
+
+__PACKAGE__->config( name => 'MyApp' );
+
+# Start the application
+__PACKAGE__->setup;
+
+
+# Authorization::ACL Rules
+__PACKAGE__->deny_access_unless(
+ "/books/form_create",
+ [qw/admin/],
+ );
+__PACKAGE__->deny_access_unless(
+ "/books/form_create_do",
+ [qw/admin/],
+ );
+__PACKAGE__->deny_access_unless(
+ "/books/delete",
+ [qw/user admin/],
+ );
+
+
+=head1 NAME
+
+MyApp - Catalyst based application
+
+=head1 SYNOPSIS
+
+ script/myapp_server.pl
+
+=head1 DESCRIPTION
+
+[enter your description here]
+
+=head1 SEE ALSO
+
+L<MyApp::Controller::Root>, L<Catalyst>
+
+=head1 AUTHOR
+
+Catalyst developer
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Deleted: trunk/examples/Tutorial/MyApp/lib/MyAppDB.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyAppDB.pm 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/lib/MyAppDB.pm 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,24 +0,0 @@
-package MyAppDB;
-
-=head1 NAME
-
-MyAppDB -- DBIC Schema Class
-
-=cut
-
-# Our schema needs to inherit from 'DBIx::Class::Schema'
-use base qw/DBIx::Class::Schema/;
-
-# Need to load the DB Model classes here.
-# You can use this syntax if you want:
-# __PACKAGE__->load_classes(qw/Book BookAuthor Author User UserRole Role/);
-# Also, if you simply want to load all of the classes in a directory
-# of the same name as your schema class (as we do here) you can use:
-# __PACKAGE__->load_classes(qw//);
-# But the variation below is more flexible in that it can be used to
-# load from multiple namespaces.
-__PACKAGE__->load_classes({
- MyAppDB => [qw/Book BookAuthor Author User UserRole Role/]
-});
-
-1;
Added: trunk/examples/Tutorial/MyApp/myapp.conf
===================================================================
--- trunk/examples/Tutorial/MyApp/myapp.conf (rev 0)
+++ trunk/examples/Tutorial/MyApp/myapp.conf 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,47 @@
+name MyApp
+<authentication>
+ default_realm dbic
+ <realms>
+ <dbic>
+ <credential>
+ # Note this first definition would be the same as setting
+ # __PACKAGE__->config->{authentication}->{realms}->{dbic}
+ # ->{credential} = 'Password' in lib/MyApp.pm
+ #
+ # Specify that we are going to do password-based auth
+ class Password
+ # This is the name of the field in the users table with the
+ # password stored in it
+ password_field password
+ # Switch to more secure hashed passwords
+ password_type hashed
+ # Use the SHA-1 hashing algorithm
+ password_hash_type SHA-1
+ </credential>
+ <store>
+ # Use DBIC to retrieve username, password & role information
+ class DBIx::Class
+ # This is the model object created by Catalyst::Model::DBIC
+ # from your schema (you created 'MyApp::Schema::User' but as
+ # the Catalyst startup debug messages show, it was loaded as
+ # 'MyApp::Model::DB::Users').
+ # NOTE: Omit 'MyApp::Model' here just as you would when using
+ # '$c->model("DB::Users)'
+ user_class DB::Users
+ # This is the name of the field in your 'users' table that
+ # contains the user's name
+ id_field username
+ # This is the name of a many_to_many relation in the users
+ # object that points to the roles for that user
+ role_relation roles
+ # This is the name of field in the roles table that contains
+ # the role information
+ role_field role
+ </store>
+ </dbic>
+ </realms>
+</authentication>
+<session>
+ flash_to_stash 1
+</session>
+
Modified: trunk/examples/Tutorial/MyApp/myapp.db
===================================================================
(Binary files differ)
Deleted: trunk/examples/Tutorial/MyApp/myapp.yml
===================================================================
--- trunk/examples/Tutorial/MyApp/myapp.yml 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/myapp.yml 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,43 +0,0 @@
----
-name: MyApp
-authentication:
- default_realm: dbic
- realms:
- dbic:
- credential:
- # Note this first definition would be the same as setting
- # __PACKAGE__->config->{authentication}->{realms}->{dbic}
- # ->{credential} = 'Password' in lib/MyApp.pm
- # (IOW, each hash key becomes a "name:" in the YAML file).
- #
- # Specify that we are going to do password-based auth
- class: Password
- # This is the name of the field in the users table with the
- # password stored in it
- password_field: password
- # We are using an unencrypted password now
- password_type: hashed
- # Use the SHA-1 hashing algorithm
- password_hash_type: SHA-1
- store:
- # Use DBIC to retrieve username, password & role information
- class: DBIx::Class
- # This is the model object created by Catalyst::Model::DBIC
- # from your schema (you created 'MyAppDB::User' but as the
- # Catalyst startup debug messages show, it was loaded as
- # 'MyApp::Model::MyAppDB::Users').
- # NOTE: Omit 'MyApp::Model' here just as you would when using
- # '$c->model("MyAppDB::Users)'
- user_class: MyAppDB::Users
- # This is the name of the field in your 'users' table that
- # contains the user's name
- id_field: username
- # This is the name of a many_to_many relation in the users
- # object that points to the roles for that user
- role_relation: roles
- # This is the name of field in the roles table that contains
- # the role information
- role_field: role
-
-session:
- flash_to_stash: 1
Modified: trunk/examples/Tutorial/MyApp/myapp01.sql
===================================================================
--- trunk/examples/Tutorial/MyApp/myapp01.sql 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/myapp01.sql 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,44 +1,43 @@
---
--- Create a very simple database to hold book and author information
---
-CREATE TABLE books (
- id INTEGER PRIMARY KEY,
- title TEXT ,
- rating INTEGER
-);
--- 'book_authors' is a many-to-many join table between books & authors
-CREATE TABLE book_authors (
- book_id INTEGER,
- author_id INTEGER,
- PRIMARY KEY (book_id, author_id)
-);
-CREATE TABLE authors (
- id INTEGER PRIMARY KEY,
- first_name TEXT,
- last_name TEXT
-);
----
---- Load some sample data
----
-INSERT INTO books VALUES (1, 'CCSP SNRS Exam Certification Guide', 5);
-INSERT INTO books VALUES (2, 'TCP/IP Illustrated, Volume 1', 5);
-INSERT INTO books VALUES (3, 'Internetworking with TCP/IP Vol.1', 4);
-INSERT INTO books VALUES (4, 'Perl Cookbook', 5);
-INSERT INTO books VALUES (5, 'Designing with Web Standards', 5);
-INSERT INTO authors VALUES (1, 'Greg', 'Bastien');
-INSERT INTO authors VALUES (2, 'Sara', 'Nasseh');
-INSERT INTO authors VALUES (3, 'Christian', 'Degu');
-INSERT INTO authors VALUES (4, 'Richard', 'Stevens');
-INSERT INTO authors VALUES (5, 'Douglas', 'Comer');
-INSERT INTO authors VALUES (6, 'Tom', 'Christiansen');
-INSERT INTO authors VALUES (7, 'Nathan', 'Torkington');
-INSERT INTO authors VALUES (8, 'Jeffrey', 'Zeldman');
-INSERT INTO book_authors VALUES (1, 1);
-INSERT INTO book_authors VALUES (1, 2);
-INSERT INTO book_authors VALUES (1, 3);
-INSERT INTO book_authors VALUES (2, 4);
-INSERT INTO book_authors VALUES (3, 5);
-INSERT INTO book_authors VALUES (4, 6);
-INSERT INTO book_authors VALUES (4, 7);
-INSERT INTO book_authors VALUES (5, 8);
-
+--
+-- Create a very simple database to hold book and author information
+--
+CREATE TABLE books (
+ id INTEGER PRIMARY KEY,
+ title TEXT ,
+ rating INTEGER
+);
+-- 'book_authors' is a many-to-many join table between books & authors
+CREATE TABLE book_authors (
+ book_id INTEGER,
+ author_id INTEGER,
+ PRIMARY KEY (book_id, author_id)
+);
+CREATE TABLE authors (
+ id INTEGER PRIMARY KEY,
+ first_name TEXT,
+ last_name TEXT
+);
+---
+--- Load some sample data
+---
+INSERT INTO books VALUES (1, 'CCSP SNRS Exam Certification Guide', 5);
+INSERT INTO books VALUES (2, 'TCP/IP Illustrated, Volume 1', 5);
+INSERT INTO books VALUES (3, 'Internetworking with TCP/IP Vol.1', 4);
+INSERT INTO books VALUES (4, 'Perl Cookbook', 5);
+INSERT INTO books VALUES (5, 'Designing with Web Standards', 5);
+INSERT INTO authors VALUES (1, 'Greg', 'Bastien');
+INSERT INTO authors VALUES (2, 'Sara', 'Nasseh');
+INSERT INTO authors VALUES (3, 'Christian', 'Degu');
+INSERT INTO authors VALUES (4, 'Richard', 'Stevens');
+INSERT INTO authors VALUES (5, 'Douglas', 'Comer');
+INSERT INTO authors VALUES (6, 'Tom', 'Christiansen');
+INSERT INTO authors VALUES (7, 'Nathan', 'Torkington');
+INSERT INTO authors VALUES (8, 'Jeffrey', 'Zeldman');
+INSERT INTO book_authors VALUES (1, 1);
+INSERT INTO book_authors VALUES (1, 2);
+INSERT INTO book_authors VALUES (1, 3);
+INSERT INTO book_authors VALUES (2, 4);
+INSERT INTO book_authors VALUES (3, 5);
+INSERT INTO book_authors VALUES (4, 6);
+INSERT INTO book_authors VALUES (4, 7);
+INSERT INTO book_authors VALUES (5, 8);
Modified: trunk/examples/Tutorial/MyApp/myapp02.sql
===================================================================
--- trunk/examples/Tutorial/MyApp/myapp02.sql 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/myapp02.sql 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,34 +1,33 @@
---
--- Add users and roles tables, along with a many-to-many join table
---
-CREATE TABLE users (
- id INTEGER PRIMARY KEY,
- username TEXT,
- password TEXT,
- email_address TEXT,
- first_name TEXT,
- last_name TEXT,
- active INTEGER
-);
-CREATE TABLE roles (
- id INTEGER PRIMARY KEY,
- role TEXT
-);
-CREATE TABLE user_roles (
- user_id INTEGER,
- role_id INTEGER,
- PRIMARY KEY (user_id, role_id)
-);
---
--- Load up some initial test data
---
-INSERT INTO users VALUES (1, 'test01', 'mypass', 't01 at na.com', 'Joe', 'Blow', 1);
-INSERT INTO users VALUES (2, 'test02', 'mypass', 't02 at na.com', 'Jane', 'Doe', 1);
-INSERT INTO users VALUES (3, 'test03', 'mypass', 't03 at na.com', 'No', 'Go', 0);
-INSERT INTO roles VALUES (1, 'user');
-INSERT INTO roles VALUES (2, 'admin');
-INSERT INTO user_roles VALUES (1, 1);
-INSERT INTO user_roles VALUES (1, 2);
-INSERT INTO user_roles VALUES (2, 1);
-INSERT INTO user_roles VALUES (3, 1);
-
+--
+-- Add users and roles tables, along with a many-to-many join table
+--
+CREATE TABLE users (
+ id INTEGER PRIMARY KEY,
+ username TEXT,
+ password TEXT,
+ email_address TEXT,
+ first_name TEXT,
+ last_name TEXT,
+ active INTEGER
+);
+CREATE TABLE roles (
+ id INTEGER PRIMARY KEY,
+ role TEXT
+);
+CREATE TABLE user_roles (
+ user_id INTEGER,
+ role_id INTEGER,
+ PRIMARY KEY (user_id, role_id)
+);
+--
+-- Load up some initial test data
+--
+INSERT INTO users VALUES (1, 'test01', 'mypass', 't01 at na.com', 'Joe', 'Blow', 1);
+INSERT INTO users VALUES (2, 'test02', 'mypass', 't02 at na.com', 'Jane', 'Doe', 1);
+INSERT INTO users VALUES (3, 'test03', 'mypass', 't03 at na.com', 'No', 'Go', 0);
+INSERT INTO roles VALUES (1, 'user');
+INSERT INTO roles VALUES (2, 'admin');
+INSERT INTO user_roles VALUES (1, 1);
+INSERT INTO user_roles VALUES (1, 2);
+INSERT INTO user_roles VALUES (2, 1);
+INSERT INTO user_roles VALUES (3, 1);
Modified: trunk/examples/Tutorial/MyApp/myapp03.sql
===================================================================
--- trunk/examples/Tutorial/MyApp/myapp03.sql 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/myapp03.sql 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,7 +1,8 @@
---
--- Convert passwords to SHA-1 hashes
---
-UPDATE users SET password = 'e727d1464ae12436e899a726da5b2f11d8381b26' WHERE id = 1;
-UPDATE users SET password = 'e727d1464ae12436e899a726da5b2f11d8381b26' WHERE id = 2;
-UPDATE users SET password = 'e727d1464ae12436e899a726da5b2f11d8381b26' WHERE id = 3;
-
+--
+-- Convert passwords to SHA-1 hashes
+--
+UPDATE users SET password = 'e727d1464ae12436e899a726da5b2f11d8381b26' WHERE id = 1;
+UPDATE users SET password = 'e727d1464ae12436e899a726da5b2f11d8381b26' WHERE id = 2;
+UPDATE users SET password = 'e727d1464ae12436e899a726da5b2f11d8381b26' WHERE id = 3;
+
+
Modified: trunk/examples/Tutorial/MyApp/myappTEST.db
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/MyApp/root/lib/config/col
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/config/col 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/lib/config/col 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,21 +1,21 @@
-[% site.rgb = {
- black = '#000000'
- white = '#ffffff'
- grey1 = '#46494c'
- grey2 = '#c6c9cc'
- grey3 = '#e3e6ea'
- red = '#CC4444'
- green = '#66AA66'
- blue = '#89b8df'
- orange = '#f08900'
- };
-
- site.col = {
- page = site.rgb.white
- text = site.rgb.grey1
- head = site.rgb.grey3
- line = site.rgb.orange
- message = site.rgb.green
- error = site.rgb.red
- };
-%]
+[% site.rgb = {
+ black = '#000000'
+ white = '#ffffff'
+ grey1 = '#46494c'
+ grey2 = '#c6c9cc'
+ grey3 = '#e3e6ea'
+ red = '#CC4444'
+ green = '#66AA66'
+ blue = '#89b8df'
+ orange = '#f08900'
+ };
+
+ site.col = {
+ page = site.rgb.white
+ text = site.rgb.grey1
+ head = site.rgb.grey3
+ line = site.rgb.orange
+ message = site.rgb.green
+ error = site.rgb.red
+ };
+%]
Modified: trunk/examples/Tutorial/MyApp/root/lib/config/main
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/config/main 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/lib/config/main 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,27 +1,27 @@
-[% # config/main
- #
- # This is the main configuration template which is processed before
- # any other page, by virtue of it being defined as a PRE_PROCESS
- # template. This is the place to define any extra template variables,
- # macros, load plugins, and perform any other template setup.
-
- IF Catalyst.debug;
- # define a debug() macro directed to Catalyst's log
- MACRO debug(message) CALL Catalyst.log.debug(message);
- END;
-
- # define a data structure to hold sitewide data
- site = {
- title => 'Catalyst::View::TTSite Example Page',
- copyright => '2008 Your Name Here',
- };
-
- # load up any other configuration items
- PROCESS config/col
- + config/url;
-
- # set defaults for variables, etc.
- DEFAULT
- message = 'There is no message';
-
--%]
+[% # config/main
+ #
+ # This is the main configuration template which is processed before
+ # any other page, by virtue of it being defined as a PRE_PROCESS
+ # template. This is the place to define any extra template variables,
+ # macros, load plugins, and perform any other template setup.
+
+ IF Catalyst.debug;
+ # define a debug() macro directed to Catalyst's log
+ MACRO debug(message) CALL Catalyst.log.debug(message);
+ END;
+
+ # define a data structure to hold sitewide data
+ site = {
+ title => 'Catalyst::View::TTSite Example Page',
+ copyright => '2008 Your Name Here',
+ };
+
+ # load up any other configuration items
+ PROCESS config/col
+ + config/url;
+
+ # set defaults for variables, etc.
+ DEFAULT
+ message = 'There is no message';
+
+-%]
Modified: trunk/examples/Tutorial/MyApp/root/lib/config/url
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/config/url 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/lib/config/url 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,8 +1,8 @@
-[% base = Catalyst.req.base;
-
- site.url = {
- base = base
- home = "${base}welcome"
- message = "${base}message"
- }
--%]
+[% base = Catalyst.req.base;
+
+ site.url = {
+ base = base
+ home = "${base}welcome"
+ message = "${base}message"
+ }
+-%]
Modified: trunk/examples/Tutorial/MyApp/root/lib/site/footer
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/site/footer 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/lib/site/footer 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,3 +1,3 @@
-<!-- BEGIN site/footer -->
-<div id="copyright">© [% site.copyright %]</div>
-<!-- END site/footer -->
+<!-- BEGIN site/footer -->
+<div id="copyright">© [% site.copyright %]</div>
+<!-- END site/footer -->
Modified: trunk/examples/Tutorial/MyApp/root/lib/site/header
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/site/header 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/lib/site/header 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,3 +1,3 @@
-<!-- BEGIN site/header -->
-<h1 class="title">[% template.title or site.title %]</h1>
-<!-- END site/header -->
+<!-- BEGIN site/header -->
+<h1 class="title">[% template.title or site.title %]</h1>
+<!-- END site/header -->
Modified: trunk/examples/Tutorial/MyApp/root/lib/site/html
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/site/html 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/lib/site/html 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,12 +1,12 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- <title>[% template.title or site.title %]</title>
- <style type="text/css">
-[% PROCESS ttsite.css %]
- </style>
- </head>
- <body>
-[% content %]
- </body>
-</html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>[% template.title or site.title %]</title>
+ <style type="text/css">
+[% PROCESS ttsite.css %]
+ </style>
+ </head>
+ <body>
+[% content %]
+ </body>
+</html>
Modified: trunk/examples/Tutorial/MyApp/root/lib/site/layout
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/site/layout 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/lib/site/layout 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,9 +1,9 @@
-<div id="header">[% PROCESS site/header %]</div>
-
-<div id="content">
-<span class="message">[% status_msg %]</span>
-<span class="error">[% error_msg %]</span>
-[% content %]
-</div>
-
-<div id="footer">[% PROCESS site/footer %]</div>
+<div id="header">[% PROCESS site/header %]</div>
+
+<div id="content">
+<span class="message">[% status_msg %]</span>
+<span class="error">[% error_msg %]</span>
+[% content %]
+</div>
+
+<div id="footer">[% PROCESS site/footer %]</div>
Modified: trunk/examples/Tutorial/MyApp/root/lib/site/wrapper
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/site/wrapper 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/lib/site/wrapper 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,8 +1,8 @@
-[% IF template.name.match('\.(css|js|txt)');
- debug("Passing page through as text: $template.name");
- content;
- ELSE;
- debug("Applying HTML page layout wrappers to $template.name\n");
- content WRAPPER site/html + site/layout;
- END;
--%]
+[% IF template.name.match('\.(css|js|txt)');
+ debug("Passing page through as text: $template.name");
+ content;
+ ELSE;
+ debug("Applying HTML page layout wrappers to $template.name\n");
+ content WRAPPER site/html + site/layout;
+ END;
+-%]
Modified: trunk/examples/Tutorial/MyApp/root/src/books/create_done.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/books/create_done.tt2 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/src/books/create_done.tt2 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,35 +1,35 @@
-[% # Use the TT Dumper plugin to Data::Dumper variables to the browser -%]
-[% # Not a good idea for production use, though. :-) 'Indent=1' is -%]
-[% # optional, but prevents "massive indenting" of deeply nested objects -%]
-[% USE Dumper(Indent=1) -%]
-
-[% # Set the page title. META can 'go back' and set values in templates -%]
-[% # that have been processed 'before' this template (here it's for -%]
-[% # root/lib/site/html and root/lib/site/header). Note that META on -%]
-[% # simple strings (e.g., no variable interpolation). -%]
-[% META title = 'Book Created' %]
-
-[% # Output information about the record that was added. First title. -%]
-<p>Added book '[% book.title %]'
-
-[% # Output the last name of the first author. This is complicated by an -%]
-[% # issue in TT 2.15 where blessed hash objects are not handled right. -%]
-[% # First, fetch 'book.authors' from the DB once. -%]
-[% authors = book.authors %]
-[% # Now use IF statements to test if 'authors.first' is "working". If so, -%]
-[% # we use it. Otherwise we use a hack that seems to keep TT 2.15 happy. -%]
-by '[% authors.first.last_name IF authors.first;
- authors.list.first.value.last_name IF ! authors.first %]'
-
-[% # Output the rating for the book that was added -%]
-with a rating of [% book.rating %].</p>
-
-[% # Provide a link back to the list page -%]
-[% # 'uri_for()' builds a full URI; e.g., 'http://localhost:3000/books/list' -%]
-<p><a href="[% Catalyst.uri_for('/books/list') %]">Return to list</a></p>
-
-[% # Try out the TT Dumper (for development only!) -%]
-<pre>
-Dump of the 'book' variable:
-[% Dumper.dump(book) %]
-
+[% # Use the TT Dumper plugin to Data::Dumper variables to the browser -%]
+[% # Not a good idea for production use, though. :-) 'Indent=1' is -%]
+[% # optional, but prevents "massive indenting" of deeply nested objects -%]
+[% USE Dumper(Indent=1) -%]
+
+[% # Set the page title. META can 'go back' and set values in templates -%]
+[% # that have been processed 'before' this template (here it's for -%]
+[% # root/lib/site/html and root/lib/site/header). Note that META on -%]
+[% # simple strings (e.g., no variable interpolation). -%]
+[% META title = 'Book Created' %]
+
+[% # Output information about the record that was added. First title. -%]
+<p>Added book '[% book.title %]'
+
+[% # Output the last name of the first author. This is complicated by an -%]
+[% # issue in TT 2.15 where blessed hash objects are not handled right. -%]
+[% # First, fetch 'book.authors' from the DB once. -%]
+[% authors = book.authors %]
+[% # Now use IF statements to test if 'authors.first' is "working". If so, -%]
+[% # we use it. Otherwise we use a hack that seems to keep TT 2.15 happy. -%]
+by '[% authors.first.last_name IF authors.first;
+ authors.list.first.value.last_name IF ! authors.first %]'
+
+[% # Output the rating for the book that was added -%]
+with a rating of [% book.rating %].</p>
+
+[% # Provide a link back to the list page -%]
+[% # 'uri_for()' builds a full URI; e.g., 'http://localhost:3000/books/list' -%]
+<p><a href="[% Catalyst.uri_for('/books/list') %]">Return to list</a></p>
+
+[% # Try out the TT Dumper (for development only!) -%]
+<pre>
+Dump of the 'book' variable:
+[% Dumper.dump(book) %]
+</pre>
Modified: trunk/examples/Tutorial/MyApp/root/src/books/form_create.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/books/form_create.tt2 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/src/books/form_create.tt2 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,10 +1,10 @@
-[% META title = 'Manual Form Book Create' -%]
-
-<form method="post" action="[% Catalyst.uri_for('form_create_do') %]">
-<table>
- <tr><td>Title:</td><td><input type="text" name="title"></td></tr>
- <tr><td>Rating:</td><td><input type="text" name="rating"></td></tr>
- <tr><td>Author ID:</td><td><input type="text" name="author_id"></td></tr>
-</table>
-<input type="submit" name="Submit" value="Submit">
-</form>
+[% META title = 'Manual Form Book Create' -%]
+
+<form method="post" action="[% Catalyst.uri_for('form_create_do') %]">
+<table>
+ <tr><td>Title:</td><td><input type="text" name="title"></td></tr>
+ <tr><td>Rating:</td><td><input type="text" name="rating"></td></tr>
+ <tr><td>Author ID:</td><td><input type="text" name="author_id"></td></tr>
+</table>
+<input type="submit" name="Submit" value="Submit">
+</form>
Deleted: trunk/examples/Tutorial/MyApp/root/src/books/hw_form.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/books/hw_form.tt2 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/src/books/hw_form.tt2 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,35 +0,0 @@
-[% META title = 'Create/Update Book' %]
-
-[%# Comment out the auto-rendered form %]
-[%# widget_result.as_xml %]
-
-
-[%# Iterate over the form elements and display each -%]
-<form name="book_form" action="[% widget_result.action %]" method="post">
-<table border="0">
-[% FOREACH element = widget_result.elements %]
- <tr>
- <td class="form-label">
- [% element.label.as_text %]
- </td>
- <td class="form-element">
- [% element.element_xml %]
- <span class="form-error">
- [% element.error_xml %]
- </span>
- </td>
- </tr>
-[% END %]
-</table>
-</form>
-
-
-<p><a href="[% Catalyst.uri_for('list') %]">Return to book list</a></p>
-
-
-[%# A little JavaScript to move the cursor to the first field %]
-<script LANGUAGE="JavaScript">
-document.book_form.book_form_title.focus();
-</script>
-
-
Modified: trunk/examples/Tutorial/MyApp/root/src/books/list.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/books/list.tt2 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/src/books/list.tt2 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,64 +1,66 @@
-[% # This is a TT comment. The '-' at the end "chomps" the newline. You won't -%]
-[% # see this "chomping" in your browser because HTML ignores blank lines, but -%]
-[% # it WILL eliminate a blank line if you view the HTML source. It's purely -%]
-[%- # optional, but both the beginning and the ending TT tags support chomping. -%]
-
-[% # Provide a title to root/lib/site/header -%]
-[% META title = 'Book List' -%]
-
-<table>
-<tr><th>Title</th><th>Rating</th><th>Author(s)</th><th>Links</th></tr>
-[% # Display each book in a table row %]
-[% FOREACH book IN books -%]
- <tr>
- <td>[% book.title %]</td>
- <td>[% book.rating %]</td>
- <td>
- [% # First initialize a TT variable to hold a list. Then use a TT FOREACH -%]
- [% # loop in 'side effect notation' to load just the last names of the -%]
- [% # authors into the list. Note that the 'push' TT vmethod does not -%]
- [% # a value, so nothing will be printed here. But, if you have something -%]
- [% # in TT that does return a method and you don't want it printed, you -%]
- [% # can: 1) assign it to a bogus value, or 2) use the CALL keyword to -%]
- [% # call it and discard the return value. -%]
- [% tt_authors = [ ];
- tt_authors.push(author.last_name) FOREACH author = book.authors %]
- [% # Now use a TT 'virtual method' to display the author count in parens -%]
- ([% tt_authors.size %])
- [% # Use another TT vmethod to join & print the names & comma separators -%]
- [% tt_authors.join(', ') %]
- </td>
- <td>
- [% # Add a link to delete a book %]
- <a href="[% Catalyst.uri_for('delete/') _ book.id %]">Delete</a>
- </td>
- </tr>
-[% END -%]
-</table>
-
-<p>
- <a href="[% Catalyst.uri_for('/login') %]">Login</a>
- <a href="[% Catalyst.uri_for('form_create') %]">Create</a>
-</p>
-
-<p>Hello [% Catalyst.user.username %], you have the following roles:</p>
-
-<ul>
- [% # Dump list of roles -%]
- [% FOR role = Catalyst.user.roles %]<li>[% role %]</li>[% END %]
-</ul>
-
-<p>
-[% # Add some simple role-specific logic to template %]
-[% # Use $c->check_user_roles() to check authz -%]
-[% IF Catalyst.check_user_roles('user') %]
- [% # Give normal users a link for 'logout' %]
- <a href="[% Catalyst.uri_for('/logout') %]">Logout</a>
-[% END %]
-
-[% # Can also use $c->user->check_roles() to check authz -%]
-[% IF Catalyst.check_user_roles('admin') %]
- [% # Give admin users a link for 'create' %]
- <a href="[% Catalyst.uri_for('form_create') %]">Create</a>
-[% END %]
-</p>
+[% # This is a TT comment. The '-' at the end "chomps" the newline. You won't -%]
+[% # see this "chomping" in your browser because HTML ignores blank lines, but -%]
+[% # it WILL eliminate a blank line if you view the HTML source. It's purely -%]
+[%- # optional, but both the beginning and the ending TT tags support chomping. -%]
+
+[% # Provide a title to root/lib/site/header -%]
+[% META title = 'Book List' -%]
+
+<table>
+<tr><th>Title</th><th>Rating</th><th>Author(s)</th><th>Links</th></tr>
+[% # Display each book in a table row %]
+[% FOREACH book IN books -%]
+ <tr>
+ <td>[% book.title %]</td>
+ <td>[% book.rating %]</td>
+ <td>
+ [% # First initialize a TT variable to hold a list. Then use a TT FOREACH -%]
+ [% # loop in 'side effect notation' to load just the last names of the -%]
+ [% # authors into the list. Note that the 'push' TT vmethod does not -%]
+ [% # a value, so nothing will be printed here. But, if you have something -%]
+ [% # in TT that does return a method and you don't want it printed, you -%]
+ [% # can: 1) assign it to a bogus value, or 2) use the CALL keyword to -%]
+ [% # call it and discard the return value. -%]
+ [% tt_authors = [ ];
+ tt_authors.push(author.last_name) FOREACH author = book.authors %]
+ [% # Now use a TT 'virtual method' to display the author count in parens -%]
+ ([% tt_authors.size %])
+ [% # Use another TT vmethod to join & print the names & comma separators -%]
+ [% tt_authors.join(', ') %]
+ </td>
+ <td>
+ [% # Add a link to delete a book %]
+ <a href="[% Catalyst.uri_for('delete/') _ book.id %]">Delete</a>
+ </td>
+ </tr>
+[% END -%]
+</table>
+
+<p>
+ <a href="[% Catalyst.uri_for('/login') %]">Login</a>
+ <a href="[% Catalyst.uri_for('form_create') %]">Create</a>
+</p>
+
+<p>Hello [% Catalyst.user.username %], you have the following roles:</p>
+
+<ul>
+ [% # Dump list of roles -%]
+ [% FOR role = Catalyst.user.roles %]<li>[% role %]</li>[% END %]
+</ul>
+
+<p>
+[% # Add some simple role-specific logic to template %]
+[% # Use $c->check_user_roles() to check authz -%]
+[% IF Catalyst.check_user_roles('user') %]
+ [% # Give normal users a link for 'logout' %]
+ <a href="[% Catalyst.uri_for('/logout') %]">Logout</a>
+[% END %]
+
+[% # Can also use $c->user->check_roles() to check authz -%]
+[% IF Catalyst.check_user_roles('admin') %]
+ [% # Give admin users a link for 'create' %]
+ <a href="[% Catalyst.uri_for('form_create') %]">Create</a>
+[% END %]
+</p>
+
+
Modified: trunk/examples/Tutorial/MyApp/root/src/error.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/error.tt2 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/src/error.tt2 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,10 +1,10 @@
-[% META title = 'Catalyst/TT Error' %]
-<p>
- An error has occurred. We're terribly sorry about that, but it's
- one of those things that happens from time to time. Let's just
- hope the developers test everything properly before release...
-</p>
-<p>
- Here's the error message, on the off-chance that it means something
- to you: <span class="error">[% error %]</span>
-</p>
+[% META title = 'Catalyst/TT Error' %]
+<p>
+ An error has occurred. We're terribly sorry about that, but it's
+ one of those things that happens from time to time. Let's just
+ hope the developers test everything properly before release...
+</p>
+<p>
+ Here's the error message, on the off-chance that it means something
+ to you: <span class="error">[% error %]</span>
+</p>
Modified: trunk/examples/Tutorial/MyApp/root/src/login.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/login.tt2 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/src/login.tt2 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,38 +1,38 @@
-[% META title = 'Login' %]
-
-<!-- Login form -->
-<form method="post" action=" [% Catalyst.uri_for('/login') %] ">
- <table>
- <tr>
- <td>Username:</td>
- <td><input type="text" name="username" size="40" /></td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input type="password" name="password" size="40" /></td>
- </tr>
- <tr>
- <td colspan="2"><input type="submit" name="submit" value="Submit" /></td>
- </tr>
- </table>
-</form>
-
-<p>
-[%
- # This code illustrates how certain parts of the TT
- # template will only be shown to users who have logged in
-%]
-[% IF Catalyst.user_exists %]
- Please Note: You are already logged in as '[% Catalyst.user.username %]'.
- You can <a href="[% Catalyst.uri_for('/logout') %]">logout</a> here.
-[% ELSE %]
- You need to log in to use this application.
-[% END %]
-[%#
- Note that this whole block is a comment because the "#" appears
- immediate after the "[%" (with no spaces in between). Although it
- can be a handy way to temporarily "comment out" a whole block of
- TT code, it's probably a little too subtle for use in "normal"
- comments.
-%]
-</p>
+[% META title = 'Login' %]
+
+<!-- Login form -->
+<form method="post" action=" [% Catalyst.uri_for('/login') %] ">
+ <table>
+ <tr>
+ <td>Username:</td>
+ <td><input type="text" name="username" size="40" /></td>
+ </tr>
+ <tr>
+ <td>Password:</td>
+ <td><input type="password" name="password" size="40" /></td>
+ </tr>
+ <tr>
+ <td colspan="2"><input type="submit" name="submit" value="Submit" /></td>
+ </tr>
+ </table>
+</form>
+
+<p>
+[%
+ # This code illustrates how certain parts of the TT
+ # template will only be shown to users who have logged in
+%]
+[% IF Catalyst.user_exists %]
+ Please Note: You are already logged in as '[% Catalyst.user.username %]'.
+ You can <a href="[% Catalyst.uri_for('/logout') %]">logout</a> here.
+[% ELSE %]
+ You need to log in to use this application.
+[% END %]
+[%#
+ Note that this whole block is a comment because the "#" appears
+ immediate after the "[%" (with no spaces in between). Although it
+ can be a handy way to temporarily "comment out" a whole block of
+ TT code, it's probably a little too subtle for use in "normal"
+ comments.
+%]
+</p>
Modified: trunk/examples/Tutorial/MyApp/root/src/message.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/message.tt2 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/src/message.tt2 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,16 +1,16 @@
-[% META title = 'Catalyst/TT View!' %]
-<p>
- Yay! You're looking at a page generated by the Catalyst::View::TT
- plugin module.
-</p>
-<p>
- We have a message for you: <span class="message">[% message %]</span>.
-</p>
-<p>
- Why not try updating the message? Go on, it's really exciting, honest!
-</p>
-<form action="[% site.url.message %]"
- method="POST" enctype="application/x-www-form-urlencoded">
- <input type="text" name="message" value="[% message %]" />
- <input type="submit" name="submit" value=" Update Message "/>
-</form>
+[% META title = 'Catalyst/TT View!' %]
+<p>
+ Yay! You're looking at a page generated by the Catalyst::View::TT
+ plugin module.
+</p>
+<p>
+ We have a message for you: <span class="message">[% message %]</span>.
+</p>
+<p>
+ Why not try updating the message? Go on, it's really exciting, honest!
+</p>
+<form action="[% site.url.message %]"
+ method="POST" enctype="application/x-www-form-urlencoded">
+ <input type="text" name="message" value="[% message %]" />
+ <input type="submit" name="submit" value=" Update Message "/>
+</form>
Modified: trunk/examples/Tutorial/MyApp/root/src/ttsite.css
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/ttsite.css 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/src/ttsite.css 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,45 +1,45 @@
-
-html {
- height: 100%;
-}
-
-body {
- background-color: [% site.col.page %];
- color: [% site.col.text %];
- margin: 0px;
- padding: 0px;
- height: 100%;
-}
-
-#header {
- background-color: [% site.col.head %];
- border-bottom: 1px solid [% site.col.line %];
-}
-
-#footer {
- background-color: [% site.col.head %];
- text-align: center;
- border-top: 1px solid [% site.col.line %];
- position: absolute;
- bottom: 0;
- left: 0px;
- width: 100%;
- padding: 4px;
-}
-
-#content {
- padding: 10px;
-}
-
-h1.title {
- padding: 4px;
- margin: 0px;
-}
-
-.message {
- color: [% site.col.message %];
-}
-
-.error {
- color: [% site.col.error %];
-}
+
+html {
+ height: 100%;
+}
+
+body {
+ background-color: [% site.col.page %];
+ color: [% site.col.text %];
+ margin: 0px;
+ padding: 0px;
+ height: 100%;
+}
+
+#header {
+ background-color: [% site.col.head %];
+ border-bottom: 1px solid [% site.col.line %];
+}
+
+#footer {
+ background-color: [% site.col.head %];
+ text-align: center;
+ border-top: 1px solid [% site.col.line %];
+ position: absolute;
+ bottom: 0;
+ left: 0px;
+ width: 100%;
+ padding: 4px;
+}
+
+#content {
+ padding: 10px;
+}
+
+h1.title {
+ padding: 4px;
+ margin: 0px;
+}
+
+.message {
+ color: [% site.col.message %];
+}
+
+.error {
+ color: [% site.col.error %];
+}
Modified: trunk/examples/Tutorial/MyApp/root/src/welcome.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/welcome.tt2 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/root/src/welcome.tt2 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,9 +1,9 @@
-[% META title = 'Catalyst/TT View!' %]
-<p>
- Yay! You're looking at a page generated by the Catalyst::View::TT
- plugin module.
-</p>
-<p>
- This is the welcome page. Why not try the equally-exciting
- <a href="[% site.url.message %]">Message Page</a>?
-</p>
+[% META title = 'Catalyst/TT View!' %]
+<p>
+ Yay! You're looking at a page generated by the Catalyst::View::TT
+ plugin module.
+</p>
+<p>
+ This is the welcome page. Why not try the equally-exciting
+ <a href="[% site.url.message %]">Message Page</a>?
+</p>
Modified: trunk/examples/Tutorial/MyApp/script/myapp_cgi.pl
===================================================================
--- trunk/examples/Tutorial/MyApp/script/myapp_cgi.pl 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/script/myapp_cgi.pl 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,37 +1,37 @@
-#!/usr/bin/perl -w
-
-BEGIN { $ENV{CATALYST_ENGINE} ||= 'CGI' }
-
-use strict;
-use warnings;
-use FindBin;
-use lib "$FindBin::Bin/../lib";
-use MyApp;
-
-MyApp->run;
-
-1;
-
-=head1 NAME
-
-myapp_cgi.pl - Catalyst CGI
-
-=head1 SYNOPSIS
-
-See L<Catalyst::Manual>
-
-=head1 DESCRIPTION
-
-Run a Catalyst application as a cgi script.
-
-=head1 AUTHOR
-
-Sebastian Riedel, C<sri at oook.de>
-
-=head1 COPYRIGHT
-
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
+#!/usr/bin/perl -w
+
+BEGIN { $ENV{CATALYST_ENGINE} ||= 'CGI' }
+
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use MyApp;
+
+MyApp->run;
+
+1;
+
+=head1 NAME
+
+myapp_cgi.pl - Catalyst CGI
+
+=head1 SYNOPSIS
+
+See L<Catalyst::Manual>
+
+=head1 DESCRIPTION
+
+Run a Catalyst application as a cgi script.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+
+=head1 COPYRIGHT
+
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Modified: trunk/examples/Tutorial/MyApp/script/myapp_create.pl
===================================================================
--- trunk/examples/Tutorial/MyApp/script/myapp_create.pl 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/script/myapp_create.pl 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,75 +1,75 @@
-#!/usr/bin/perl -w
-
-use strict;
-use warnings;
-use Getopt::Long;
-use Pod::Usage;
-use Catalyst::Helper;
-
-my $force = 0;
-my $mech = 0;
-my $help = 0;
-
-GetOptions(
- 'nonew|force' => \$force,
- 'mech|mechanize' => \$mech,
- 'help|?' => \$help
- );
-
-pod2usage(1) if ( $help || !$ARGV[0] );
-
-my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } );
-
-pod2usage(1) unless $helper->mk_component( 'MyApp', @ARGV );
-
-1;
-
-=head1 NAME
-
-myapp_create.pl - Create a new Catalyst Component
-
-=head1 SYNOPSIS
-
-myapp_create.pl [options] model|view|controller name [helper] [options]
-
- Options:
- -force don't create a .new file where a file to be created exists
- -mechanize use Test::WWW::Mechanize::Catalyst for tests if available
- -help display this help and exits
-
- Examples:
- myapp_create.pl controller My::Controller
- myapp_create.pl controller My::Controller BindLex
- myapp_create.pl -mechanize controller My::Controller
- myapp_create.pl view My::View
- myapp_create.pl view MyView TT
- myapp_create.pl view TT TT
- myapp_create.pl model My::Model
- myapp_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\
- dbi:SQLite:/tmp/my.db
- myapp_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\
- dbi:Pg:dbname=foo root 4321
-
- See also:
- perldoc Catalyst::Manual
- perldoc Catalyst::Manual::Intro
-
-=head1 DESCRIPTION
-
-Create a new Catalyst Component.
-
-Existing component files are not overwritten. If any of the component files
-to be created already exist the file will be written with a '.new' suffix.
-This behavior can be suppressed with the C<-force> option.
-
-=head1 AUTHOR
-
-Sebastian Riedel, C<sri at oook.de>
-Maintained by the Catalyst Core Team.
-
-=head1 COPYRIGHT
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use Catalyst::Helper;
+
+my $force = 0;
+my $mech = 0;
+my $help = 0;
+
+GetOptions(
+ 'nonew|force' => \$force,
+ 'mech|mechanize' => \$mech,
+ 'help|?' => \$help
+ );
+
+pod2usage(1) if ( $help || !$ARGV[0] );
+
+my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } );
+
+pod2usage(1) unless $helper->mk_component( 'MyApp', @ARGV );
+
+1;
+
+=head1 NAME
+
+myapp_create.pl - Create a new Catalyst Component
+
+=head1 SYNOPSIS
+
+myapp_create.pl [options] model|view|controller name [helper] [options]
+
+ Options:
+ -force don't create a .new file where a file to be created exists
+ -mechanize use Test::WWW::Mechanize::Catalyst for tests if available
+ -help display this help and exits
+
+ Examples:
+ myapp_create.pl controller My::Controller
+ myapp_create.pl controller My::Controller BindLex
+ myapp_create.pl -mechanize controller My::Controller
+ myapp_create.pl view My::View
+ myapp_create.pl view MyView TT
+ myapp_create.pl view TT TT
+ myapp_create.pl model My::Model
+ myapp_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\
+ dbi:SQLite:/tmp/my.db
+ myapp_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\
+ dbi:Pg:dbname=foo root 4321
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Create a new Catalyst Component.
+
+Existing component files are not overwritten. If any of the component files
+to be created already exist the file will be written with a '.new' suffix.
+This behavior can be suppressed with the C<-force> option.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Modified: trunk/examples/Tutorial/MyApp/script/myapp_fastcgi.pl
===================================================================
--- trunk/examples/Tutorial/MyApp/script/myapp_fastcgi.pl 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/script/myapp_fastcgi.pl 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,80 +1,80 @@
-#!/usr/bin/perl -w
-
-BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' }
-
-use strict;
-use warnings;
-use Getopt::Long;
-use Pod::Usage;
-use FindBin;
-use lib "$FindBin::Bin/../lib";
-use MyApp;
-
-my $help = 0;
-my ( $listen, $nproc, $pidfile, $manager, $detach, $keep_stderr );
-
-GetOptions(
- 'help|?' => \$help,
- 'listen|l=s' => \$listen,
- 'nproc|n=i' => \$nproc,
- 'pidfile|p=s' => \$pidfile,
- 'manager|M=s' => \$manager,
- 'daemon|d' => \$detach,
- 'keeperr|e' => \$keep_stderr,
-);
-
-pod2usage(1) if $help;
-
-MyApp->run(
- $listen,
- { nproc => $nproc,
- pidfile => $pidfile,
- manager => $manager,
- detach => $detach,
- keep_stderr => $keep_stderr,
- }
-);
-
-1;
-
-=head1 NAME
-
-myapp_fastcgi.pl - Catalyst FastCGI
-
-=head1 SYNOPSIS
-
-myapp_fastcgi.pl [options]
-
- Options:
- -? -help display this help and exits
- -l -listen Socket path to listen on
- (defaults to standard input)
- can be HOST:PORT, :PORT or a
- filesystem path
- -n -nproc specify number of processes to keep
- to serve requests (defaults to 1,
- requires -listen)
- -p -pidfile specify filename for pid file
- (requires -listen)
- -d -daemon daemonize (requires -listen)
- -M -manager specify alternate process manager
- (FCGI::ProcManager sub-class)
- or empty string to disable
- -e -keeperr send error messages to STDOUT, not
- to the webserver
-
-=head1 DESCRIPTION
-
-Run a Catalyst application as fastcgi.
-
-=head1 AUTHOR
-
-Sebastian Riedel, C<sri at oook.de>
-Maintained by the Catalyst Core Team.
-
-=head1 COPYRIGHT
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
+#!/usr/bin/perl -w
+
+BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' }
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use MyApp;
+
+my $help = 0;
+my ( $listen, $nproc, $pidfile, $manager, $detach, $keep_stderr );
+
+GetOptions(
+ 'help|?' => \$help,
+ 'listen|l=s' => \$listen,
+ 'nproc|n=i' => \$nproc,
+ 'pidfile|p=s' => \$pidfile,
+ 'manager|M=s' => \$manager,
+ 'daemon|d' => \$detach,
+ 'keeperr|e' => \$keep_stderr,
+);
+
+pod2usage(1) if $help;
+
+MyApp->run(
+ $listen,
+ { nproc => $nproc,
+ pidfile => $pidfile,
+ manager => $manager,
+ detach => $detach,
+ keep_stderr => $keep_stderr,
+ }
+);
+
+1;
+
+=head1 NAME
+
+myapp_fastcgi.pl - Catalyst FastCGI
+
+=head1 SYNOPSIS
+
+myapp_fastcgi.pl [options]
+
+ Options:
+ -? -help display this help and exits
+ -l -listen Socket path to listen on
+ (defaults to standard input)
+ can be HOST:PORT, :PORT or a
+ filesystem path
+ -n -nproc specify number of processes to keep
+ to serve requests (defaults to 1,
+ requires -listen)
+ -p -pidfile specify filename for pid file
+ (requires -listen)
+ -d -daemon daemonize (requires -listen)
+ -M -manager specify alternate process manager
+ (FCGI::ProcManager sub-class)
+ or empty string to disable
+ -e -keeperr send error messages to STDOUT, not
+ to the webserver
+
+=head1 DESCRIPTION
+
+Run a Catalyst application as fastcgi.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Modified: trunk/examples/Tutorial/MyApp/script/myapp_server.pl
===================================================================
--- trunk/examples/Tutorial/MyApp/script/myapp_server.pl 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/script/myapp_server.pl 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,111 +1,111 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- $ENV{CATALYST_ENGINE} ||= 'HTTP';
- $ENV{CATALYST_SCRIPT_GEN} = 30;
- require Catalyst::Engine::HTTP;
-}
-
-use strict;
-use warnings;
-use Getopt::Long;
-use Pod::Usage;
-use FindBin;
-use lib "$FindBin::Bin/../lib";
-
-my $debug = 0;
-my $fork = 0;
-my $help = 0;
-my $host = undef;
-my $port = $ENV{MYAPP_PORT} || $ENV{CATALYST_PORT} || 3000;
-my $keepalive = 0;
-my $restart = $ENV{MYAPP_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
-my $restart_delay = 1;
-my $restart_regex = '\.yml$|\.yaml$|\.pm$';
-my $restart_directory = undef;
-
-my @argv = @ARGV;
-
-GetOptions(
- 'debug|d' => \$debug,
- 'fork' => \$fork,
- 'help|?' => \$help,
- 'host=s' => \$host,
- 'port=s' => \$port,
- 'keepalive|k' => \$keepalive,
- 'restart|r' => \$restart,
- 'restartdelay|rd=s' => \$restart_delay,
- 'restartregex|rr=s' => \$restart_regex,
- 'restartdirectory=s' => \$restart_directory,
-);
-
-pod2usage(1) if $help;
-
-if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
- $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
-}
-if ( $debug ) {
- $ENV{CATALYST_DEBUG} = 1;
-}
-
-# This is require instead of use so that the above environment
-# variables can be set at runtime.
-require MyApp;
-
-MyApp->run( $port, $host, {
- argv => \@argv,
- 'fork' => $fork,
- keepalive => $keepalive,
- restart => $restart,
- restart_delay => $restart_delay,
- restart_regex => qr/$restart_regex/,
- restart_directory => $restart_directory,
-} );
-
-1;
-
-=head1 NAME
-
-myapp_server.pl - Catalyst Testserver
-
-=head1 SYNOPSIS
-
-myapp_server.pl [options]
-
- Options:
- -d -debug force debug mode
- -f -fork handle each request in a new process
- (defaults to false)
- -? -help display this help and exits
- -host host (defaults to all)
- -p -port port (defaults to 3000)
- -k -keepalive enable keep-alive connections
- -r -restart restart when files get modified
- (defaults to false)
- -rd -restartdelay delay between file checks
- -rr -restartregex regex match files that trigger
- a restart when modified
- (defaults to '\.yml$|\.yaml$|\.pm$')
- -restartdirectory the directory to search for
- modified files
- (defaults to '../')
-
- See also:
- perldoc Catalyst::Manual
- perldoc Catalyst::Manual::Intro
-
-=head1 DESCRIPTION
-
-Run a Catalyst Testserver for this application.
-
-=head1 AUTHOR
-
-Sebastian Riedel, C<sri at oook.de>
-Maintained by the Catalyst Core Team.
-
-=head1 COPYRIGHT
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
+#!/usr/bin/perl -w
+
+BEGIN {
+ $ENV{CATALYST_ENGINE} ||= 'HTTP';
+ $ENV{CATALYST_SCRIPT_GEN} = 30;
+ require Catalyst::Engine::HTTP;
+}
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+my $debug = 0;
+my $fork = 0;
+my $help = 0;
+my $host = undef;
+my $port = $ENV{MYAPP_PORT} || $ENV{CATALYST_PORT} || 3000;
+my $keepalive = 0;
+my $restart = $ENV{MYAPP_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
+my $restart_delay = 1;
+my $restart_regex = '\.yml$|\.yaml$|\.pm$';
+my $restart_directory = undef;
+
+my @argv = @ARGV;
+
+GetOptions(
+ 'debug|d' => \$debug,
+ 'fork' => \$fork,
+ 'help|?' => \$help,
+ 'host=s' => \$host,
+ 'port=s' => \$port,
+ 'keepalive|k' => \$keepalive,
+ 'restart|r' => \$restart,
+ 'restartdelay|rd=s' => \$restart_delay,
+ 'restartregex|rr=s' => \$restart_regex,
+ 'restartdirectory=s' => \$restart_directory,
+);
+
+pod2usage(1) if $help;
+
+if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
+ $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
+}
+if ( $debug ) {
+ $ENV{CATALYST_DEBUG} = 1;
+}
+
+# This is require instead of use so that the above environment
+# variables can be set at runtime.
+require MyApp;
+
+MyApp->run( $port, $host, {
+ argv => \@argv,
+ 'fork' => $fork,
+ keepalive => $keepalive,
+ restart => $restart,
+ restart_delay => $restart_delay,
+ restart_regex => qr/$restart_regex/,
+ restart_directory => $restart_directory,
+} );
+
+1;
+
+=head1 NAME
+
+myapp_server.pl - Catalyst Testserver
+
+=head1 SYNOPSIS
+
+myapp_server.pl [options]
+
+ Options:
+ -d -debug force debug mode
+ -f -fork handle each request in a new process
+ (defaults to false)
+ -? -help display this help and exits
+ -host host (defaults to all)
+ -p -port port (defaults to 3000)
+ -k -keepalive enable keep-alive connections
+ -r -restart restart when files get modified
+ (defaults to false)
+ -rd -restartdelay delay between file checks
+ -rr -restartregex regex match files that trigger
+ a restart when modified
+ (defaults to '\.yml$|\.yaml$|\.pm$')
+ -restartdirectory the directory to search for
+ modified files
+ (defaults to '../')
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Run a Catalyst Testserver for this application.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Modified: trunk/examples/Tutorial/MyApp/script/myapp_test.pl
===================================================================
--- trunk/examples/Tutorial/MyApp/script/myapp_test.pl 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/script/myapp_test.pl 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,54 +1,54 @@
-#!/usr/bin/perl -w
-
-use strict;
-use warnings;
-use Getopt::Long;
-use Pod::Usage;
-use FindBin;
-use lib "$FindBin::Bin/../lib";
-use Catalyst::Test 'MyApp';
-
-my $help = 0;
-
-GetOptions( 'help|?' => \$help );
-
-pod2usage(1) if ( $help || !$ARGV[0] );
-
-print request($ARGV[0])->content . "\n";
-
-1;
-
-=head1 NAME
-
-myapp_test.pl - Catalyst Test
-
-=head1 SYNOPSIS
-
-myapp_test.pl [options] uri
-
- Options:
- -help display this help and exits
-
- Examples:
- myapp_test.pl http://localhost/some_action
- myapp_test.pl /some_action
-
- See also:
- perldoc Catalyst::Manual
- perldoc Catalyst::Manual::Intro
-
-=head1 DESCRIPTION
-
-Run a Catalyst action from the command line.
-
-=head1 AUTHOR
-
-Sebastian Riedel, C<sri at oook.de>
-Maintained by the Catalyst Core Team.
-
-=head1 COPYRIGHT
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use Catalyst::Test 'MyApp';
+
+my $help = 0;
+
+GetOptions( 'help|?' => \$help );
+
+pod2usage(1) if ( $help || !$ARGV[0] );
+
+print request($ARGV[0])->content . "\n";
+
+1;
+
+=head1 NAME
+
+myapp_test.pl - Catalyst Test
+
+=head1 SYNOPSIS
+
+myapp_test.pl [options] uri
+
+ Options:
+ -help display this help and exits
+
+ Examples:
+ myapp_test.pl http://localhost/some_action
+ myapp_test.pl /some_action
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Run a Catalyst action from the command line.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Modified: trunk/examples/Tutorial/MyApp/t/01app.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/01app.t 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/t/01app.t 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,7 +1,7 @@
-use strict;
-use warnings;
-use Test::More tests => 2;
-
-BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
-
-ok( request('/login')->is_success, 'Request should succeed' );
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
+
+ok( request('/login')->is_success, 'Request should succeed' );
Modified: trunk/examples/Tutorial/MyApp/t/02pod.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/02pod.t 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/t/02pod.t 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,9 +1,9 @@
-use strict;
-use warnings;
-use Test::More;
-
-eval "use Test::Pod 1.14";
-plan skip_all => 'Test::Pod 1.14 required' if $@;
-plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-
-all_pod_files_ok();
+use strict;
+use warnings;
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => 'Test::Pod 1.14 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_files_ok();
Modified: trunk/examples/Tutorial/MyApp/t/03podcoverage.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/03podcoverage.t 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/t/03podcoverage.t 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,9 +1,9 @@
-use strict;
-use warnings;
-use Test::More;
-
-eval "use Test::Pod::Coverage 1.04";
-plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
-plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-
-all_pod_coverage_ok();
+use strict;
+use warnings;
+use Test::More;
+
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_coverage_ok();
Modified: trunk/examples/Tutorial/MyApp/t/controller_Books.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/controller_Books.t 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/t/controller_Books.t 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,10 +1,10 @@
-use strict;
-use warnings;
-use Test::More tests => 3;
-
-BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
-BEGIN { use_ok 'MyApp::Controller::Books' }
-
-ok( request('/books')->is_redirect, 'Request should succeed' );
-
-
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
+BEGIN { use_ok 'MyApp::Controller::Books' }
+
+ok( request('/books')->is_redirect, 'Request should succeed' );
+
+
Modified: trunk/examples/Tutorial/MyApp/t/controller_Login.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/controller_Login.t 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/t/controller_Login.t 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,10 +1,10 @@
-use strict;
-use warnings;
-use Test::More tests => 3;
-
-BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
-BEGIN { use_ok 'MyApp::Controller::Login' }
-
-ok( request('/login')->is_success, 'Request should succeed' );
-
-
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
+BEGIN { use_ok 'MyApp::Controller::Login' }
+
+ok( request('/login')->is_success, 'Request should succeed' );
+
+
Modified: trunk/examples/Tutorial/MyApp/t/controller_Logout.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/controller_Logout.t 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/t/controller_Logout.t 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,10 +1,10 @@
-use strict;
-use warnings;
-use Test::More tests => 3;
-
-BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
-BEGIN { use_ok 'MyApp::Controller::Logout' }
-
-ok( request('/logout')->is_redirect, 'Request should succeed' );
-
-
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
+BEGIN { use_ok 'MyApp::Controller::Logout' }
+
+ok( request('/logout')->is_redirect, 'Request should succeed' );
+
+
Modified: trunk/examples/Tutorial/MyApp/t/live_app01.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/live_app01.t 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/t/live_app01.t 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,103 +1,102 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-# Load testing framework and use 'no_plan' to dynamically pick up
-# all tests. Better to replace "'no_plan'" with "tests => 30" so it
-# knows exactly how many tests need to be run (and will tell you if
-# not), but 'no_plan' is nice for quick & dirty tests
-
-use Test::More 'no_plan';
-
-# Need to specify the name of your app as arg on next line
-# Can also do:
-# use Test::WWW::Mechanize::Catalyst "MyApp";
-
-use ok "Test::WWW::Mechanize::Catalyst" => "MyApp";
-
-# Create two 'user agents' to simulate two different users ('test01' & 'test02')
-my $ua1 = Test::WWW::Mechanize::Catalyst->new;
-my $ua2 = Test::WWW::Mechanize::Catalyst->new;
-
-# Use a simplified for loop to do tests that are common to both users
-# Use get_ok() to make sure we can hit the base URL
-# Second arg = optional description of test (will be displayed for failed tests)
-# Note that in test scripts you send everything to 'http://localhost'
-$_->get_ok("http://localhost/", "Check redirect of base URL") for $ua1, $ua2;
-# Use title_is() to check the contents of the <title>...</title> tags
-$_->title_is("Login", "Check for login title") for $ua1, $ua2;
-# Use content_contains() to match on text in the html body
-$_->content_contains("You need to log in to use this application",
- "Check we are NOT logged in") for $ua1, $ua2;
-
-# Log in as each user
-# Specify username and password on the URL
-$ua1->get_ok("http://localhost/login?username=test01&password=mypass", "Login 'test01'");
-# Use the form for user 'test02'; note there is no description here
-$ua2->submit_form(
- fields => {
- username => 'test02',
- password => 'mypass',
- });
-
-# Go back to the login page and it should show that we are already logged in
-$_->get_ok("http://localhost/login", "Return to '/login'") for $ua1, $ua2;
-$_->title_is("Login", "Check for login page") for $ua1, $ua2;
-$_->content_contains("Please Note: You are already logged in as ",
- "Check we ARE logged in" ) for $ua1, $ua2;
-
-# 'Click' the 'Logout' link (see also 'text_regex' and 'url_regex' options)
-$_->follow_link_ok({n => 1}, "Logout via first link on page") for $ua1, $ua2;
-$_->title_is("Login", "Check for login title") for $ua1, $ua2;
-$_->content_contains("You need to log in to use this application",
- "Check we are NOT logged in") for $ua1, $ua2;
-
-# Log back in
-$ua1->get_ok("http://localhost/login?username=test01&password=mypass", "Login 'test01'");
-$ua2->get_ok("http://localhost/login?username=test02&password=mypass", "Login 'test02'");
-# Should be at the Book List page... do some checks to confirm
-$_->title_is("Book List", "Check for book list title") for $ua1, $ua2;
-
-$ua1->get_ok("http://localhost/books/list", "'test01' book list");
-$ua1->get_ok("http://localhost/login", "Login Page");
-$ua1->get_ok("http://localhost/books/list", "'test01' book list");
-
-$_->content_contains("Book List", "Check for book list title") for $ua1, $ua2;
-# Make sure the appropriate logout buttons are displayed
-$_->content_contains("/logout\">Logout</a>",
- "Both users should have a 'User Logout'") for $ua1, $ua2;
-$ua1->content_contains("/books/form_create\">Create</a>",
- "Only 'test01' should have a create link");
-
-$ua1->get_ok("http://localhost/books/list", "View book list as 'test01'");
-
-# User 'test01' should be able to create a book with the "formless create" URL
-$ua1->get_ok("http://localhost/books/url_create/TestTitle/2/4",
- "'test01' formless create");
-$ua1->title_is("Book Created", "Book created title");
-$ua1->content_contains("Added book 'TestTitle'", "Check title added OK");
-$ua1->content_contains("by 'Stevens'", "Check author added OK");
-$ua1->content_contains("with a rating of 2.", "Check rating added");
-# Try a regular expression to combine the previous 3 checks & account for whitespace
-$ua1->content_like(qr/Added book 'TestTitle'\s+by 'Stevens'\s+with a rating of 2./, "Regex check");
-
-# Make sure the new book shows in the list
-$ua1->get_ok("http://localhost/books/list", "'test01' book list");
-$ua1->title_is("Book List", "Check logged in and at book list");
-$ua1->content_contains("Book List", "Book List page test");
-$ua1->content_contains("TestTitle", "Look for 'TestTitle'");
-
-# Make sure the new book can be deleted
-# Get all the Delete links on the list page
-my @delLinks = $ua1->find_all_links(text => 'Delete');
-# Use the final link to delete the last book
-$ua1->get_ok($delLinks[$#delLinks]->url, 'Delete last book');
-# Check that delete worked
-$ua1->content_contains("Book List", "Book List page test");
-$ua1->content_contains("Book deleted", "Book was deleted");
-
-# User 'test02' should not be able to add a book
-$ua2->get_ok("http://localhost/books/url_create/TestTitle2/2/5", "'test02' add");
-$ua2->content_contains("Unauthorized!", "Check 'test02' cannot add");
-
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+# Load testing framework and use 'no_plan' to dynamically pick up
+# all tests. Better to replace "'no_plan'" with "tests => 30" so it
+# knows exactly how many tests need to be run (and will tell you if
+# not), but 'no_plan' is nice for quick & dirty tests
+
+use Test::More 'no_plan';
+
+# Need to specify the name of your app as arg on next line
+# Can also do:
+# use Test::WWW::Mechanize::Catalyst "MyApp";
+
+use ok "Test::WWW::Mechanize::Catalyst" => "MyApp";
+
+# Create two 'user agents' to simulate two different users ('test01' & 'test02')
+my $ua1 = Test::WWW::Mechanize::Catalyst->new;
+my $ua2 = Test::WWW::Mechanize::Catalyst->new;
+
+# Use a simplified for loop to do tests that are common to both users
+# Use get_ok() to make sure we can hit the base URL
+# Second arg = optional description of test (will be displayed for failed tests)
+# Note that in test scripts you send everything to 'http://localhost'
+$_->get_ok("http://localhost/", "Check redirect of base URL") for $ua1, $ua2;
+# Use title_is() to check the contents of the <title>...</title> tags
+$_->title_is("Login", "Check for login title") for $ua1, $ua2;
+# Use content_contains() to match on text in the html body
+$_->content_contains("You need to log in to use this application",
+ "Check we are NOT logged in") for $ua1, $ua2;
+
+# Log in as each user
+# Specify username and password on the URL
+$ua1->get_ok("http://localhost/login?username=test01&password=mypass", "Login 'test01'");
+# Use the form for user 'test02'; note there is no description here
+$ua2->submit_form(
+ fields => {
+ username => 'test02',
+ password => 'mypass',
+ });
+
+# Go back to the login page and it should show that we are already logged in
+$_->get_ok("http://localhost/login", "Return to '/login'") for $ua1, $ua2;
+$_->title_is("Login", "Check for login page") for $ua1, $ua2;
+$_->content_contains("Please Note: You are already logged in as ",
+ "Check we ARE logged in" ) for $ua1, $ua2;
+
+# 'Click' the 'Logout' link (see also 'text_regex' and 'url_regex' options)
+$_->follow_link_ok({n => 1}, "Logout via first link on page") for $ua1, $ua2;
+$_->title_is("Login", "Check for login title") for $ua1, $ua2;
+$_->content_contains("You need to log in to use this application",
+ "Check we are NOT logged in") for $ua1, $ua2;
+
+# Log back in
+$ua1->get_ok("http://localhost/login?username=test01&password=mypass", "Login 'test01'");
+$ua2->get_ok("http://localhost/login?username=test02&password=mypass", "Login 'test02'");
+# Should be at the Book List page... do some checks to confirm
+$_->title_is("Book List", "Check for book list title") for $ua1, $ua2;
+
+$ua1->get_ok("http://localhost/books/list", "'test01' book list");
+$ua1->get_ok("http://localhost/login", "Login Page");
+$ua1->get_ok("http://localhost/books/list", "'test01' book list");
+
+$_->content_contains("Book List", "Check for book list title") for $ua1, $ua2;
+# Make sure the appropriate logout buttons are displayed
+$_->content_contains("/logout\">Logout</a>",
+ "Both users should have a 'User Logout'") for $ua1, $ua2;
+$ua1->content_contains("/books/form_create\">Create</a>",
+ "Only 'test01' should have a create link");
+
+$ua1->get_ok("http://localhost/books/list", "View book list as 'test01'");
+
+# User 'test01' should be able to create a book with the "formless create" URL
+$ua1->get_ok("http://localhost/books/url_create/TestTitle/2/4",
+ "'test01' formless create");
+$ua1->title_is("Book Created", "Book created title");
+$ua1->content_contains("Added book 'TestTitle'", "Check title added OK");
+$ua1->content_contains("by 'Stevens'", "Check author added OK");
+$ua1->content_contains("with a rating of 2.", "Check rating added");
+# Try a regular expression to combine the previous 3 checks & account for whitespace
+$ua1->content_like(qr/Added book 'TestTitle'\s+by 'Stevens'\s+with a rating of 2./, "Regex check");
+
+# Make sure the new book shows in the list
+$ua1->get_ok("http://localhost/books/list", "'test01' book list");
+$ua1->title_is("Book List", "Check logged in and at book list");
+$ua1->content_contains("Book List", "Book List page test");
+$ua1->content_contains("TestTitle", "Look for 'TestTitle'");
+
+# Make sure the new book can be deleted
+# Get all the Delete links on the list page
+my @delLinks = $ua1->find_all_links(text => 'Delete');
+# Use the final link to delete the last book
+$ua1->get_ok($delLinks[$#delLinks]->url, 'Delete last book');
+# Check that delete worked
+$ua1->content_contains("Book List", "Book List page test");
+$ua1->content_contains("Book deleted", "Book was deleted");
+
+# User 'test02' should not be able to add a book
+$ua2->get_ok("http://localhost/books/url_create/TestTitle2/2/5", "'test02' add");
+$ua2->content_contains("Unauthorized!", "Check 'test02' cannot add");
Added: trunk/examples/Tutorial/MyApp/t/model_DB.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/model_DB.t (rev 0)
+++ trunk/examples/Tutorial/MyApp/t/model_DB.t 2008-05-26 12:20:53 UTC (rev 7797)
@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'MyApp::Model::DB' }
+
Deleted: trunk/examples/Tutorial/MyApp/t/model_MyAppDB.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/model_MyAppDB.t 2008-05-26 12:08:41 UTC (rev 7796)
+++ trunk/examples/Tutorial/MyApp/t/model_MyAppDB.t 2008-05-26 12:20:53 UTC (rev 7797)
@@ -1,6 +0,0 @@
-use strict;
-use warnings;
-use Test::More tests => 1;
-
-BEGIN { use_ok 'MyApp::Model::MyAppDB' }
-
More information about the Catalyst-commits
mailing list