| mobirc documentation | Contained in the mobirc distribution. |
App::Mobirc::Plugin::HTMLFilter::CompressHTML - compress the html filter
compress the html filter for mobirc
cho45
| mobirc documentation | Contained in the mobirc distribution. |
package App::Mobirc::Plugin::HTMLFilter::CompressHTML; # vim:expandtab: use strict; use MooseX::Plaggerize::Plugin; use App::Mobirc::Util; use App::Mobirc::Validator; hook html_filter => sub { my ($self, $global_context, $req, $content) = validate_hook('html_filter', @_); my $bsize = length $content; $content =~ s{<!--.+?-->}{}gs; $content =~ s{[ \t\f]+}{ }g; # å¯èªæ§ä¿æã®ããè¥å¹²ããã©ããã¨ããã£ã¦ãã $content =~ s{([ \t\f]*[\r\n]+[ \t\f]*)+}{\n}g; $content =~ s{> ([^<])}{>$1}g; my $asize = length $content; my $rate = sprintf("%03.1f", 100 - ($asize / $bsize * 100)); my $packets = sprintf("%0.1f D.%.1f", $asize / 128, ($bsize - $asize) / 128); DEBUG "Compress before->$bsize after->$asize $rate% packets->$packets"; return ( $req, $content); }; 1; __END__