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