Show
Ignore:
Timestamp:
04/20/08 01:11:02 (5 years ago)
Author:
tokuhirom
Message:

FlashUseImgTag? のサポートをついかした。

Location:
lang/perl/Moxy/branches/CC
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Moxy/branches/CC/config.yaml

    r9923 r9926  
    2323  - module: Filter::CookieCutter 
    2424  - module: Filter::HTTPHeader 
    25 # - module: Filter::FlashUseImgTag 
     25  - module: Filter::FlashUseImgTag 
    2626# - module: Filter::QRCode::Imager 
    2727# - module: Filter::GPS 
  • lang/perl/Moxy/branches/CC/lib/Moxy/Plugin/Filter/FlashUseImgTag.pm

    r5041 r9926  
    66use HTML::Parser; 
    77 
    8 sub register { 
    9     my ($class, $context) = @_; 
     8sub e: Hook('response_filter_E') { 
     9    my ( $self, $context, $args ) = @_; 
    1010 
    11     $context->register_hook( 
    12         response_filter_E => sub { 
    13             my ( $context, $args ) = @_; 
     11    # only for html. 
     12    return unless (($args->{response}->header('Content-Type')||'') =~ /html/); 
    1413 
    15             # only for html. 
    16             return unless (($args->{response}->header('Content-Type')||'') =~ /html/); 
     14    my $output = ''; 
     15    my $parser = HTML::Parser->new( 
     16        api_version   => 3, 
     17        start_h       => [ sub { 
     18            my ($tagname, $attr, $orig) = @_; 
    1719 
    18             my $output = ''; 
    19             my $parser = HTML::Parser->new( 
    20                 api_version   => 3, 
    21                 start_h       => [ sub { 
    22                     my ($tagname, $attr, $orig) = @_; 
     20            if ($tagname =~ /^img$/i && $attr->{src} =~ /\.swf$/) { 
     21                $output .= qq| 
     22                    <object data="@{[$attr->{src}]}" width="@{[$attr->{width}]}" height="@{[$attr->{height}]}"  
     23                            type="application/x-shockwave-flash"> 
     24                        <param name="bgcolor" value="#ffffff" /> 
     25                        <param name="loop" value="off" /> 
     26                        <param name="quality" value="high" /> 
     27                        <param name="salign" value="t" /> 
     28                    </object> 
     29                |; 
     30            } else { 
     31                $output .= $orig; 
     32                return; 
     33            } 
    2334 
    24                     if ($tagname =~ /^img$/i && $attr->{src} =~ /\.swf$/) { 
    25                         $output .= qq| 
    26                             <object data="@{[$attr->{src}]}" width="@{[$attr->{width}]}" height="@{[$attr->{height}]}"  
    27                                     type="application/x-shockwave-flash"> 
    28                                 <param name="bgcolor" value="#ffffff" /> 
    29                                 <param name="loop" value="off" /> 
    30                                 <param name="quality" value="high" /> 
    31                                 <param name="salign" value="t" /> 
    32                             </object> 
    33                         |; 
    34                     } else { 
    35                         $output .= $orig; 
    36                         return; 
    37                     } 
     35        }, "tagname, attr, text" ], 
     36        end_h  => [ sub { $output .= shift }, "text"], 
     37        text_h => [ sub { $output .= shift }, "text"], 
     38    ); 
    3839 
    39                 }, "tagname, attr, text" ], 
    40                 end_h  => [ sub { $output .= shift }, "text"], 
    41                 text_h => [ sub { $output .= shift }, "text"], 
    42             ); 
     40    $parser->boolean_attribute_value('__BOOLEAN__'); 
     41    $parser->parse( $args->{response}->content ); 
    4342 
    44             $parser->boolean_attribute_value('__BOOLEAN__'); 
    45             $parser->parse(${ $args->{content_ref} }); 
    46  
    47             ${ $args->{content_ref} } = $output; 
    48         } 
    49     ); 
     43    $args->{response}->content( $output ); 
    5044} 
    5145