Changeset 10567
- Timestamp:
- 04/27/08 17:11:09 (7 months ago)
- Location:
- lang/perl/Nanto/trunk
- Files:
-
- 1 added
- 14 modified
- 2 moved
-
examples/SampleBBS/bin/nanto-server.pl (modified) (1 diff)
-
examples/SampleBBS/lib/SampleBBS/Factory/MobileAttribute.pm (added)
-
examples/SampleBBS/lib/SampleBBS/Web/C (moved) (moved from lang/perl/Nanto/trunk/examples/SampleBBS/lib/SampleBBS/C)
-
examples/SampleBBS/lib/SampleBBS/Web/C/Root.pm (modified) (2 diffs)
-
examples/SampleBBS/lib/SampleBBS/Web/Context.pm (modified) (1 diff)
-
examples/SampleBBS/lib/SampleBBS/Web/Dispatcher.pm (moved) (moved from lang/perl/Nanto/trunk/examples/SampleBBS/lib/SampleBBS/Dispatcher.pm) (1 diff)
-
examples/SampleBBS/lib/SampleBBS/Web/Handler.pm (modified) (1 diff)
-
examples/SampleBBS/samplebbs.sqlite (modified) (previous)
-
lib/Nanto/Config/Any.pm (modified) (1 diff)
-
lib/Nanto/Factory/DBIC.pm (modified) (1 diff)
-
lib/Nanto/Factory/MobileAttribute.pm (modified) (1 diff)
-
lib/Nanto/Role/Context.pm (modified) (3 diffs)
-
lib/Nanto/Web/Authorizer/Null.pm (modified) (1 diff)
-
lib/Nanto/Web/Context.pm (modified) (3 diffs)
-
lib/Nanto/Web/Handler.pm (modified) (1 diff)
-
lib/Nanto/Web/Role/Controller.pm (modified) (1 diff)
-
lib/Nanto/Web/View/TT.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Nanto/trunk/examples/SampleBBS/bin/nanto-server.pl
r10557 r10567 11 11 HTTP::Engine->new( 12 12 config => 'engine-config.yaml', 13 handle_request => sub { 14 my $c = shift; 15 my $handler = SampleBBS::Web::Handler->new( 16 context => SampleBBS::Web::Context->new( req => $c->req, res => $c->res ) 17 ); 18 $handler->handle(); 19 }, 13 handle_request => \&_handle_request, 20 14 )->run; 21 15 16 sub _handle_request { 17 my $c = shift; 18 my $handler = SampleBBS::Web::Handler->new( 19 context => SampleBBS::Web::Context->new( req => $c->req, res => $c->res ) 20 ); 21 $handler->handle(); 22 } -
lang/perl/Nanto/trunk/examples/SampleBBS/lib/SampleBBS/Web/C/Root.pm
r10556 r10567 1 package SampleBBS:: C::Root;1 package SampleBBS::Web::C::Root; 2 2 use Moose; 3 with 'Nanto:: Role::Controller';3 with 'Nanto::Web::Role::Controller'; 4 4 5 5 sub dispatch_index { … … 23 23 my $body = $c->req->params->{'body'}; 24 24 25 if ( $c-> is_post_request&& $body ) {25 if ( $c->req->method eq 'POST' && $body ) { 26 26 my $user_id = 'Anonymous Coward'; 27 27 $c->factory('DBIC')->resultset('Post')->create( { body => $body, userid => $user_id, } ); 28 28 } 29 29 30 $c->re direct( $c->dispatcher->uri_for({controller => 'Root', action => 'index'}) );30 $c->res->redirect( $c->dispatcher->uri_for({controller => 'Root', action => 'index'}) ); 31 31 } 32 32 -
lang/perl/Nanto/trunk/examples/SampleBBS/lib/SampleBBS/Web/Context.pm
r10556 r10567 2 2 use Moose; 3 3 extends 'Nanto::Web::Context'; 4 with 'Nanto::Plugin::Factory';5 4 6 use Nanto:: Authorizer::Null;7 sub create_authorizer { Nanto:: Authorizer::Null->new }5 use Nanto::Web::Authorizer::Null; 6 sub create_authorizer { Nanto::Web::Authorizer::Null->new } 8 7 9 use Nanto:: View::TT;8 use Nanto::Web::View::TT; 10 9 sub create_view { 11 my $view = Nanto:: View::TT->new;10 my $view = Nanto::Web::View::TT->new; 12 11 $view->tmpl_fname('tmpl/index.html'); 13 12 $view; -
lang/perl/Nanto/trunk/examples/SampleBBS/lib/SampleBBS/Web/Dispatcher.pm
r10530 r10567 1 package SampleBBS:: Dispatcher;1 package SampleBBS::Web::Dispatcher; 2 2 use strict; 3 3 use warnings; -
lang/perl/Nanto/trunk/examples/SampleBBS/lib/SampleBBS/Web/Handler.pm
r10557 r10567 1 package SampleBBS:: Handler;1 package SampleBBS::Web::Handler; 2 2 use Moose; 3 3 extends 'Nanto::Web::Handler'; -
lang/perl/Nanto/trunk/lib/Nanto/Config/Any.pm
r10530 r10567 4 4 use File::Spec::Functions; 5 5 use Carp; 6 use Config::Any; 6 7 7 8 with 'Nanto::Role::Config'; -
lang/perl/Nanto/trunk/lib/Nanto/Factory/DBIC.pm
r10544 r10567 1 package Nanto::Factory:: MobileAttribute;1 package Nanto::Factory::DBIC; 2 2 use Moose; 3 3 with 'Nanto::Role::Factory'; 4 4 5 override per_context => sub{ 1 };5 sub per_context { 1 }; 6 6 7 7 sub create { -
lang/perl/Nanto/trunk/lib/Nanto/Factory/MobileAttribute.pm
r10544 r10567 4 4 use HTTP::MobileAttribute; 5 5 6 override per_context => sub { 1 }; 6 sub per_context { 1 } 7 7 8 8 sub create { -
lang/perl/Nanto/trunk/lib/Nanto/Role/Context.pm
r10556 r10567 2 2 use strict; 3 3 use Moose::Role; 4 use UNIVERSAL::require; 4 5 5 6 with 'Nanto::Plugin::Factory'; … … 7 8 sub base_name { 8 9 my $self = shift; 10 (my $base_name = $self->local_base_name) =~ s/::[^:]+$//; 11 $base_name; 12 } 13 14 sub local_base_name { 15 my $self = shift; 9 16 my $proto = ref $self || $self; 10 (my $ base_name = $proto) =~ s/.+::Context//g;11 $ base_name;17 (my $local_base_name = $proto) =~ s/::Context.*//g; 18 $local_base_name; 12 19 } 13 20 … … 24 31 } 25 32 33 sub local_component { 34 my ($self, $moniker) = @_; 35 my $pkg = $self->local_base_name . "::$moniker"; 36 $pkg->use or die $@; 37 $pkg; 38 } 39 26 40 1; -
lang/perl/Nanto/trunk/lib/Nanto/Web/Authorizer/Null.pm
r10558 r10567 1 package Nanto:: Authorizer::Null;1 package Nanto::Web::Authorizer::Null; 2 2 use Moose; 3 3 -
lang/perl/Nanto/trunk/lib/Nanto/Web/Context.pm
r10556 r10567 1 package Nanto:: Context::Web;1 package Nanto::Web::Context; 2 2 use strict; 3 3 use Moose; … … 16 16 has view => ( 17 17 is => 'rw', 18 does => 'Nanto:: Role::View',18 does => 'Nanto::Web::Role::View', 19 19 default => sub { 20 20 my $self = shift; … … 25 25 sub dispatcher { 26 26 my $self = shift; 27 $self-> component('Dispatcher');27 $self->local_component('Dispatcher'); 28 28 } 29 29 30 30 sub create_authorizer { 31 31 my $self = shift; 32 $self-> component('Authorizer');32 $self->local_component('Authorizer'); 33 33 } 34 34 35 35 sub create_view { 36 36 my $self = shift; 37 $self-> component('V');37 $self->local_component('V'); 38 38 } 39 39 40 40 sub create_controller { 41 41 my ($self, $moniker) = @_; 42 my $pkg = join('::', $self-> base_name, $moniker);42 my $pkg = join('::', $self->local_base_name, 'C', $moniker); 43 43 $pkg->use or die $@; 44 $pkg; 44 45 } 45 46 -
lang/perl/Nanto/trunk/lib/Nanto/Web/Handler.pm
r10558 r10567 1 package Nanto:: Handler;1 package Nanto::Web::Handler; 2 2 use Moose; 3 3 with 'Nanto::Web::Role::Handler'; -
lang/perl/Nanto/trunk/lib/Nanto/Web/Role/Controller.pm
r10557 r10567 8 8 return if $c->finished; 9 9 10 if ($c-> is_post_request) {10 if ($c->req->method eq 'POST') { 11 11 my $meth = "post_dispatch_$page"; 12 12 if ($self->can($meth)) { -
lang/perl/Nanto/trunk/lib/Nanto/Web/View/TT.pm
r10558 r10567 1 package Nanto:: View::TT;1 package Nanto::Web::View::TT; 2 2 use Moose; 3 3 use Template;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)