Changeset 13231

Show
Ignore:
Timestamp:
06/04/08 23:39:58 (5 years ago)
Author:
tokuhirom
Message:

httpd is one of component plugin!

Location:
lang/perl/mobirc/trunk
Files:
29 modified
1 moved

Legend:

Unmodified
Added
Removed
  • lang/perl/mobirc/trunk/config.yaml.sample

    r13013 r13231  
    5858  #     root: /foo/ 
    5959 
     60  - module: Component::HTTPD 
     61    config: 
     62      port: 5678 
     63 
     64 
    6065httpd: 
    61   port: 5785 
    62   title: mobirc 
    6366  lines: 40 
    6467  # root: / 
    65   # recent_log_per_page: 40 
    66   # charset: cp932 
    67   # content_type: text/html; charset=Shift_JIS 
    6868 
  • lang/perl/mobirc/trunk/lib/App/Mobirc.pm

    r13228 r13231  
    77use App::Mobirc::ConfigLoader; 
    88use App::Mobirc::Util; 
    9 use App::Mobirc::HTTPD; 
    109use UNIVERSAL::require; 
    1110use Carp; 
     
    4948sub run { 
    5049    my $self = shift; 
    51     die "this is instance method" unless blessed $self; 
     50    croak "this is instance method" unless blessed $self; 
    5251 
    5352    $self->run_hook('run_component'); 
    54  
    55     App::Mobirc::HTTPD->init($self->config, $self); 
    5653 
    5754    $poe_kernel->run(); 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/ConfigLoader.pm

    r13230 r13231  
    3434            mapping  => { 
    3535                lines          => { type => 'int', }, 
    36                 address        => { type => 'str', }, 
    37                 port           => { type => 'int', required => 1, }, 
    38                 title          => { type => 'str', }, 
    39                 content_type   => { type => 'str', }, 
    40                 charset        => { type => 'str', }, 
    41                 host           => { type => 'str', }, 
    4236                root           => { type => 'str', }, 
    4337                echo           => { type => 'bool', }, 
     
    9589 
    9690    # set default vars. 
     91    $config->{httpd}->{lines}          ||= 20; 
    9792    $config->{httpd}->{root}           ||= decode( 'utf8', '/' ); 
    9893    $config->{httpd}->{echo} = true unless exists $config->{httpd}->{echo}; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Model/Channel.pm

    r13013 r13231  
    6868    my ($self, $key, $row) = @_; 
    6969 
    70     my $log_max = $self->{global_context}->config->{httpd}->{lines}; 
     70    my $log_max = $self->{global_context}->config->{httpd}->{lines} || 20; 
    7171 
    7272    push @{$self->{$key}}, $row; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Plugin/Component/HTTPD.pm

    r13031 r13231  
    1 package App::Mobirc::HTTPD; 
     1package App::Mobirc::Plugin::Component::HTTPD; 
    22use strict; 
    3 use warnings; 
    4  
    5 use POE; 
    6 use POE::Filter::HTTPD; 
    7 use POE::Component::Server::TCP; 
     3use MooseX::Plaggerize::Plugin; 
    84 
    95use HTTP::MobileAgent; 
     
    2117]; 
    2218 
    23 sub init { 
    24     my ( $class, $config, $global_context ) = @_; 
     19has address => ( 
     20    is      => 'ro', 
     21    isa     => 'Str', 
     22    default => '0.0.0.0', 
     23); 
     24 
     25has port => ( 
     26    is      => 'ro', 
     27    isa     => 'Int', 
     28    default => 80, 
     29); 
     30 
     31hook run_component => sub { 
     32    my ( $self, $global_context ) = @_; 
    2533 
    2634    HTTP::Engine->new( 
    2735        interface => { 
    2836            module => 'POE', 
    29             args => { 
    30                 host => ($config->{httpd}->{address} || '0.0.0.0'), 
    31                 port => ($config->{httpd}->{port} || 80), 
     37            args   => { 
     38                host => $self->address, 
     39                port => $self->port, 
    3240            }, 
    3341            request_handler => \&App::Mobirc::Web::Handler::handler, 
     
    3644 
    3745    $global_context->load_plugin('StickyTime'); 
    38 } 
     46}; 
    3947 
    40481; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Web/Middleware/MobileAgent.pm

    r13031 r13231  
    11package App::Mobirc::Web::Middleware::MobileAgent; 
    22use Moose; 
     3use HTTP::MobileAgent; 
     4use HTTP::MobileAgent::Plugin::Charset; 
    35 
    46sub setup { 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Web/Template/Mobile.pm

    r13164 r13231  
    88use HTML::Entities qw/encode_entities/; 
    99use URI::Escape qw/uri_escape/; 
     10use HTTP::MobileAgent::Plugin::Charset; 
    1011 
    1112template 'mobile/wrapper_mobile' => sub { 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Web/Template/MobileAjax.pm

    r13166 r13231  
    77use App::Mobirc; 
    88use Path::Class; 
     9use HTTP::MobileAgent::Plugin::Charset; 
    910 
    1011private template 'mobile-ajax/wrapper_mobile' => sub { 
  • lang/perl/mobirc/trunk/t/00_compile.t

    r13031 r13231  
    1111use_ok 'App::Mobirc::Plugin::Component::IRCClient'; 
    1212 
    13 use_ok 'App::Mobirc::HTTPD'; 
     13use_ok 'App::Mobirc::Plugin::Component::HTTPD'; 
    1414use_ok 'App::Mobirc::Web::Router'; 
    1515 
  • lang/perl/mobirc/trunk/t/Core/channel.t

    r12354 r13231  
    1010App::Mobirc->new( 
    1111    { 
    12         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     12        httpd  => { lines => 40 }, 
    1313        global => { keywords => [qw/foo/], stopwords => [qw/foo31/] } 
    1414    } 
  • lang/perl/mobirc/trunk/t/Plugins/Authorizer/BasicAuth.t

    r13227 r13231  
    55use App::Mobirc::Plugin::Authorizer::BasicAuth; 
    66use MIME::Base64 (); 
     7use HTTP::Engine::Context; 
    78 
    89my $mobirc = App::Mobirc->new( 
    910    { 
    10         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     11        httpd  => { lines => 40 }, 
    1112        global => { keywords => [qw/foo/] } 
    1213    } 
  • lang/perl/mobirc/trunk/t/Plugins/Authorizer/DoCoMoGUID-authorizer.t

    r13017 r13231  
    1111my $mobirc = App::Mobirc->new( 
    1212    { 
    13         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     13        httpd  => { lines => 40 }, 
    1414        global => { keywords => [qw/foo/] } 
    1515    } 
  • lang/perl/mobirc/trunk/t/Plugins/Authorizer/DoCoMoGUID-html_filter.t

    r13031 r13231  
    33use Test::More; 
    44use App::Mobirc; 
     5use HTTP::MobileAgent; 
    56use HTTP::Engine middlewares => [ 
    67    qw/ +App::Mobirc::Web::Middleware::MobileAgent / 
     
    1314my $mobirc = App::Mobirc->new( 
    1415    { 
    15         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     16        httpd  => { lines => 40 }, 
    1617        global => { keywords => [qw/foo/] } 
    1718    } 
  • lang/perl/mobirc/trunk/t/Plugins/Component/IRCClient.t

    r13013 r13231  
    1515my $PORT = 9999; 
    1616 
    17 my $config = { 
    18     httpd => { 
    19         port  => 88888, 
    20         lines => 50, 
    21     }, 
    22 }; 
    23  
    2417$SIG{INT} = sub { die }; 
    2518 
    26 my $global_context = App::Mobirc->new($config); 
     19my $global_context = App::Mobirc->new( 
     20    { 
     21        httpd => { }, 
     22    } 
     23); 
    2724$global_context->load_plugin( 
    2825    { 
  • lang/perl/mobirc/trunk/t/Plugins/DocRoot.t

    r13013 r13231  
    88my $global_context = App::Mobirc->new( 
    99    { 
    10         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     10        httpd  => { lines => 40 }, 
    1111        global => { keywords => [qw/foo/] } 
    1212    } 
  • lang/perl/mobirc/trunk/t/Plugins/Filter/clickable.t

    r13013 r13231  
    1414    my $global_context = App::Mobirc->new( 
    1515        { 
    16             httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     16            httpd  => { lines => 40 }, 
    1717            global => { keywords => [qw/foo/] } 
    1818        } 
  • lang/perl/mobirc/trunk/t/Plugins/Filter/decorate-irc-color.t

    r13013 r13231  
    1010my $global_context = App::Mobirc->new( 
    1111    { 
    12         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     12        httpd  => { lines => 40 }, 
    1313        global => { keywords => [qw/foo/] } 
    1414    } 
  • lang/perl/mobirc/trunk/t/Plugins/Filter/no-decorate-irc-color.t

    r13013 r13231  
    99my $global_context = App::Mobirc->new( 
    1010    { 
    11         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     11        httpd  => { lines => 40 }, 
    1212        global => { keywords => [qw/foo/] } 
    1313    } 
  • lang/perl/mobirc/trunk/t/Plugins/GPS.t

    r13013 r13231  
    44use Test::More tests => 2; 
    55use HTTP::Engine::Context; 
     6use HTTP::Engine middlewares => [ 
     7    '+App::Mobirc::Web::Middleware::MobileAgent' 
     8]; 
    69 
    710my $mobirc = App::Mobirc->new( 
    811    { 
    9         httpd => { port => 3333, title => 'mobirc', lines => 40 }, 
     12        httpd => { lines => 40 }, 
    1013        global => { keywords => [qw/foo/], stopwords => [qw/foo31/] }, 
    1114    } 
  • lang/perl/mobirc/trunk/t/Plugins/HTMLFilter/CompressHTML.t

    r13013 r13231  
    77my $global_context = App::Mobirc->new( 
    88    { 
    9         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     9        httpd  => { lines => 40 }, 
    1010        global => { keywords => [qw/foo/] } 
    1111    } 
  • lang/perl/mobirc/trunk/t/Plugins/HTMLFilter/ConvertPictograms.t

    r13013 r13231  
    55use HTTP::Engine::Context; 
    66use Test::Base; 
     7use HTTP::Engine middlewares => [ 
     8    '+App::Mobirc::Web::Middleware::MobileAgent' 
     9]; 
    710 
    811my $global_context = App::Mobirc->new( 
    912    { 
    10         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     13        httpd  => { lines => 40 }, 
    1114        global => { keywords => [qw/foo/] } 
    1215    } 
  • lang/perl/mobirc/trunk/t/Plugins/HTMLFilter/DoCoMoCSS.t

    r13029 r13231  
    66use App::Mobirc::Plugin::HTMLFilter::DoCoMoCSS; 
    77use HTTP::Engine::Context; 
     8use HTTP::Engine middlewares => [ 
     9    '+App::Mobirc::Web::Middleware::MobileAgent' 
     10]; 
    811 
    912my $c = HTTP::Engine::Context->new; 
     
    1114my $global_context = App::Mobirc->new( 
    1215    { 
    13         httpd  => { port     => 3333, }, 
     16        httpd  => { }, 
    1417        global => { keywords => [qw/foo/], assets_dir => 'assets' } 
    1518    } 
  • lang/perl/mobirc/trunk/t/Plugins/HTMLFilter/NickGroup.t

    r13044 r13231  
    66my $mobirc = App::Mobirc->new( 
    77    { 
    8         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     8        httpd  => { lines => 40 }, 
    99        global => { keywords => [qw/foo/] } 
    1010    } 
  • lang/perl/mobirc/trunk/t/Plugins/StickyTime.t

    r13019 r13231  
    66my $global_context = App::Mobirc->new( 
    77    { 
    8         httpd  => { port     => 3333, title => 'mobirc', lines => 40 }, 
     8        httpd  => { lines => 40 }, 
    99        global => { keywords => [qw/foo/] } 
    1010    } 
  • lang/perl/mobirc/trunk/t/Role/Context.t

    r12355 r13231  
    77my $c = App::Mobirc->new( 
    88    { 
    9         httpd => { port => 3333, title => 'mobirc', lines => 40 }, 
     9        httpd => { lines => 40 }, 
    1010        global => { keywords => [qw/foo/], stopwords => [qw/foo31/] } 
    1111    } 
  • lang/perl/mobirc/trunk/t/Web/Template/Ajax/channel.t

    r13031 r13231  
    1414my $c = App::Mobirc->new( 
    1515    { 
    16         httpd => { port => 3333, title => 'mobirc', lines => 40 }, 
     16        httpd => { lines => 40 }, 
    1717        global => {}, 
    1818    } 
  • lang/perl/mobirc/trunk/t/Web/Template/Ajax/menu.t

    r13031 r13231  
    1212my $c = App::Mobirc->new( 
    1313    { 
    14         httpd => { port => 3333, title => 'mobirc', lines => 40 }, 
     14        httpd => { lines => 40 }, 
    1515        global => { keywords => [qw/foo/], stopwords => [qw/foo31/] }, 
    1616    } 
  • lang/perl/mobirc/trunk/t/Web/Template/IRCMessage.t

    r13042 r13231  
    1010my $c = App::Mobirc->new( 
    1111    { 
    12         httpd => { port => 3333, title => 'mobirc', lines => 40 }, 
     12        httpd => { lines => 40 }, 
    1313        global => { keywords => [qw/foo/], stopwords => [qw/foo31/] }, 
    1414        plugin => [ 
  • lang/perl/mobirc/trunk/t/Web/Template/Mobile/topics.t

    r13031 r13231  
    1010my $c = App::Mobirc->new( 
    1111    { 
    12         httpd => { port => 3333, title => 'mobirc', lines => 40 }, 
     12        httpd => { lines => 40 }, 
    1313        global => { keywords => [qw/foo/], stopwords => [qw/foo31/] }, 
    1414    } 
  • lang/perl/mobirc/trunk/t/Web/Template/MobileAjax/index.t

    r13164 r13231  
    1010my $c = App::Mobirc->new( 
    1111    { 
    12         httpd => { port => 3333, title => 'mobirc', lines => 40 }, 
     12        httpd => { lines => 40 }, 
    1313        global => { keywords => [qw/foo/], stopwords => [qw/foo31/], assets_dir => 'assets/' }, 
    1414    }