line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::MobileJp::Filter; |
2
|
5
|
|
|
5
|
|
852160
|
use Any::Moose; |
|
5
|
|
|
|
|
163601
|
|
|
5
|
|
|
|
|
37
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has filters => ( |
6
|
|
|
|
|
|
|
is => 'rw', |
7
|
|
|
|
|
|
|
isa => 'ArrayRef', |
8
|
|
|
|
|
|
|
required => 1, |
9
|
|
|
|
|
|
|
auto_deref => 1, |
10
|
|
|
|
|
|
|
default => sub { [] }, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has stash => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
isa => 'HashRef', |
16
|
|
|
|
|
|
|
default => sub { {} }, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
5
|
|
13690
|
no Any::Moose; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
26
|
|
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
5
|
|
6501
|
use Class::Trigger; |
|
5
|
|
|
|
|
6706
|
|
|
5
|
|
|
|
|
32
|
|
22
|
5
|
|
|
5
|
|
3809
|
use HTML::MobileJp::Filter::Content; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILD { |
25
|
|
|
|
|
|
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
for my $config (@{ $self->filters }) { |
27
|
|
|
|
|
|
|
my $filter = do { |
28
|
|
|
|
|
|
|
my $module = $config->{module} =~ m{^\+(.*)$} ? $1 : __PACKAGE__ ."::$config->{module}"; |
29
|
|
|
|
|
|
|
Any::Moose::load_class($module); |
30
|
|
|
|
|
|
|
$module->new($config); |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$self->add_trigger(filter_process => sub { |
34
|
|
|
|
|
|
|
my $context = shift; |
35
|
|
|
|
|
|
|
$filter->mobile_agent($context->stash->{mobile_agent}); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $ret = $filter->filter($context->stash->{content}); |
38
|
|
|
|
|
|
|
if (defined $ret) { |
39
|
|
|
|
|
|
|
$context->stash->{content}->update($ret); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub filter { |
46
|
|
|
|
|
|
|
my ($self, %param) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$self->stash({ |
49
|
|
|
|
|
|
|
mobile_agent => $param{mobile_agent}, |
50
|
|
|
|
|
|
|
content => HTML::MobileJp::Filter::Content->new(html => $param{html}), |
51
|
|
|
|
|
|
|
}); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$self->call_trigger('filter_process'); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$self->stash->{content}->as_html; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
__END__ |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=encoding utf-8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
HTML::MobileJp::Filter - Glue of modules for fighting with Japanese mobile web |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SYNOPSIS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
use HTML::MobileJp::Filter; |
72
|
|
|
|
|
|
|
use HTTP::MobileAgent; |
73
|
|
|
|
|
|
|
use YAML; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $filter = HTML::MobileJp::Filter->new(YAML::Load <<'...' |
76
|
|
|
|
|
|
|
--- |
77
|
|
|
|
|
|
|
filters: |
78
|
|
|
|
|
|
|
- module: DoCoMoCSS |
79
|
|
|
|
|
|
|
config: |
80
|
|
|
|
|
|
|
base_dir: /path/to/htdocs |
81
|
|
|
|
|
|
|
- module: DoCoMoGUID |
82
|
|
|
|
|
|
|
- module: FallbackImage |
83
|
|
|
|
|
|
|
config: |
84
|
|
|
|
|
|
|
template: '<img src="%s.gif" />' |
85
|
|
|
|
|
|
|
params: |
86
|
|
|
|
|
|
|
- unicode_hex |
87
|
|
|
|
|
|
|
- module: +MyApp::Filter::Foo |
88
|
|
|
|
|
|
|
... |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$html = $filter->filter( |
92
|
|
|
|
|
|
|
mobile_agent => HTTP::MobileAgent->new, |
93
|
|
|
|
|
|
|
html => $html, |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DESCRIPTION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
HTML::MobileJp::Filter is å大ãªå
人ãã¡ãã¤ãã£ã¦ãããæºå¸¯ãµã¤ãã«å½¹ç«ã¤ |
99
|
|
|
|
|
|
|
CPAN ã¢ã¸ã¥ã¼ã«ãã¡ãã¤ãªããèããã¬ã¼ã ã¯ã¼ã¯ã§ãã |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
B<CAUTION: This module is still alpha, its possible the API will change!> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 METHODS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=over 4 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item new( filters => [ ] ) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item filter( mobile_agent => $ua, html => $html ) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SEE ALSO |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L<http://search.cpan.org/search?mode=module&query=HTML::MobileJp::Filter::> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Naoki Tomita E<lt>tomita@cpan.orgE<gt> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DEVELOPMENT |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L<http://coderepos.org/share/browser/lang/perl/HTML-MobileJp-Filter> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#mobilejp on irc.freenode.net (I've joined as "tomi-ru") |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
130
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |