document $c->detach with no args
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Manual / Cookbook.pod
index 400d589..24a515b 100644 (file)
@@ -1,4 +1,4 @@
-=head1 NAME
+S=head1 NAME
 
 Catalyst::Manual::Cookbook - Cooking with Catalyst
 
@@ -205,6 +205,28 @@ This is equivalent to:
 
 See also L<YAML>.
 
+=head1 Skipping your VCS's directories
+
+Catalyst uses Module::Pluggable to load Models, Views and Controllers.
+Module::Pluggable will scan through all directories and load modules
+it finds.  Sometimes you might want to skip some of these directories,
+for example when your version control system makes a subdirectory with
+meta-information in every version-controlled directory.  While
+Catalyst skips subversion and CVS directories already, there are other
+source control systems.  Here is the configuration you need to add
+their directories to the list to skip.
+
+You can make catalyst skip these directories using the Catalyst config:
+
+  # Configure the application
+  __PACKAGE__->config(
+      name => 'MyApp',
+      setup_components => { except => qr/SCCS/ },
+  );
+
+See the Module::Pluggable manual page for more information on B<except>
+and other options.
+
 =head1 Users and Access Control
 
 Most multiuser, and some single user web applications require that
@@ -573,12 +595,6 @@ C<default>, etc will also be restricted.
 will create rules that permit access to C<end>, C<begin>, and C<auto> in the
 root of your app (but not in any other controller).
 
-=head1 COPYRIGHT
-
-This program is free software, you can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-
 =head1 Models
 
 Models are where application data belongs.  Catalyst is exteremely
@@ -997,6 +1013,45 @@ variable, so you can generate Atom feeds with the same code.
 Now, go ahead and make RSS feeds for all your stuff. The world *needs*
 updates on your goldfish!
 
+=head2 Forcing the browser to download content
+Sometimes you need your application to send content for download. For
+example, you can generate a comma-separated values (CSV) file for your
+users to download and import into their spreadsheet program.
+Let's say you have an C<Orders> controller which generates a CSV file
+in the C<export> action (i.e., C<http://localhost:3000/orders/export>):
+
+    sub export : Local Args(0) {
+        my ( $self, $c ) = @_;
+
+        # In a real application, you'd generate this from the database
+        my $csv = "1,5.99\n2,29.99\n3,3.99\n";
+
+        $c->res->content_type('text/comma-separated-values');
+        $c->res->body($csv);
+    }
+
+Normally the browser uses the last part of the URI to generate a
+filename for data it cannot display. In this case your browser would
+likely ask you to save a file named C<export>.
+
+Luckily you can have the browser download the content with a specific
+filename by setting the C<Content-Disposition> header:
+
+    my $filename = 'Important Orders.csv';
+    $c->res->header('Content-Disposition', qq[attachment; filename="$filename"]);
+
+Note the use of quotes around the filename; this ensures that any
+spaces in the filename are handled by the browser.
+
+Put this right before calling C<< $c->res->body >> and your browser
+will download a file named C<Important Orders.csv> instead of
+C<export>.
+
+You can also use this to have the browser download content which it
+normally displays, such as JPEG images or even HTML. Just be sure to
+set the appropriate content type and disposition.
 
 
 =head1 Controllers
@@ -1357,13 +1412,11 @@ including web server engines and tips to improve application efficiency.
 
 =head2 mod_perl Deployment
 
-=head3 Pros & Cons
-
-mod_perl is the best solution for many applications, but I'll list some pros
+mod_perl is the best solution for many applications, but we'll list some pros
 and cons so you can decide for yourself.  The other production deployment
-option is FastCGI, which I'll talk about in a future calendar article.
+option is FastCGI, for which see below.
 
-=head4 Pros
+=head3 Pros
 
 =head4 Speed
 
@@ -1375,7 +1428,7 @@ within each Apache process.
 If you need to run several Catalyst apps on the same server, mod_perl will
 share the memory for common modules.
 
-=head4 Cons
+=head3 Cons
 
 =head4 Memory usage
 
@@ -2217,13 +2270,28 @@ L<http://search.cpan.org/perldoc?Catalyst::Plugin::Authorization::ACL>
 
 =head1 AUTHORS
 
-Sebastian Riedel, C<sri@oook.de>
-Danijel Milicevic, C<me@danijel.de>
-Viljo Marrandi, C<vilts@yahoo.com>  
-Marcus Ramberg, C<mramberg@cpan.org>
-Jesse Sheidlower, C<jester@panix.com>
-Andy Grundman, C<andy@hybridized.org> 
-Chisel Wright, C<pause@herlpacker.co.uk>
-Will Hawes, C<info@whawes.co.uk>
-Gavin Henry, C<ghenry@perl.me.uk>
+Sebastian Riedel C<sri@oook.de>
+
+Danijel Milicevic C<me@danijel.de>
+
+Viljo Marrandi C<vilts@yahoo.com>  
+
+Marcus Ramberg C<mramberg@cpan.org>
+
+Jesse Sheidlower C<jester@panix.com>
+
+Andy Grundman C<andy@hybridized.org> 
+
+Chisel Wright C<pause@herlpacker.co.uk>
+
+Will Hawes C<info@whawes.co.uk>
+
+Gavin Henry C<ghenry@perl.me.uk>
+
 Kieren Diment C<kd@totaldatasolution.com>
+
+=head1 COPYRIGHT
+
+This document is free, you can redistribute it and/or modify it
+under the same terms as Perl itself.
+