Catalyst::View::Graphics::Primitive - A Catalyst View for Graphics::Primitive
# lib/MyApp/View/GP.pm package MyApp::View::GP use base 'Catalyst::View::Graphics::Primitive'; 1; # configure in lib/MyApp.pm MyApp->config( ... 'View::Graphics::Primitive' => { driver => 'Cairo', driver_args => { format => 'pdf' }, content_type => 'application/pdf' } )
This is the Catalyst view class for Graphics::Primitive. Any components created with Graphics::Primitive can be passed to this view and rendered via whatever driver you desire. This view has a helper so you can create your view in the standard Catalyst way with myapp_create.pl (where myapp is replaced with your application name).
The following configuration options can be set:
Sets the default content type to put into the response.
Sets the default driver to use when rendering a component.
Sets the arguments to pass when insantiating the driver. A common example for the Cairo driver would be:
MyApp->config( ... 'View::Graphics::Primitive' => { driver => 'Cairo', driver_args => { format => 'pdf' }, content_type => 'application/pdf' } );
All of these options can be overridden at request time by prefixing the name with graphics_primitive_ and setting the value in the stash. For example, to override the driver, args and content type:
graphics_primitive_
$c->stash->{graphics_primitive_driver} = 'SomethingElse'; $c->stash->{graphics_primitive_driver_args} = { format => 'png' }; $c->stash->{graphics_primitive_content_type} = 'image/png';
The constructor for a new Graphics::Primitive view.
Renders the Graphics::Primitive::Component object stored in $c->stash->{graphics_primitive} using the driver specified in the configuration or in $c->stash->{graphics_primitive_driver} (for runtime changes). The driver will instantiated using driver_args from the configuration or $c->stash->{graphics_primitive_driver_args}. The component will then be moved through the Graphics::Primitive rendering lifecycle as follows:
$c->stash->{graphics_primitive}
$c->stash->{graphics_primitive_driver}
$c->stash->{graphics_primitive_driver_args}
$driver->prepare($comp); $driver->finalize($comp); if($comp->can('layout_manager')) { $comp->layout_manager->do_layout($comp); } $driver->draw($comp);
The result of draw is then set as the body response. The content type is set based on the content_type configuration option or the value of $c->stash->{graphics_primitive_content_type}.
draw
content_type
$c->stash->{graphics_primitive_content_type}
Cory Watson, <gphat@cpan.org>
<gphat@cpan.org>
Infinity Interactive, http://www.iinteractive.com
This module was inspired by Catalyst::View::GD and Catalyst::View::TT.
Please report any bugs or feature requests to bug-geometry-primitive at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geometry-Primitive. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-geometry-primitive at rt.cpan.org
Copyright 2008 by Infinity Interactive, Inc.
http://www.iinteractive.com
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::View::Graphics::Primitive, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::View::Graphics::Primitive
CPAN shell
perl -MCPAN -e shell install Catalyst::View::Graphics::Primitive
For more information on module installation, please visit the detailed CPAN module installation guide.