diff --git a/assets/template/root/test.html b/assets/template/root/test.html index 718cef9..8e89cc0 100644 --- a/assets/template/root/test.html +++ b/assets/template/root/test.html @@ -10,38 +10,12 @@ var dataStore = new Ext.data.Store({ model: 'Conversation', data: [ +: while $iter.next -> $d{ { - id : 1, - body: 'おい', - }, - { - id : 2, - body: 'こら', - }, - { - id : 3, - body: 'これは', - }, - { - id : 4, - body: 'テスト', - }, - { - id : 5, - body: 'です', - }, - { - id : 6, - body: 'おい', - }, - { - id : 7, - body: 'きいてんのか', - }, - { - id : 8, - body: 'おい', + id: <: $d.id() :>, + body: '<: $d.body() :>', }, +: } ] }); diff --git a/lib/SenchaStudy/Container.pm b/lib/SenchaStudy/Container.pm index 50e8a36..1945098 100644 --- a/lib/SenchaStudy/Container.pm +++ b/lib/SenchaStudy/Container.pm @@ -1,6 +1,13 @@ package SenchaStudy::Container; use Chiffon::Core; use Chiffon::Container -base; +use SenchaStudy::Model::DB; + +register 'db' => sub { + my $self = shift; + my $conf = $self->get('conf'); + SenchaStudy::Model::DB->new($conf->{datasource}->{master}); +}; 1; diff --git a/lib/SenchaStudy/Model/DB.pm b/lib/SenchaStudy/Model/DB.pm new file mode 100644 index 0000000..3efb7f5 --- /dev/null +++ b/lib/SenchaStudy/Model/DB.pm @@ -0,0 +1,8 @@ +package SenchaStudy::Model::DB; +use strict; +use warnings; +use utf8; +use DBIx::Skinny; +use DBIx::Skinny::Mixin modules => ['SearchWithPager']; + +1; diff --git a/lib/SenchaStudy/Model/DB/Schema.pm b/lib/SenchaStudy/Model/DB/Schema.pm new file mode 100644 index 0000000..1712ecc --- /dev/null +++ b/lib/SenchaStudy/Model/DB/Schema.pm @@ -0,0 +1,14 @@ +package SenchaStudy::Model::DB::Schema; +use strict; +use warnings; +use utf8; +use DBIx::Skinny::Schema; + +install_table conversation => schema { + pk 'id'; + columns qw/id body/; +}; + +install_utf8_columns qw/body/; + +1; diff --git a/lib/SenchaStudy/Web/C/Root.pm b/lib/SenchaStudy/Web/C/Root.pm index 1e3d34c..c8d7b81 100644 --- a/lib/SenchaStudy/Web/C/Root.pm +++ b/lib/SenchaStudy/Web/C/Root.pm @@ -12,7 +12,17 @@ sub do_slide { my ( $class, $c ) = @_; } -sub do_test{} +sub do_test{ + my ( $class, $c ) = @_; + my $con = container('db')->search( + 'conversation', + {}, + { + order_by => { id => 'asc' } + }, + ); + $c->stash->{iter} = $con; +} sub do_slide_list { my ( $class, $c ) = @_;