| 1 | package HTML::Display::MozRepl; | ||
| 2 | use strict; | ||
| 3 | use Carp qw(carp); | ||
| 4 | use WWW::Mechanize::Firefox; | ||
| 5 | use parent 'HTML::Display::Common'; | ||
| 6 | our $VERSION = '0.80'; | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | HTML::Display::MozRepl - use a mozrepl enabled Firefox to display HTML | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | $ENV{PERL_HTML_DISPLAY} = 'HTML::Display::MozRepl'; | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | sub new { | ||
| 19 | my ($class,%options) = @_; | ||
| 20 | my $self = $class->SUPER::new(); | ||
| 21 | my $ff = WWW::Mechanize::Firefox->new( | ||
| 22 | autoclose => 0, | ||
| 23 | %options, | ||
| 24 | ); | ||
| 25 | $self->{ff} = $ff; | ||
| 26 | $self; | ||
| 27 | }; | ||
| 28 | |||
| 29 | sub ff { $_[0]->{ff} }; | ||
| 30 | |||
| 31 | sub display_html { | ||
| 32 | my ($self,$html) = @_; | ||
| 33 | if ($html) { | ||
| 34 | my $browser = $self->ff; | ||
| 35 | $browser->update_html($html); | ||
| 36 | } else { | ||
| 37 | carp "No HTML given" unless $html; | ||
| 38 | }; | ||
| 39 | }; | ||
| 40 | |||
| 41 | =head1 SEE ALSO | ||
| 42 | |||
| 43 | L<WWW::Mechanize::Firefox> | ||
| 44 | |||
| 45 | =head1 REPOSITORY | ||
| 46 | |||
| 47 | The public repository of this module is | ||
| 48 | L<http://github.com/Corion/www-mechanize-firefox>. | ||
| 49 | |||
| 50 | =head1 AUTHOR | ||
| 51 | |||
| 52 | Copyright (c) 2009-2014 Max Maischein C<< <corion@cpan.org> >> | ||
| 53 | |||
| 54 | =head1 LICENSE | ||
| 55 | |||
| 56 | This module is released under the same terms as Perl itself. | ||
| 57 | |||
| 58 | =cut | ||
| 59 | |||
| 60 | 1; |