|
Revision 10637, 1.4 kB
(checked in by tokuhirom, 5 years ago)
|
|
AirHPhone のときは横幅320px固定でおねがいします。
|
| 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 | my $attr = $args->{mobile_attribute}; |
|---|
| 10 | return if $attr->is_non_mobile; |
|---|
| 11 | |
|---|
| 12 | # HTTP::MobileAttribute::Plugin::Display は AirHPhone に対応していない。 |
|---|
| 13 | # が、ディスプレイ幅の指定がないと利用に耐えないので、現行機種のほとんどが 320px であることが下記 URL より確認できるので |
|---|
| 14 | # http://www.willcom-inc.com/ja/lineup/spec/voice/index.html |
|---|
| 15 | # 320px 固定にしておく。だれか Willcom が大好きでたまらないような人があらわれたら対応してください。 |
|---|
| 16 | my $width = $attr->is_airh_phone ? 320 : $attr->display->width; |
|---|
| 17 | |
|---|
| 18 | my $header = qq!<div style="border: 1px black solid; width: ${width}px; margin: 0 auto;float: left;">!; |
|---|
| 19 | |
|---|
| 20 | my $content = $args->{response}->content; |
|---|
| 21 | $content =~ s!(<body[^>]*>)!$1$header!i; |
|---|
| 22 | $content =~ s!(</body>)!"</div>$1"!ie; |
|---|
| 23 | $args->{response}->content($content); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | 1; |
|---|
| 27 | __END__ |
|---|
| 28 | |
|---|
| 29 | =for stopwords localsrc HTML |
|---|
| 30 | |
|---|
| 31 | =head1 NAME |
|---|
| 32 | |
|---|
| 33 | Moxy::Plugin::DisplayWidth - limit the HTML width |
|---|
| 34 | |
|---|
| 35 | =head1 SYNOPSIS |
|---|
| 36 | |
|---|
| 37 | - module: HTMLWidth |
|---|
| 38 | |
|---|
| 39 | =head1 DESCRIPTION |
|---|
| 40 | |
|---|
| 41 | limit the HTML width |
|---|
| 42 | |
|---|
| 43 | =head1 AUTHOR |
|---|
| 44 | |
|---|
| 45 | Kan Fushihara |
|---|
| 46 | |
|---|
| 47 | Tokuhiro Matsuno |
|---|
| 48 | |
|---|
| 49 | =head1 SEE ALSO |
|---|
| 50 | |
|---|
| 51 | L<Moxy> |
|---|