/
DoCoMoGUIDFilter.pm
47 lines (39 loc) · 984 Bytes
/
DoCoMoGUIDFilter.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package Kamui::Plugin::Mobile::DoCoMoGUIDFilter;
use Kamui;
use base 'Kamui::Plugin';
sub register_method {
+{
docomo_guid_filter => sub {
my $c = shift;
Kamui::Plugin::Mobile::DoCoMoGUIDFilter::Backend->new($c);
},
};
}
package Kamui::Plugin::Mobile::DoCoMoGUIDFilter::Backend;
use Kamui;
use HTML::StickyQuery::DoCoMoGUID;
sub new {
my ($class, $c) = @_;
bless {c => $c}, $class;
}
sub c { $_[0]->{c} }
sub finalize {
my ($self, $res) = @_;
if ( $res && $res->status == 200
&& $res->content_type =~ /html/
&& not( Scalar::Util::blessed( $res->body ) )
&& $self->c->mobile_attribute->is_docomo
&& $res->body )
{
my $body = $res->body;
$res->body(
sub {
my $guid = HTML::StickyQuery::DoCoMoGUID->new;
$guid->sticky(
scalarref => \$body,
);
}->()
);
}
}
1;