Eric Wilhelm > dotReader-v0.11.2 > dtRdr::Callbacks::Book

Download:
dotReader-v0.11.2.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Source  

NAME ^

dtRdr::Callbacks::Book - the callbacks object for books

SYNOPSIS ^

Just using the module will typically do everything you need.

  use dtRdr::Callbacks::Book;

This installs callback() and get_callbacks() methods in your class. The callback() method is for adding to your class's callbacks.

  YourClass->callback->set_foo_sub(sub {...});

The get_callbacks() methods aggregates your classes callbacks with your base class. If your plugin has no specific callbacks, you can just inherit it, but this is not recommended.

To run the 'foo' callback (which will either be specific to your class, your base class, or else the default), just:

  YourClass->get_callbacks->foo($args);

Alternatively, the standalone usage:

  use dtRdr::Callbacks::Book (); # suppress import()
  my $callbacks = dtRdr::Callbacks::Book->new();
  $callbacks->set_core_link_sub(sub {"foo://" . $_[0]});

  # later ...

  my $link = $callback->core_link($book, 'dr_note_link.png');

new

  my $callbacks = dtRdr::Callbacks::Book->new();

aggregate

Overwrites each property (from right to left) and returns an aggregated callback object. List types are appended rather than overwritten.

  my $all_callbacks = $callback->aggregate($and1, $and2, $and3);

Callbacks ^

The documentation for each callback here should also serve as your custom callback's prototype.

XML things

core_link

Create a uri to a core file (such as an icon.) The default is to prepend 'dr://CORE/'.

  my $link = $callbacks->core_link($item);

img_src_rewrite

Rewrites the img tag's src uri (such as into a base-64 encoded form.) The default just parrots the $uri with which it was called.

  $uri = $callbacks->img_src_rewrite($uri, $book);

Annotation Events

annotation_created

  $callbacks->annotation_created($anno);

annotation_changed

  $callbacks->annotation_changed($anno);

annotation_deleted

  $callbacks->annotation_deleted($anno);

Meta ^

These methods let you add to the callback object, though it is best to define the methods in this package as above.

define

Define a callback and the default subref.

  dtRdr::Callbacks::Book->define('name', sub {...});

For multi-entry callbacks, the second argument is a (possibly empty) array reference.

has

Returns true if some method (other than the default) has been installed under $name. For multi-sub callbacks, returns true if one or more is installed (whether it is the default or not.)

  $callbacks->has($name);

import

Calls install_in() on your current package.

  use dtRdr::Callbacks::Book;

install_in

  dtRdr::Callbacks::Book->install_in($class);

AUTHOR ^

Eric Wilhelm <ewilhelm at cpan dot org>

http://scratchcomputing.com/

COPYRIGHT ^

Copyright (C) 2006 Eric L. Wilhelm and OSoft, All Rights Reserved.

NO WARRANTY ^

Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.

LICENSE ^

The dotReader(TM) is OSI Certified Open Source Software licensed under the GNU General Public License (GPL) Version 2, June 1991. Non-encrypted and encrypted packages are usable in connection with the dotReader(TM). The ability to create, edit, or otherwise modify content of such encrypted packages is self-contained within the packages, and NOT provided by the dotReader(TM), and is addressed in a separate commercial license.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

syntax highlighting: