[Catalyst-commits] r13786 - in
trunk/examples/CatalystAdvent/root/2010: . pen
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Mon Dec 6 07:56:47 GMT 2010
Author: caelum
Date: 2010-12-06 07:56:47 +0000 (Mon, 06 Dec 2010)
New Revision: 13786
Added:
trunk/examples/CatalystAdvent/root/2010/pen/6.pod
Removed:
trunk/examples/CatalystAdvent/root/2010/6.pod
Log:
move article out of the way so it can be picked up again
Deleted: trunk/examples/CatalystAdvent/root/2010/6.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2010/6.pod 2010-12-06 07:41:55 UTC (rev 13785)
+++ trunk/examples/CatalystAdvent/root/2010/6.pod 2010-12-06 07:56:47 UTC (rev 13786)
@@ -1,105 +0,0 @@
-=head1 Adding Simple Excel Support
-
-In this example I will expand on my
-L<last year's advent article|http://www.catalystframework.org/calendar/2009/22>
-on AJAX grids by adding a button to download the book list as an Excel
-spreadsheet.
-
-The complete tarball for this example is
-L<here|http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter9_flexigrid.tar.gz>.
-
-We'll use
-L<this module|http://search.cpan.org/perldoc?Catalyst::Action::Serialize::SimpleExcel>
-to create the Excel spreadsheets.
-
-=head1 The Button
-
-First we need a suitable Excel icon, find one and put it into your
-C<root/static/images> directory. I used
-L<this one|http://www.nc-sco.com/images/excel-icon-small.gif>.
-
-Insert standard disclaimer about not using other people's art without
-permission.
-
-Add the style for the button in the C<< <style> >> section of
-C<root/src/ajax.tt>, like so:
-
- .flexigrid div.fbutton .excel
- {
- background: url([% c.uri_for('/static/images/excel-icon-small.gif') %]) no-repeat center left;
- }
-
-Add the button in the C<buttons> section of the flexigrid:
-
- {name: 'Excel', bclass: 'excel', onpress : export_to_excel},
-
-Now we'll write the javascript, as specified in the
-L<synopsis|http://search.cpan.org/perldoc?Catalyst::Action::Serialize::SimpleExcel#SYNOPSIS>.
-
- function export_to_excel(button, grid) {
- $('<iframe '
- +'src="/api/books?content-type=application%2Fvnd.ms-excel">')
- .hide().appendTo('body');
- }
-
-This initiates the file download.
-
-=head2 The Serializer
-
-The serializer is much like any other serializer you would write. It goes into
-the API controller.
-
-At the top, put:
-
- use POSIX ();
-
- __PACKAGE__->config->{map}{'application/vnd.ms-excel'} = 'SimpleExcel';
-
-Then the action:
-
- sub books : Local ActionClass('REST') {}
-
- sub books_GET {
- my ($self, $c) = @_;
-
- my $rs = $c->model('DB::Book')->search({}, {
- order_by => ['title']
- });
-
- my @rows = map {
- [ $_->id, $_->title, $_->rating, $_->author_list ]
- } $rs->all;
-
- my $entity = {
- header => ['ID', 'Title', 'Rating', 'Authors'],
- rows => \@rows,
- filename => 'books-'.POSIX::strftime('%m-%d-%Y', localtime)
- };
-
- $self->status_ok(
- $c,
- entity => $entity
- );
- }
-
-=head2 Try it out
-
-Start the server with C<script/myapp_server.pl>.
-
-In your browser, open L<http://localhost:3000/ajax>. You will see the books
-grid, click on the excel icon and you should get a file download prompt for the
-Excel file, open it with Excel or OpenOffice.
-
-=head2 TODO
-
-We need an Excel deserializer, so that users can edit the downloaded Excel
-sheets and upload them back. It would also be nice if the ID column was
-highlighted and locked against editing.
-
-If you have any interest in these things, or in working on them, please email
-me, my email is at the bottom. Patches most certainly welcome as well.
-
-=head1 AUTHOR
-
-Caelum: Rafael Kitover <rkitover at cpan.org>
-
Copied: trunk/examples/CatalystAdvent/root/2010/pen/6.pod (from rev 13785, trunk/examples/CatalystAdvent/root/2010/6.pod)
===================================================================
--- trunk/examples/CatalystAdvent/root/2010/pen/6.pod (rev 0)
+++ trunk/examples/CatalystAdvent/root/2010/pen/6.pod 2010-12-06 07:56:47 UTC (rev 13786)
@@ -0,0 +1,105 @@
+=head1 Adding Simple Excel Support
+
+In this example I will expand on my
+L<last year's advent article|http://www.catalystframework.org/calendar/2009/22>
+on AJAX grids by adding a button to download the book list as an Excel
+spreadsheet.
+
+The complete tarball for this example is
+L<here|http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial/MyApp_Chapter9_flexigrid.tar.gz>.
+
+We'll use
+L<this module|http://search.cpan.org/perldoc?Catalyst::Action::Serialize::SimpleExcel>
+to create the Excel spreadsheets.
+
+=head1 The Button
+
+First we need a suitable Excel icon, find one and put it into your
+C<root/static/images> directory. I used
+L<this one|http://www.nc-sco.com/images/excel-icon-small.gif>.
+
+Insert standard disclaimer about not using other people's art without
+permission.
+
+Add the style for the button in the C<< <style> >> section of
+C<root/src/ajax.tt>, like so:
+
+ .flexigrid div.fbutton .excel
+ {
+ background: url([% c.uri_for('/static/images/excel-icon-small.gif') %]) no-repeat center left;
+ }
+
+Add the button in the C<buttons> section of the flexigrid:
+
+ {name: 'Excel', bclass: 'excel', onpress : export_to_excel},
+
+Now we'll write the javascript, as specified in the
+L<synopsis|http://search.cpan.org/perldoc?Catalyst::Action::Serialize::SimpleExcel#SYNOPSIS>.
+
+ function export_to_excel(button, grid) {
+ $('<iframe '
+ +'src="/api/books?content-type=application%2Fvnd.ms-excel">')
+ .hide().appendTo('body');
+ }
+
+This initiates the file download.
+
+=head2 The Serializer
+
+The serializer is much like any other serializer you would write. It goes into
+the API controller.
+
+At the top, put:
+
+ use POSIX ();
+
+ __PACKAGE__->config->{map}{'application/vnd.ms-excel'} = 'SimpleExcel';
+
+Then the action:
+
+ sub books : Local ActionClass('REST') {}
+
+ sub books_GET {
+ my ($self, $c) = @_;
+
+ my $rs = $c->model('DB::Book')->search({}, {
+ order_by => ['title']
+ });
+
+ my @rows = map {
+ [ $_->id, $_->title, $_->rating, $_->author_list ]
+ } $rs->all;
+
+ my $entity = {
+ header => ['ID', 'Title', 'Rating', 'Authors'],
+ rows => \@rows,
+ filename => 'books-'.POSIX::strftime('%m-%d-%Y', localtime)
+ };
+
+ $self->status_ok(
+ $c,
+ entity => $entity
+ );
+ }
+
+=head2 Try it out
+
+Start the server with C<script/myapp_server.pl>.
+
+In your browser, open L<http://localhost:3000/ajax>. You will see the books
+grid, click on the excel icon and you should get a file download prompt for the
+Excel file, open it with Excel or OpenOffice.
+
+=head2 TODO
+
+We need an Excel deserializer, so that users can edit the downloaded Excel
+sheets and upload them back. It would also be nice if the ID column was
+highlighted and locked against editing.
+
+If you have any interest in these things, or in working on them, please email
+me, my email is at the bottom. Patches most certainly welcome as well.
+
+=head1 AUTHOR
+
+Caelum: Rafael Kitover <rkitover at cpan.org>
+
More information about the Catalyst-commits
mailing list