| Catalyst-Plugin-Acme-LOLCAT documentation | Contained in the Catalyst-Plugin-Acme-LOLCAT distribution. |
Catalyst::Plugin::Acme::LOLCAT - IM IN UR CATALYST APLACASHUN REWRITIN YUR OUTPUTS.
Version 0.03
See Acme::LOLCAT if you don't already know what this will do to your Catalyst plain text and HTML output.
use Catalyst qw/
Your::Regular::Plugins
Acme::LOLCAT
/;
# And observe the corrected output of your application
Ashley Pond V, ashley at cpan.org.
I love bugs! Hymenoptera, dictyoptera, coleoptera, all of them.
Expects valid nesting. May sometimes interfere with tags that should be literal, like <script> and <style>, when it's not present.
Targeted tags in config file?
You can find documentation for this module with the perldoc command.
perldoc Catalyst::Plugin::Acme::LOLCAT
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Plugin-Acme-LOLCAT
Copyright (c) 2007 Ashley Pond V, all rights reserved.
This program is free software; you can redistribute it and modify it under the same terms as Perl itself.
| Catalyst-Plugin-Acme-LOLCAT documentation | Contained in the Catalyst-Plugin-Acme-LOLCAT distribution. |
package Catalyst::Plugin::Acme::LOLCAT; use strict; use Acme::LOLCAT ();
our $VERSION = "0.03";
my $skip = qr/\Ascript|style\z/; sub finalize { my $c = shift; return $c->NEXT::finalize unless $c->response->body and $c->response->content_type =~ m,^text/(plain|html),; if ( $1 eq 'plain' ) { $c->response->{body} = Acme::LOLCAT::translate($c->response->{body}); } else { require HTML::TokeParser; my $p = HTML::TokeParser->new( \$c->response->{body} ); my $repaired = ''; my @queue; while ( my $t = $p->get_token() ) { push @queue, $t->[1] if $t->[0] eq 'S'; # assumes well-formed pop @queue if $t->[0] eq 'E' or ( $t->[0] eq 'S' and $t->[-1] =~ m,/>\z, ); # self-closer if ( $t->[0] eq 'T' and not $t->[2] and not grep /$skip/, @queue ) { my $txt = $t->[1] =~ /\w/ ? Acme::LOLCAT::translate($t->[1]) : $t->[1]; $repaired .= $txt; } else { $repaired .= ( $t->[0] eq 'T' ) ? $t->[1] : $t->[-1]; } } $c->response->{body} = $repaired; } $c->NEXT::finalize; }
1; # End of Catalyst::Plugin::Acme::LOLCAT