root/lang/perl/Moxy/trunk/lib/Moxy/Plugin/DisplayWidth.pm @ 10022

Revision 10022, 0.9 kB (checked in by tokuhirom, 5 years ago)

画面構成変えてみた。

Line 
1package Moxy::Plugin::DisplayWidth;
2use strict;
3use warnings;
4use base qw/Moxy::Plugin/;
5
6# HTML全体の横幅をUAの画面サイズに合わせる
7sub response_filter:Hook('response_filter') {
8    my ($class, $context, $args) = @_;
9
10    if ( $args->{mobile_attribute} && (my $display = $args->{mobile_attribute}->display) ) {
11        my $header = sprintf(
12            q{<div style="border: 1px black solid;
13                                            width: %dpx">}, $display->width
14        );
15
16        my $content = $args->{response}->content;
17        $content =~ s!(<body[^>]*>)!$1$header!i;
18        $content =~ s!(</body>)!"</div>$1"!ie;
19        $args->{response}->content($content);
20    }
21}
22
231;
24__END__
25
26=for stopwords localsrc HTML
27
28=head1 NAME
29
30Moxy::Plugin::DisplayWidth - limit the HTML width
31
32=head1 SYNOPSIS
33
34  - module: HTMLWidth
35
36=head1 DESCRIPTION
37
38limit the HTML width
39
40=head1 AUTHOR
41
42Kan Fushihara
43
44Tokuhiro Matsuno
45
46=head1 SEE ALSO
47
48L<Moxy>
Note: See TracBrowser for help on using the browser.