[Catalyst-commits] r8920 - trunk/examples/CatalystAdvent/root/2008/pen

zarquon at dev.catalyst.perl.org zarquon at dev.catalyst.perl.org
Thu Dec 18 21:32:56 GMT 2008


Author: zarquon
Date: 2008-12-18 21:32:55 +0000 (Thu, 18 Dec 2008)
New Revision: 8920

Modified:
   trunk/examples/CatalystAdvent/root/2008/pen/WrapCGI.pod
Log:
edits

Modified: trunk/examples/CatalystAdvent/root/2008/pen/WrapCGI.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2008/pen/WrapCGI.pod	2008-12-18 21:17:32 UTC (rev 8919)
+++ trunk/examples/CatalystAdvent/root/2008/pen/WrapCGI.pod	2008-12-18 21:32:55 UTC (rev 8920)
@@ -1,13 +1,18 @@
 =head1 WrapCGI: CGI.pm in your Catalyst app.
 
-L<Catalyst::Controller::WrapCGI> allows you to use CGI.pm directly in your Catalyst controller.
+L<Catalyst::Controller::WrapCGI> allows you to use CGI.pm directly in
+your Catalyst controller.
 
-A huge benefit of this is quick porting of a legacy CGI.pm application directly into a Catalyst skeleton
-in an almost cut and paste fashion.  You B<still> have the full power of the Catalyst framework and you don't lose
-any of your CGI application's functionality.
+A huge benefit of this is quick porting of a legacy CGI.pm application
+directly into a Catalyst skeleton in an almost cut and paste fashion.
+You B<still> have the full power of the Catalyst framework and you
+don't lose any of your CGI application's functionality.
 
 
-To demonstrate a quick WrapCGI application, we're going to write a pastebot using WrapCGI, Acme::Bleach (to keep our code clean :-) ) and for giggles, translate our application's output with Catalyst::Plugin::Acme::LOLCAT.
+To demonstrate a quick WrapCGI application, we're going to write a
+pastebot using WrapCGI, Acme::Bleach (to keep our code clean :-) ) and
+for giggles, translate our application's output with
+Catalyst::Plugin::Acme::LOLCAT.
 
 =head2 Packing list
 
@@ -27,13 +32,18 @@
 
 =head2 Getting Started
 
-This article assumes you are familiar with creating a Catalyst application skeleton, so we're going to skip that part in this article.
+This article assumes you are familiar with creating a Catalyst
+application skeleton, so we're going to skip that part in this
+article.
 
-Your first step (after creating your application) is to create a controller called Paste.  You should also know how to do this, but for the sake of sanity, here's what it looks like:
+Your first step (after creating your application) is to create a
+controller called Paste.  You should also know how to do this, but for
+the sake of sanity, here's what it looks like:
 
     perl script/myapp_create.pl controller Paste
 
-Next, open up this new controller in your favorite text editor and add the following lines:
+Next, open up this new controller in your favorite text editor and add
+the following lines:
 
     use Moose;
     use parent 'Catalyst::Controller::WrapCGI';
@@ -42,55 +52,59 @@
 
     has 'cgi' => (is =>'rw', isa =>'CGI', default => sub { CGI->new });
 
-If you're not familiar with Moose at all, you should get to be :-).  All this line is saying is "create an accessor called 'cgi' that when called with $self->cgi defaults to an anonymous sub that creates a new CGI object".  Easy as pie :-)
+If you're not familiar with Moose at all, you should get to be :-).
+All this line is saying is "create an accessor called 'cgi' that when
+called with $self->cgi defaults to an anonymous sub that creates a new
+CGI object".  Easy as pie :-)
 
-Add the following lines to your controller after you've absorbed up to here:
+Add the following lines to your controller after you've absorbed up to
+here:
 
-sub index :Path('/cgi-bin/paste.cgi')  {
-    my ( $self, $c ) = @_;
-    my $q = $self->cgi;
-    $self->cgi_to_response( $c, sub {  
-        
-        print $q->header, $q->start_html('Clean your code!'),
-              $q->h1('Paste your code here'),
-              $q->start_form(
-                 -name   => 'paste',
-                 -action => $c->uri_for('/cgi-bin/bleachit.cgi'),              
-              ),
-              $q->textarea (
-                -name => 'code',
-                -rows => '10',
-                -cols => '80'
-              ),
-              $q->br,
-              $q->submit(
-                -name    => 'translate',
-                -value   => 'Paste it!',
-              ),
-              $q->end_form,
-              $q->end_html;
-    });
+ sub index :Path('/cgi-bin/paste.cgi')  {
+     my ( $self, $c ) = @_;
+     my $q = $self->cgi;
+     $self->cgi_to_response( $c, sub {  
 
-}
+         print $q->header, $q->start_html('Clean your code!'),
+               $q->h1('Paste your code here'),
+               $q->start_form(
+                  -name   => 'paste',
+                  -action => $c->uri_for('/cgi-bin/bleachit.cgi'),
+               ),
+               $q->textarea (
+                 -name => 'code',
+                 -rows => '10',
+                 -cols => '80'
+               ),
+               $q->br,
+               $q->submit(
+                 -name    => 'translate',
+                 -value   => 'Paste it!',
+               ),
+               $q->end_form,
+               $q->end_html;
+     });
 
-sub paste : Path("/cgi-bin/bleachit.cgi") {
-    my ($self, $c) = @_;
-    my $q = $self->cgi;
+ }
 
-    $self->cgi_to_response( $c, sub {  
-        
-        my $code = $q->param('code');
-        my $cleaned_string = eval "use Acme::Bleach; $code" . "";
- 
-        print $q->header, $q->start_html('Cleaned code'),
-        $q->h1("Your code, cleaned:"),
-        $q->pre($cleaned_string),
-        $q->end_html;
-    });
+ sub paste : Path("/cgi-bin/bleachit.cgi") {
+     my ($self, $c) = @_;
+     my $q = $self->cgi;
 
-}
+     $self->cgi_to_response( $c, sub {
 
+         my $code = $q->param('code');
+         my $cleaned_string = eval "use Acme::Bleach; $code" . "";
+  
+         print $q->header, $q->start_html('Cleaned code'),
+         $q->h1("Your code, cleaned:"),
+         $q->pre($cleaned_string),
+         $q->end_html;
+     });
 
+ }
+
+
 That's *it*.  That's how WrapCGI integrates CGI into Catalyst.  
 
 Tada!




More information about the Catalyst-commits mailing list