Changeset 12464

Show
Ignore:
Timestamp:
05/26/08 22:54:43 (5 years ago)
Author:
tokuhirom
Message:

rewrite PC top page by Template::Declare.

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

Legend:

Unmodified
Added
Removed
  • lang/perl/mobirc/trunk/Makefile.PL

    r12457 r12464  
    7373tests 't/*.t t/*/*.t t/*/*/*.t'; 
    7474test_requires 'Test::More'; 
     75test_requires 'Text::Diff'; 
    7576test_requires 'Test::Exception'; 
    7677install_script 'mobirc'; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/HTTPD/Controller.pm

    r12459 r12464  
    3434    my ($class, $c) = @_; 
    3535 
     36    if ($c->{mobile_agent}->is_non_mobile) { 
     37        return render_td( 
     38            $c, 
     39            'pc_top' => ( 
     40                $c->{mobile_agent}, 
     41                ($c->{config}->{httpd}->{root} || '/'), 
     42            ) 
     43        ); 
     44    } 
     45 
    3646    my $server = server; 
    37  
    38 #   if ($c->{mobile_agent}->is_non_mobile) { 
    39 #       return render_td( 
    40 #           $c, 
    41 #           'pc_top' => ( 
    42 #           ) 
    43 #       ); 
    44 #   } 
    4547 
    4648    my $channels = [ 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/HTTPD/Router.pm

    r12459 r12464  
    5050        return 'static', 'style.css', 'text/css'; 
    5151    }  
    52     elsif ($uri =~ '/mobirc.css') { 
    53         return 'static', 'mobirc.css', 'text/css'; 
    54     }  
     52    elsif ($uri =~ m{^/(pc|mobirc|mobile).css}) { 
     53        return 'static', "$1.css", 'text/css'; 
     54    } 
    5555    elsif ($uri =~ '/mobile.css') { 
    5656        return 'static', 'mobile.css', 'text/css'; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/HTTPD/Template/PC.pm

    r12458 r12464  
    66use Params::Validate ':all'; 
    77use HTML::Entities qw/encode_entities/; 
     8use App::Mobirc; 
     9 
     10private template 'wrapper_pc' => sub { 
     11    my ($self, $mobile_agent, $code, $subtitle) = @_; 
     12 
     13    xml_decl { 'xml', version => 1.0, encoding => 'UTF-8' }; 
     14    html { 
     15        attr { lang => 'ja', 'xml:lang' => 'ja', xmlns => "http://www.w3.org/1999/xhtml" } 
     16        head { 
     17            meta { attr { 'http-equiv' => 'Content-Type', 'content' => "text/html; charset=UTF-8" } }; 
     18            meta { attr { 'http-equiv' => 'Cache-Control', 'content' => "max-age=0" } }; 
     19            meta { attr { name => 'robots', 'content' => 'noindex, nofollow' } }; 
     20            link { attr { rel => 'stylesheet', href => '/pc.css', type=> "text/css"} }; 
     21            link { attr { rel => 'stylesheet', href => '/mobirc.css', type=> "text/css"} }; 
     22            script { src is "/jquery.js" }; 
     23            script { src is "/mobirc.js" }; 
     24            if ($mobile_agent->user_agent =~ /(?:iPod|iPhone)/) { 
     25                meta { attr { name => 'viewport', content => 'width=device-width' } } 
     26                meta { attr { name => 'viewport', content => 'initial-scale=1.0, user-scalable=yes' } } 
     27            } 
     28            title { 
     29                my $title = $subtitle ? "$subtitle - " : ''; 
     30                   $title .= "mobirc"; 
     31                   $title; 
     32            } 
     33        } 
     34        body { 
     35            $code->() 
     36        } 
     37    } 
     38}; 
     39 
     40template 'pc_top' => sub { 
     41    my ($self, $mobile_agent, $docroot) = validate_pos(@_, OBJECT, OBJECT, SCALAR); 
     42    show 'wrapper_pc', $mobile_agent, sub { 
     43        div { 
     44            id is 'body'; 
     45            div { 
     46                id is 'main'; 
     47                div { id is 'menu' } 
     48                div { id is 'contents' } 
     49            } 
     50            div { 
     51                id is 'footer'; 
     52                form { 
     53                    onsubmit is 'send_message();return false'; 
     54                    input { attr { type => 'text', id => 'msg', name => 'msg', size => 30 } }; 
     55                    input { attr { type => 'button', value => 'send', onclick => 'send_message();' } }; 
     56                } 
     57                div { span { 'mobirc -'} span { class is 'version'; $App::Mobirc::VERSION } }; 
     58            } 
     59        }; 
     60 
     61        script { lang is 'javascript'; 
     62            outs_raw qq{docroot = '$docroot';}; 
     63        }; 
     64    }; 
     65}; 
    866 
    967template 'pc_menu' => sub { 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/HTTPD/Template/Pages.pm

    r12459 r12464  
    3232        body { 
    3333            $code->() 
    34  
    3534        } 
    3635    };