Cory G Watson

NAME

Catalyst::View::Graphics::Primitive - A Catalyst View for Graphics::Primitive

SYNOPSIS

  # 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'
    }
  )

DESCRIPTION

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).

CONFIGURATION

The following configuration options can be set:

content_type

Sets the default content type to put into the response.

driver

Sets the default driver to use when rendering a component.

driver_args

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:

  $c->stash->{graphics_primitive_driver} = 'SomethingElse';
  $c->stash->{graphics_primitive_driver_args} = { format => 'png' };
  $c->stash->{graphics_primitive_content_type} = 'image/png';

METHODS

new

The constructor for a new Graphics::Primitive view.

process

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:

  $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}.

AUTHOR

Cory Watson, <gphat@cpan.org>

Infinity Interactive, http://www.iinteractive.com

ACKNOWLEDGEMENTS

This module was inspired by Catalyst::View::GD and Catalyst::View::TT.

BUGS

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.

COPYRIGHT & LICENSE

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.




Hosting generously
sponsored by Bytemark