| Moxy documentation | Contained in the Moxy distribution. |
Moxy::Plugin::DisplayWidth - limit the HTML width
- module: HTMLWidth
limit the HTML width
Kan Fushihara
Tokuhiro Matsuno
| Moxy documentation | Contained in the Moxy distribution. |
package Moxy::Plugin::DisplayWidth; use strict; use warnings; use base qw/Moxy::Plugin/; # HTMLå ¨ä½ã®æ¨ªå¹ ãUAã®ç»é¢ãµã¤ãºã«åããã sub response_filter :Hook { my ($class, $context, $args) = @_; my $attr = $args->{mobile_attribute}; return if $attr->is_non_mobile; # HTTP::MobileAttribute::Plugin::Display 㯠AirHPhone ã«å¯¾å¿ãã¦ããªãã # ãããã£ã¹ãã¬ã¤å¹ ã®æå®ããªãã¨å©ç¨ã«èããªãã®ã§ãç¾è¡æ©ç¨®ã®ã»ã¨ãã©ã 320px ã§ãããã¨ãä¸è¨ URL ãã確èªã§ããã®ã§ # http://www.willcom-inc.com/ja/lineup/spec/voice/index.html # 320px åºå®ã«ãã¦ãããã ãã Willcom ã大好ãã§ãã¾ããªããããªäººããããããã対å¿ãã¦ãã ããã my $width = $attr->is_airh_phone ? 320 : $attr->display->width; $width ||= 320; # ãªãããã¾ãã¨ããªãã£ãã¨ãã®ããã©ã«ãã®ãµã¤ãºã¯ 320 ã¨ãããã¨ãã«çç±ã¯ãªãã my $header = qq!<div style="border: 1px black solid; width: ${width}px; margin: 0 auto;float: left;">!; my $content = $args->{response}->content; $content =~ s!(<body[^>]*>)!$1$header!i; $content =~ s!(</body>)!"</div>$1"!ie; $args->{response}->content($content); } 1; __END__