Plagger::Plugin::Widget::CacheGoogle
Google cacheへのリンクを追加するWidgetプラグイン。
WWW::Cache::Googleを利用してる。
![]()
package Plagger::Plugin::Widget::CacheGoogle;
use strict;
use base qw( Plagger::Plugin );
use HTML::Entities;
use WWW::Cache::Google;
sub register {
my($self, $context) = @_;
$context->register_hook(
$self,
'publish.entry.fixup' => \&add,
);
}
sub add {
my($self, $context, $args) = @_;
$args->{entry}->add_widget($self);
}
sub html {
my($self, $entry) = @_;
my $uri = WWW::Cache::Google->new($entry->permalink)->cache;
my $url = HTML::Entities::encode($uri->as_string);
return qq(<a href="$url" style="color:#77c;">Cached</a>);
}
1;