|
Revision 10022, 0.9 kB
(checked in by tokuhirom, 5 years ago)
|
|
画面構成変えてみた。
|
| Line | |
|---|
| 1 | package Moxy::Plugin::DisplayWidth; |
|---|
| 2 | use strict; |
|---|
| 3 | use warnings; |
|---|
| 4 | use base qw/Moxy::Plugin/; |
|---|
| 5 | |
|---|
| 6 | # HTML全体の横幅をUAの画面サイズに合わせる |
|---|
| 7 | sub 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 | |
|---|
| 23 | 1; |
|---|
| 24 | __END__ |
|---|
| 25 | |
|---|
| 26 | =for stopwords localsrc HTML |
|---|
| 27 | |
|---|
| 28 | =head1 NAME |
|---|
| 29 | |
|---|
| 30 | Moxy::Plugin::DisplayWidth - limit the HTML width |
|---|
| 31 | |
|---|
| 32 | =head1 SYNOPSIS |
|---|
| 33 | |
|---|
| 34 | - module: HTMLWidth |
|---|
| 35 | |
|---|
| 36 | =head1 DESCRIPTION |
|---|
| 37 | |
|---|
| 38 | limit the HTML width |
|---|
| 39 | |
|---|
| 40 | =head1 AUTHOR |
|---|
| 41 | |
|---|
| 42 | Kan Fushihara |
|---|
| 43 | |
|---|
| 44 | Tokuhiro Matsuno |
|---|
| 45 | |
|---|
| 46 | =head1 SEE ALSO |
|---|
| 47 | |
|---|
| 48 | L<Moxy> |
|---|