Changeset 12376

Show
Ignore:
Timestamp:
05/26/08 00:58:09 (6 months ago)
Author:
tokuhirom
Message:

topic pages is replaced by Template::Declare.

Location:
lang/perl/mobirc/trunk
Files:
1 added
2 removed
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/mobirc/trunk/lib/App/Mobirc/HTTPD/Controller.pm

    r12371 r12376  
    138138    my ($class, $c) = @_; 
    139139 
    140     return render( 
    141         $c, 
    142         'topics' => { 
    143             channels => [$c->{global_context}->channels], 
    144         }, 
    145     ); 
     140    my $html = App::Mobirc::HTTPD::View->show( 
     141        'topics', 
     142        $c->{mobile_agent}, App::Mobirc->context->server 
     143    ); 
     144    make_response($c, $html); 
    146145} 
    147146 
     
    229228} 
    230229 
    231 sub render { 
    232     my ( $c, $name, $args ) = @_; 
    233  
    234     croak "invalid args : $args" unless ref $args eq 'HASH'; 
    235  
    236     DEBUG "rendering template"; 
    237  
    238     # set default vars 
    239     $args = { 
    240         docroot              => $c->{config}->{httpd}->{root}, 
    241         render_line          => sub { render_line( $c, @_ ) }, 
    242         user_agent           => $c->{user_agent}, 
    243         mobile_agent         => $c->{mobile_agent}, 
    244         title                => $c->{config}->{httpd}->{title}, 
    245         version              => $App::Mobirc::VERSION, 
    246         now                  => time(), 
    247  
    248         %$args, 
    249     }; 
    250  
    251     my $tmpl_dir = $c->{mobile_agent}->is_non_mobile ? 'pc' : 'mobile'; 
    252     DEBUG "tmpl_dir: $tmpl_dir"; 
    253  
    254     my $tt = Template->new( 
    255         LOAD_TEMPLATES => [ 
    256             Template::Provider::Encoding->new( 
    257                 ABSOLUTE => 1, 
    258                 INCLUDE_PATH => dir( $c->{config}->{global}->{assets_dir}, 'tmpl', $tmpl_dir, )->stringify, 
    259             ) 
    260         ], 
    261     ); 
    262     $tt->process("$name.html", $args, \my $out) 
    263         or die $tt->error; 
    264  
    265     DEBUG "rendering done"; 
     230sub make_response { 
     231    my ( $c, $out ) = @_; 
    266232 
    267233    $out = _html_filter($c, $out); 
     
    293259} 
    294260 
     261sub render { 
     262    my ( $c, $name, $args ) = @_; 
     263 
     264    croak "invalid args : $args" unless ref $args eq 'HASH'; 
     265 
     266    DEBUG "rendering template"; 
     267 
     268    # set default vars 
     269    $args = { 
     270        docroot              => $c->{config}->{httpd}->{root}, 
     271        render_line          => sub { render_line( $c, @_ ) }, 
     272        user_agent           => $c->{user_agent}, 
     273        mobile_agent         => $c->{mobile_agent}, 
     274        title                => $c->{config}->{httpd}->{title}, 
     275        version              => $App::Mobirc::VERSION, 
     276        now                  => time(), 
     277 
     278        %$args, 
     279    }; 
     280 
     281    my $tmpl_dir = $c->{mobile_agent}->is_non_mobile ? 'pc' : 'mobile'; 
     282    DEBUG "tmpl_dir: $tmpl_dir"; 
     283 
     284    my $tt = Template->new( 
     285        LOAD_TEMPLATES => [ 
     286            Template::Provider::Encoding->new( 
     287                ABSOLUTE => 1, 
     288                INCLUDE_PATH => dir( $c->{config}->{global}->{assets_dir}, 'tmpl', $tmpl_dir, )->stringify, 
     289            ) 
     290        ], 
     291    ); 
     292    $tt->process("$name.html", $args, \my $out) 
     293        or die $tt->error; 
     294 
     295    DEBUG "rendering done"; 
     296 
     297    return make_response($c, $out); 
     298} 
     299 
    295300sub dispatch_static { 
    296301    my ($class, $c, $file_name, $content_type) = @_; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/HTTPD/View.pm

    r12371 r12376  
    44use Template::Declare; 
    55use App::Mobirc::HTTPD::Template::IRCMessage; 
     6use App::Mobirc::HTTPD::Template::Pages; 
    67 
    7 Template::Declare->init(roots => ['App::Mobirc::HTTPD::Template::IRCMessage']); 
     8Template::Declare->init(roots => ['App::Mobirc::HTTPD::Template::IRCMessage', 'App::Mobirc::HTTPD::Template::Pages']); 
    89 
    910sub show {