Changeset 14688

Show
Ignore:
Timestamp:
06/27/08 14:07:55 (5 years ago)
Author:
tomi-ru
Message:

render()を追加、pod, test

Location:
lang/perl/Catalyst-View-MobileJpFilter/trunk
Files:
10 added
3 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Catalyst-View-MobileJpFilter/trunk

    • Property svn:ignore set to
      MANIFEST
  • lang/perl/Catalyst-View-MobileJpFilter/trunk/Makefile.PL

    r14686 r14688  
    44all_from 'lib/Catalyst/View/MobileJpFilter.pm'; 
    55 
    6 requires 'Foo::Bar'; 
     6requires 'Catalyst::Runtime' => '5.70'; 
     7requires 'Catalyst::Plugin::MobileAgent'; 
     8requires 'HTML::MobileJp::Filter'; 
     9requires 'Data::Visitor::Callback'; 
    710 
    811build_requires 'Test::More'; 
     12build_requires 'Encode::JP::Mobile'; 
    913 
    1014auto_include; 
  • lang/perl/Catalyst-View-MobileJpFilter/trunk/lib/Catalyst/View/MobileJpFilter.pm

    r14687 r14688  
    22use strict; 
    33use warnings; 
     4our $VERSION = '0.01'; 
     5 
    46use base 'Catalyst::View'; 
    5  
    67use Class::C3; 
    78use Data::Visitor::Callback; 
     
    3435} 
    3536 
     37sub render { 
     38    my ($self, $c) = @_; 
     39     
     40    $self->html_filter->filter( 
     41        mobile_agent => $c->req->mobile_agent, 
     42        html         => $c->res->body || "", 
     43    ); 
     44} 
     45 
    3646sub process { 
    3747    my ($self, $c) = @_; 
    3848     
    39     my $html = $self->html_filter->filter( 
    40         mobile_agent => $c->req->mobile_agent, 
    41         html         => $c->res->body || "", 
    42     ); 
    43      
    44     $c->res->body($html); 
    45      
     49    if ($c->res->content_type =~ /html$|xhtml\+xml$/) { 
     50        $c->res->body( $self->render($c) ); 
     51    } 
     52 
    4653    return 1; 
    4754} 
    4855 
    49561; 
     57__END__ 
     58 
     59=encoding utf-8 
     60 
     61=head1 NAME 
     62 
     63Catalyst::View::MobileJpFilter - Filtering HTML for Japanese cellphone 
     64 
     65=head1 DESCRIPTION 
     66 
     67Catalyst::View::MobileJpFilter is a simple adapter to use 
     68L<HTML::MobileJp::Filter> as Catalyst view class. 
     69 
     70=head1 SYNOPSIS 
     71 
     72  package MyApp::View::MobileJpFilter; 
     73  use strict; 
     74  use base 'Catalyst::View::MobileJpFilter'; 
     75   
     76  use YAML; 
     77   
     78  __PACKAGE__->config(YAML::Load <<'...' 
     79  --- 
     80  filters: 
     81    - module: DoCoMoCSS 
     82      config: 
     83        base_dir: __path_to(root)__ 
     84    - module: DoCoMoGUID 
     85    - module: FallbackImage 
     86      config: 
     87        template: '<img src="%s.gif" />' 
     88        params: 
     89          - unicode_hex 
     90  ... 
     91  ); 
     92   
     93  1; 
     94 
     95=head1 CONFIGURATION 
     96 
     97Same as L<HTML::MobileJp::Filter>. 
     98 
     99=head1 HOW TO USE 
     100 
     101Use as follows from your controller. 
     102 
     103  $c->forward( $c->view('TT') );             # making $c->res->body 
     104  $c->forward( $c->view('MobileJpFilter') ); # filtering $c->res->body 
     105 
     106Or with L<RenderView|Catalyst::Action::RenderView>. 
     107 
     108  sub render :ActionClass('RenderView') { } 
     109   
     110  sub end :Private { 
     111      my ($self, $c) = @_; 
     112      $c->forward('render'); 
     113  } 
     114 
     115=head1 AUTHOR 
     116 
     117Naoki Tomita E<lt>tomita@cpan.orgE<gt> 
     118 
     119=head1 LICENSE 
     120 
     121This library is free software; you can redistribute it and/or modify 
     122it under the same terms as Perl itself. 
     123 
     124=head1 SEE ALSO 
     125 
     126L<HTML::MobileJp::Filter> 
     127 
     128L<http://coderepos.org/share/browser/lang/perl/Catalyst-View-MobileJpFilter> (repository) 
     129 
     130=cut