package MT::Plugin::CompressGZip; # CompressGZip - Enable zlib compression of the static contents # Original Copyright (c) 2007 Piroli YUKARINOMIYA # Open MagicVox.net - http://www.magicvox.net/ # @see http://www.magicvox.net/archive/2007/03041744/ use strict; use Compress::Zlib; use vars qw( $MYNAME $VERSION ); $MYNAME = 'CompressGZip'; $VERSION = '1.00'; use base qw( MT::Plugin ); my $plugin = new MT::Plugin ({ name => $MYNAME, version => $VERSION, author_name => 'Piroli YUKARINOMIYA', author_link => 'http://www.magicvox.net/?'. $MYNAME, doc_link => 'http://www.magicvox.net/archive/2007/03041744/?'. $MYNAME, description => <zlib compression of the static contents with Compress::Zlib v.$Compress::Zlib::VERSION HTMLHEREDOC }); MT->add_plugin ($plugin); sub instance { $plugin } ######################################################################## use MT::Template::Context; ### MTRecommendedEntries MT::Template::Context->add_container_tag (CompressGZip => \&compress_gzip); sub compress_gzip { my ($ctx, $args, $cond) = @_; # my $builder = $ctx->stash ('builder'); my $tokens = $ctx->stash ('tokens'); defined (my $out = $builder->build ($ctx, $tokens, $cond)) or return $ctx->error ($builder->errstr); Compress::Zlib::memGzip ($out); } 1; __END__ ######################################################################## # '07/03/04 1.00 ŌJ