From: Kennedy Clark Date: Tue, 3 Mar 2009 01:19:03 +0000 (+0000) Subject: Suggestions and fixes with thanks to Murray Walker (along with a few other minor... X-Git-Tag: v5.8005~196 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=commitdiff_plain;h=1435672d3f51326b8f15006abcfe98180e89becb Suggestions and fixes with thanks to Murray Walker (along with a few other minor adjustments) --- diff --git a/Changes b/Changes index 254ae59..73a0a84 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Catalyst-Manual +5.7XXX + - Suggestions and fixes with thanks to Murray Walker + - Misc updates and fixes + 5.7017 28 Feb 2009 - Main change = adding Chained dispatch starting in BasicCRUD (Part 4) - Add some "getting started" links to the Catalyst::Manual page diff --git a/lib/Catalyst/Manual/Tutorial.pod b/lib/Catalyst/Manual/Tutorial.pod index 6d914a5..38c6145 100644 --- a/lib/Catalyst/Manual/Tutorial.pod +++ b/lib/Catalyst/Manual/Tutorial.pod @@ -11,7 +11,7 @@ commonly used features while focusing on real-world best practices. The tutorial is divided into the following sections: -B CLICK THESE LINKS TO JUMP TO CHAPTERS (the index links above +B (the index links above only navigate inside this page). =over 4 @@ -604,13 +604,14 @@ PostgreSQL content in the Appendix. =item * People who have emailed me with corrections and suggestions on the -tutorial. As of the most recent release, this include: Florian Ragwitz, -Mauro Andreolini, Jim Howard, Giovanni Gigante, William Moreno, Bryan -Roach, Ashley Berlin, David Kamholz, Kevin Old, Henning Sprang, Jeremy -Jones, David Kurtz, Ingo Wichmann, and Shlomi Fish. Also, thanks to -Devin Austin for coming up with an initial version of a non-TTSite -wrapper page. I'm sure I am missing some names here... apologies for -that (please let me know if you name should be here). +tutorial. As of the most recent release, this include: Florian +Ragwitz, Mauro Andreolini, Jim Howard, Giovanni Gigante, William +Moreno, Bryan Roach, Ashley Berlin, David Kamholz, Kevin Old, Henning +Sprang, Jeremy Jones, David Kurtz, Ingo Wichmann, Shlomi Fish, Murray +Walker. Also, thanks to Devin Austin for coming up with an initial +version of a non-TTSite wrapper page. I'm sure I am missing some +names here... apologies for that (please let me know if you name +should be here). =back diff --git a/lib/Catalyst/Manual/Tutorial/Authentication.pod b/lib/Catalyst/Manual/Tutorial/Authentication.pod index 0410643..be80e98 100644 --- a/lib/Catalyst/Manual/Tutorial/Authentication.pod +++ b/lib/Catalyst/Manual/Tutorial/Authentication.pod @@ -158,7 +158,7 @@ C: # 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 + # 3) Column name in *foreign* table (aka, foreign key in peer table) __PACKAGE__->has_many(map_user_role => 'MyApp::Schema::UserRoles', 'user_id'); # many_to_many(): @@ -180,7 +180,7 @@ C: # 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 + # 3) Column name in *foreign* table (aka, foreign key in peer table) __PACKAGE__->has_many(map_user_role => 'MyApp::Schema::UserRoles', 'role_id'); diff --git a/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod index 1de9f96..b288293 100644 --- a/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod @@ -220,8 +220,7 @@ server: [info] Hello powered by Catalyst 5.7014 You can connect to your server at http://localhost:3000 -Point your web browser to -L (substituting a +Point your web browser to L (substituting a different hostname or IP address as appropriate) and you should be greeted by the Catalyst welcome screen. Information similar to the following should be appended to the logging output of the development @@ -323,13 +322,28 @@ To create a TT view, run: $ script/hello_create.pl view TT TT This creates the C module, which is a subclass of -C. The "view" keyword tells the create script that -you are creating a view, the second "TT" tells it that you are creating -a Template Toolkit view, and the first "TT" tells the script to name -the View module "TT.pm", which is a commonly used name for TT views. -(You can name it anything you want, such as "HTML.pm".) If you look at -TT.pm, you will find that it only contains a config statement to set -the TT extension to ".tt". +C. + +=over 4 + +=item * + +The "view" keyword tells the create script that you are creating a view. + +=item * + +The first "TT" tells the script to name the View module "TT.pm", which is a +commonly used name for TT views. (You can name it anything you want, such as +"HTML.pm".) + +=item * + +The final "TT" tells it that you are creating a Template Toolkit view. + +=back + +If you look at C you will find that it only contains a +config statement to set the TT extension to ".tt". Now that the TT.pm "View" exists, Catalyst will autodiscover it and be able to use it to display the view templates, using the "process" @@ -345,15 +359,17 @@ Create a C template file (put it in the C under the C directory that is the base of your application). Here is a simple sample: - [% META title = 'Hello, World!' %]

- This is a TT view template, located in the 'root/' directory. + This is a TT view template, called '[% template.name %]'.

[% and %] are markers for the TT parts of the template. Inside you can -access Perl variables and classes, and use TT directives. The rest of -the template is normal HTML. Change the hello method in -C to the following: +access Perl variables and classes, and use TT directives. In this +case, we're using a special TT variable that defines the name of the +template file (C). The rest of the template is normal HTML. + +Change the hello method in C to the +following: sub hello : Global { my ( $self, $c ) = @_; @@ -361,13 +377,13 @@ C to the following: $c->stash->{template} = 'hello.tt'; } -This time, instead of doing C<$c-Eresponse->body()>, you are setting +This time, instead of doing C<$c-Eresponse-Ebody()>, you are setting the value of the "template" hash key in the Catalyst "stash", an area for putting information to share with other parts of your application. The "template" key determines which template will be displayed at the end of the method. Catalyst controllers have a default "end" action for all methods which causes the first (or default) view to be -rendered (unless there's a C<$c-Eresponse->body()> statement). So your +rendered (unless there's a C<$c-Eresponse-Ebody()> statement). So your template will be magically displayed at the end of your method. After saving the file, restart the development server, and look at @@ -395,16 +411,23 @@ In C, add the following method: $c->stash->{template} = 'site/test.tt'; } -Notice the "Local" attribute on the method. This will allow the action -to be executed on the "controller/method" URL, or, in this case, -"site/test", instead of at the root site URL, like "Global". It's not -actually necessary to set the template value, since by default TT will -attempt to render a template that follows the naming pattern -"controller/method.tt", and we're following that pattern here, but in -other situations you will need to specify the template (such as if -you've "forwarded" to the method, or if it doesn't follow the default -naming convention). We've also put the variable "name" into the stash, -for use in the template. +Notice the "Local" attribute on the C method. This will cause +the C action (now that we have assigned an action type to the +method it appears as a controller "action" to Catalyst) to be executed +on the "controller/method" URL, or, in this case, "site/test". We +will see additional information on controller actions throughout the +rest of the tutorial, but if you are curious take a look at +L. + +It's not actually necessary to set the template value as we do here. +By default TT will attempt to render a template that follows the +naming pattern "controller/method.tt", and we're following that +pattern here. However, in other situations you will need to specify +the template (such as if you've "forwarded" to the method, or if it +doesn't follow the default naming convention). + +We've also put the variable "username" into the stash, for use in the +template. Make a subdirectory "site" in the "root" directory. Copy the hello.tt file into the directory as C, or create a new diff --git a/lib/Catalyst/Manual/Tutorial/Intro.pod b/lib/Catalyst/Manual/Tutorial/Intro.pod index fdce808..0454a3a 100644 --- a/lib/Catalyst/Manual/Tutorial/Intro.pod +++ b/lib/Catalyst/Manual/Tutorial/Intro.pod @@ -383,7 +383,7 @@ NetBSD Package Collection on Solaris The 2008 Advent Day 15 entry has more information on using C and NetBSD packages on Solaris: -L. +L. =item * diff --git a/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod index 8c1734e..24c9157 100644 --- a/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod @@ -140,20 +140,21 @@ very similar to Apache configuration files. We will see how to use this feature of Catalyst during the authentication and authorization sections (Part 5 and Part 6). -B If you are using a version of -L prior to version 1.06, you need to -be aware that Catalyst changed from a default format of YAML to the -more straightforward C format. This tutorial use the -newer C configuration file for C instead -of C for YAML. However, Catalyst has long supported both -formats and Catalyst will automatically use either C or -C (or any other format supported by -L and -L). If you are using a versions of -Catalyst::Devel prior to 1.06, you can convert to the newer format by -simply creating the C file manually and deleting -C. The default contents of C should only -consist of one line: C. +B If you are using a version of +L prior to version 1.06, be aware +that Catalyst changed the default format from YAML to the more +straightforward C style. This tutorial uses the +newer C file for C. However, Catalyst +supports both formats and will automatically use either C +or C (or any other format supported by +L and +L). If you are using a version of +Catalyst::Devel prior to 1.06, you can convert to the newer format by +simply creating the C file manually and deleting +C. The default contents of the C you create +should only consist of one line: + + name MyApp B: This script can be useful for converting between configuration formats: @@ -161,10 +162,6 @@ formats: perl -Ilib -e 'use MyApp; use Config::General; Config::General->new->save_file("myapp.conf", MyApp->config);' -B The default C should look like: - - name MyApp - =item * L @@ -664,19 +661,37 @@ starts: created "/home/me/MyApp/script/../t/model_DB.t" +The C