Catalyst-Example-InstantCRUD-0.0.32/0000755000175000017500000000000011221745410015234 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/t/0000755000175000017500000000000011221745410015477 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/t/tmp/0000755000175000017500000000000011221745410016277 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/t/tmp/test.db0000644000175000017500000002200011221740574017565 0ustar zbyzbySQLite format 3@  mOe%%mtablecomposed_keycomposed_keyCREATE TABLE composed_key( id1 integer, id2 integer, value varchar(32), primary key (id1, id2) )7K%indexsqlite_autoindex_composed_key_1composed_key ~OtablebookmarkbookmarkCREATE TABLE bookmark( id serial primary key, usr integer, foreign key (usr) references usr(id) )/Cindexsqlite_autoindex_bookmark_1bookmark;_tableusrusrCREATE TABLE usr( id serial primary key )%9indexsqlite_autoindex_usr_1usr3##-tablesecondtablesecondtableCREATE TABLE secondtable( id integer primary key, firstableid integer, charfield char(10), foreign key (firstableid) references firsttable(id) )!!ktablefirsttablefirsttableCREATE TABLE firsttable ( id integer primary key, intfield integer, charfield char(10), varfield varchar(100) ) tkDZ3 pI"tt%Ebbbaaaaaaaaaaaaaaaaaaaaaaaaaaaa.WaaaThis is the row with the smallest int.U'aaaThis is the row with the biggest int%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa% Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa% Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa% Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa% Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa% Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%Eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'Ea7aChanged varchar field7aaaThis is the first row  ~~~ aaa aaa aaa bbb bbbbbbbbbbbbbbbbbbbbbbbbbbb     %C random pWvMNr5FWyEC3Vr7rnBy bbb   Catalyst-Example-InstantCRUD-0.0.32/t/var/0000755000175000017500000000000011221745410016267 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/t/var/test.sql0000644000175000017500000000556211210747745020012 0ustar zbyzbyBEGIN TRANSACTION; CREATE TABLE firsttable ( id integer primary key, intfield integer, charfield char(10), varfield varchar(100) ); INSERT INTO "firsttable" VALUES(1,1,'aaa','This is the first row'); INSERT INTO "firsttable" VALUES(2,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(3,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(4,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(5,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(6,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(7,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(8,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(9,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(10,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(11,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(12,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(13,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(14,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(15,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(16,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(17,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(18,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(19,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(20,1,'aaa','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); INSERT INTO "firsttable" VALUES(21,9999,'aaa','This is the row with the biggest int'); INSERT INTO "firsttable" VALUES(22,0,'aaa','This is the row with the smallest int'); INSERT INTO "firsttable" VALUES(23,1,'bbb','aaaaaaaaaaaaaaaaaaaaaaaaaaaa'); CREATE TABLE secondtable( id integer primary key, firstableid integer, charfield char(10), foreign key (firstableid) references firsttable(id) ); INSERT INTO "secondtable" VALUES(1,1,'bbb'); INSERT INTO "secondtable" VALUES(2,1,'bbb'); INSERT INTO "secondtable" VALUES(3,1,'bbb'); INSERT INTO "secondtable" VALUES(4,1,'bbb'); INSERT INTO "secondtable" VALUES(5,1,'bbb'); INSERT INTO "secondtable" VALUES(6,1,'bbb'); INSERT INTO "secondtable" VALUES(7,1,'bbb'); INSERT INTO "secondtable" VALUES(8,1,'bbb'); INSERT INTO "secondtable" VALUES(9,1,'bbb'); INSERT INTO "secondtable" VALUES(10,1,'bbb'); INSERT INTO "secondtable" VALUES(11,2,'aaa'); INSERT INTO "secondtable" VALUES(12,3,'aaa'); INSERT INTO "secondtable" VALUES(13,4,'aaa'); CREATE TABLE usr( id serial primary key ); CREATE TABLE bookmark( id serial primary key, usr integer, foreign key (usr) references usr(id) ); CREATE TABLE composed_key( id1 integer, id2 integer, value varchar(32), primary key (id1, id2) ); INSERT INTO "composed_key" VALUES(1,1,'bbb'); COMMIT; Catalyst-Example-InstantCRUD-0.0.32/t/pod.t0000644000175000017500000000021411200774502016444 0ustar zbyzby#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Catalyst-Example-InstantCRUD-0.0.32/t/20.create_dvdzbr.t0000644000175000017500000000050011200774502020716 0ustar zbyzbyuse strict; use warnings; use Test::More tests => 1; use Path::Class; use File::Path; use File::Copy; my $app = 'DVDzbr'; my $lcapp = lc $app; rmtree( ["t/tmp/$app", "t/tmp/$lcapp.db"] ); `cd t/tmp; $^X -I../../lib ../../script/instantcrud.pl $app`; ok( -f "t/tmp/$app/lib/$app/DBSchema.pm", 'DBSchema creation'); Catalyst-Example-InstantCRUD-0.0.32/t/30.create_rest.t0000644000175000017500000000051311201254360020401 0ustar zbyzbyuse strict; use warnings; use Test::More tests => 1; use Path::Class; use File::Path; use File::Copy; my $app = 'DVDzbr_rest'; my $lcapp = lc $app; rmtree( ["t/tmp/$app", "t/tmp/$lcapp.db"] ); `cd t/tmp; $^X -I../../lib ../../script/instantcrud.pl $app -rest`; ok( -f "t/tmp/$app/lib/$app/DBSchema.pm", 'DBSchema creation'); Catalyst-Example-InstantCRUD-0.0.32/t/21.test_dvdzbr.t0000644000175000017500000001015411203760101020432 0ustar zbyzbyuse strict; use warnings; use Test::More; BEGIN { use lib 't/tmp/DVDzbr/lib'; } eval "use Test::WWW::Mechanize::Catalyst 'DVDzbr'"; if ($@){ plan skip_all => "Test::WWW::Mechanize::Catalyst required for testing application"; }else{ plan tests => 20; #plan tests => 'no_plan'; } my $mech = Test::WWW::Mechanize::Catalyst->new; $mech->get_ok("http://localhost/", "Application Running"); # $mech->content_lacks("dvdtag", "Do not list the relation tables"); # $mech->content_lacks("user_role", "Do not list the relation tables"); # # $mech->follow_link_ok({text => 'Restricted Area'}, "Go to restricted area"); # # $mech->content_like(qr/Username.*Password/, "Login Requested"); # $mech->submit_form( # form_number => 1, # fields => { # username => 'jgda', # password => 'jonas', # }, # ); # # $mech->follow_link_ok({text => 'Restricted Area'}, "Go to restricted area"); # $mech->content_contains("This is the restricted area", "Yes, we are logged in"); $mech->follow_link_ok({text => 'Tag'}, "Click on tag"); $mech->follow_link_ok({text => 'Add'}, "Let's add a tag :)"); $mech->submit_form( form_number => 1, fields => { name => 'TestTag', #dvdtags => 0, } ); $mech->follow_link_ok({text => 'List'}, "Let's list them all"); $mech->follow_link_ok({text => 'Name'}, "Let's sort them"); $mech->content_contains("TestTag", "Yes, our tag is listed"); $mech->get_ok("/user/edit", "Adding a User"); $mech->submit_form( form_number => 1, fields => { name => 'Zbigniew Lukasiak', username => 'zby', password => 'zby', #dvd_owners => 0, #dvd_current_owners => 0, #user_roles => 0, }, ); # $mech->content_contains("Confirm the password", "Password constraint"); # # $mech->submit_form( # form_number => 1, # fields => { # name => 'Zbigniew Lukasiak', # username => 'zby', # password => 'zby', # password_2 => 'zbyyyy', # # #dvd_owners => 0, # #dvd_current_owners => 0, # #user_roles => 0, # } # ); # $mech->content_contains("Passwords must match", "Password constraint"); # # $mech->submit_form( # form_number => 1, # fields => { # name => 'Zbigniew Lukasiak', # username => 'zby', # password => 'zby', # password_2 => 'zby', # # #dvd_owners => 0, # #dvd_current_owners => 0, # #user_roles => 0, # } # ); $mech->content_contains('Zbigniew Lukasiak', "User added"); $mech->get_ok("/user/list", "Listing Users"); $mech->content_contains("Zbigniew Lukasiak", "User listed"); $mech->get_ok("/dvd/edit", "Adding a DVD with a related Tag"); # Hack to simulate the selection of a value in the double select #$mech->form_number(1)->push_input(option => {name => 'tags', value => '1' }); $mech->submit_form( form_number => 1, fields => { name => 'Jurassic Park II', tags => 1, owner => 1, current_owner => 2, hour => '10:00', 'creation_date.year' => '1990', 'creation_date.month' => '08', 'creation_date.day' => '23', 'alter_date.year' => '2000', 'alter_date.month' => '02', 'alter_date.day' => '17', imdb_id => 133, } ); $mech->content_contains('Jurassic Park II', "DVD added"); $mech->content_like(qr/Tags[^A]+Action/, "DVD added with Tag"); $mech->get_ok("/dvd/list", "Listing DVD's"); $mech->content_contains("Jurassic Park II", "DVD Listed"); $mech->content_contains("Action", "Related Tag Listed"); $mech->follow_link_ok({text => 'Edit'}, "Editing a DVD"); $mech->submit_form( form_number => 1, fields => { name => 'Big Fish', #dvdtags => 0, owner => 1, current_owner => 2, hour => '10:00', 'creation_date.year' => '1990', 'creation_date.month' => '08', 'creation_date.day' => '23', 'alter_date.year' => '2000', 'alter_date.month' => '02', 'alter_date.day' => '17', imdb_id => 133, } ); $mech->content_like(qr/Name[^B]+Big Fish/, "DVD eddited"); $mech->get_ok("/dvd/list", "Listing DVD's"); $mech->content_contains("Big Fish", "DVD Listed"); Catalyst-Example-InstantCRUD-0.0.32/t/00.createapp.t0000644000175000017500000000257311210767267020071 0ustar zbyzbyuse strict; use warnings; use Test::More tests => 2; use Path::Class; use File::Path; use DBI; my $apptree = dir('t', 'tmp', 'My-App'); my $dbfile = file('t', 'tmp', 'test.db'); rmtree( [$apptree, $dbfile] ); my $testfile = file('t', 'tmp', 'test.db')->absolute->stringify; my $sqlfile = file('t', 'var', 'test.sql')->absolute->stringify; create_example_db( $testfile, $sqlfile ); my $tmpdir = dir(qw/ t tmp/); my $libdir = dir(dir()->parent->parent, 'lib'); my $instant = file(dir()->parent->parent, 'script', 'instantcrud.pl'); my $currdir = dir()->absolute; chdir $tmpdir; my $line = "$^X -I$libdir ../../script/instantcrud.pl My::App -dsn='dbi:SQLite:dbname=$testfile' -noauth"; warn $line; `$line`; chdir $currdir; ok( -f file(qw/ t tmp My-App lib My App DBSchema.pm/), 'DBSchema creation'); ok( -f file( qw/ t tmp My-App lib My App Controller Usr.pm / ), 'Controller for "User" created'); sub create_example_db { my ( $filename, $sqlfile ) = @_; my $dsn ||= 'dbi:SQLite:dbname=' . $filename; my $dbh = DBI->connect( $dsn ) or die "Cannot connect to $dsn\n"; $dbh->{unicode} = 1; my $sqlfh; open $sqlfh, $sqlfile; my $sql; { local $/; $sql = <$sqlfh>; } for my $statement ( split /;/, $sql ){ next if $statement =~ /\A\s*\z/; # warn "executing: \n$statement"; $dbh->do($statement) or die $dbh->errstr; } } Catalyst-Example-InstantCRUD-0.0.32/t/10.apptest.t0000644000175000017500000000513511220230231017554 0ustar zbyzbyuse strict; use warnings; use Test::More; use String::Random qw(random_string random_regex); use DBI; BEGIN { use lib 't/tmp/My-App/lib'; } eval "use Test::WWW::Mechanize::Catalyst 'My::App'"; if ($@){ plan skip_all => "Test::WWW::Mechanize::Catalyst required for testing application"; }else{ plan tests => 22; } my $mech = Test::WWW::Mechanize::Catalyst->new; $mech->get_ok("http://localhost/", "Application Running"); $mech->follow_link_ok({text => 'Firsttable'}, "Click on firsttable"); $mech->follow_link_ok({text => 'Intfield'}, "sort by intfield"); $mech->content_contains("This is the row with the smallest int", "smallest int row found"); $mech->follow_link_ok({text => 'Intfield'}, "desc sort by intfield"); $mech->content_contains("This is the row with the biggest int", "biggest int row found"); $mech->follow_link_ok({text => '3'}, "desc sort by intfield page 3"); $mech->content_contains("This is the row with the smallest int", "smallest int row found"); $mech->get_ok("/firsttable/edit/2", "Edit fisttable 2nd record"); $mech->submit_form( form_number => 1, fields => { intfield => '3', varfield => 'Changed varchar field', charfield => 'a', } ); $mech->follow_link_ok({text => 'Firsttable'}, "Click on firsttable"); $mech->content_contains("Changed varchar field", "Record changed"); $mech->get_ok("/firsttable/destroy/2", "Destroy 2nd record"); $mech->submit_form( form_number => 1 ); $mech->content_lacks("Changed varchar field", "Record deleted"); $mech->follow_link_ok({text => 'ComposedKey'}, "Click on composed key table"); $mech->follow_link_ok({text => 'Add'}, "Click on composed key Add row"); my $id1 = int(rand(1000000)); my $id2 = int(rand(1000000)); $mech->submit_form( form_number => 1, fields => { id1 => $id1, id2 => $id2, value => 'Varchar Field', } ); $mech->content_like( qr{Id1:\s*\s*$id1}, 'Viewing record with composed key' ); $mech->follow_link_ok({text => 'Edit'}, "Editing a record with composed key"); $mech->content_contains( $id1, 'Following Edit for a record with composed key' ); my $random_string = 'random ' . random_regex('\w{20}'); #DBI->trace(1); $mech->submit_form( form_number => 1, fields => { value => $random_string, } ); $mech->content_contains( $id1, 'Editing record with composed key' ); $mech->content_contains( $random_string, 'Editing record with composed key' ); $mech->follow_link_ok({text => 'List'}, "Listing records with composed key"); $mech->content_contains( $random_string, 'Listing of records with composed key contains the new record' ); Catalyst-Example-InstantCRUD-0.0.32/t/00.load.t0000644000175000017500000000043411200774502017023 0ustar zbyzbyuse Test::More tests => 3; BEGIN { use_ok( 'Catalyst::Example::Controller::InstantCRUD' ); use_ok( 'Catalyst::Helper::Controller::InstantCRUD' ); use_ok( 'Catalyst::Example::InstantCRUD'); } diag( "Testing Catalyst::Example::InstantCRUD $Catalyst::Example::InstantCRUD::VERSION" ); Catalyst-Example-InstantCRUD-0.0.32/t/31.test_rest.t0000644000175000017500000000114011203245253020116 0ustar zbyzbyuse strict; use warnings; use Test::More; BEGIN { use lib 't/tmp/DVDzbr_rest/lib'; } eval "use Test::WWW::Mechanize::Catalyst 'DVDzbr_rest'"; if ($@){ plan skip_all => "Test::WWW::Mechanize::Catalyst required for testing application"; }else{ plan tests => 2; #plan tests => 'no_plan'; } my $mech = Test::WWW::Mechanize::Catalyst->new; $mech->get_ok("http://localhost/", "Application Running"); $mech->default_header( 'Content-Type' => "text/x-json"); $mech->default_header( 'Accept' => "text/x-json"); $mech->get_ok("http://localhost/dvd/by_id/2", "GET dvd object"); #warn $mech->content; Catalyst-Example-InstantCRUD-0.0.32/t/pod-coverage.t0000644000175000017500000000037511203236524020245 0ustar zbyzby#!perl -T use Test::More; if (!$ENV{AUTHOR_TEST}) { plan skip_all => 'Author test'; } else{ eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; } all_pod_coverage_ok(); Catalyst-Example-InstantCRUD-0.0.32/lib/0000755000175000017500000000000011221745410016002 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/0000755000175000017500000000000011221745410017566 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Helper/0000755000175000017500000000000011221745410021005 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Helper/View/0000755000175000017500000000000011221745410021717 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Helper/View/InstantCRUD.pm0000644000175000017500000004075211221740552024365 0ustar zbyzbypackage Catalyst::Helper::View::InstantCRUD; use version; $VERSION = qv('0.0.7'); use warnings; use strict; use Carp; use Path::Class; use List::Util qw(first); sub mk_compclass { my ( $self, $helper, $schema, $m2m, $bridges ) = @_; my $file = $helper->{file}; $helper->render_file( 'compclass', $file ); my @classes = map { $bridges->{ $_ } ? () : $_ } $schema->sources; my $dir = dir( $helper->{dir}, 'root' ); $helper->mk_dir($dir); # TT View $helper->mk_component( $helper->{app}, 'view', $helper->{name}, 'TT' ); # table menu my $table_menu = '| Home | Restricted Area |'; for my $c (@classes) { $table_menu .= ' $c |}; } $helper->mk_file( file( $dir, 'table_menu.tt' ), $table_menu ); # static files $helper->render_file( home => file( $dir, 'home.tt' ) ); $helper->render_file( restricted => file( $dir, 'restricted.tt' ) ); $helper->mk_file( file( $dir, 'wrapper.tt' ), $helper->get_file( __PACKAGE__, 'wrapper' ) ); $helper->mk_file( file( $dir, 'login.tt' ), $helper->get_file( __PACKAGE__, 'login' ) ); $helper->mk_file( file( $dir, 'pager.tt' ), $helper->get_file( __PACKAGE__, 'pager' ) ); # $helper->mk_file( file( $dir, 'destroy.tt' ), $helper->get_file( __PACKAGE__, 'destroy' ) ); my $staticdir = dir( $helper->{dir}, 'root', 'static' ); $helper->mk_dir( $staticdir ); $helper->render_file( style => file( $staticdir, 'pagingandsort.css' ) ); $helper->render_file( form_style => file( $staticdir, 'form.css' ) ); # javascript # $helper->mk_file( file( $staticdir, 'doubleselect.js' ), # HTML::Widget::Element::DoubleSelect->js_lib ); # templates for my $class (@classes){ my $classdir = dir( $helper->{dir}, 'root', lc $class ); $helper->mk_dir( $classdir ); $helper->mk_file( file( $classdir, $_ . '.tt'), $helper->get_file( __PACKAGE__, $_ ) ) for qw/edit destroy/; $helper->{field_configs} = _get_column_config( $schema, $class, $m2m ) ; my $source = $schema->source($class); $helper->{primary_keys} = [ $source->primary_columns ]; $helper->render_file( list => file( $classdir, 'list.tt' )); $helper->render_file( view => file( $classdir, 'view.tt' )); } return 1; } sub _mk_label { my $name = shift; return join ' ', map { ucfirst } split '_', $name; } sub _get_column_config { my( $schema, $class, $m2m ) = @_; my @configs; my $source = $schema->source($class); my %bridge_cols; for my $rel ( $source->relationships ) { my $info = $source->relationship_info($rel); $bridge_cols{$_} = 1 for _get_self_cols( $info->{cond} ); $m2m->{$class} and next if first { $_->[1] eq $rel } @{$m2m->{$class}}; my $config = { name => $rel, label => _mk_label( $rel ), }; $config->{multiple} = 1 if $info->{attrs}{accessor} eq 'multi'; push @configs, $config; } for my $column ( $source->columns ) { next if $bridge_cols{$column}; push @configs, { name => $column, label => _mk_label( $column ), }; } if( $m2m->{$class} ) { for my $m ( @{$m2m->{$class}} ){ push @configs, { name => $m->[0], label => _mk_label( $m->[0] ), multiple => 1, }; } } return \@configs; } sub _get_self_cols{ my $cond = shift; my @cols; if ( ref $cond eq 'ARRAY' ){ for my $c1 ( @$cond ){ push @cols, get_self_cols( $c1 ); } } elsif ( ref $cond eq 'HASH' ){ for my $key ( values %{$cond} ){ if( $key =~ /self\.(.*)/ ){ push @cols, $1; } } } return @cols; } 1; # Magic true value required at end of module __DATA__ =begin pod_to_ignore __compclass__ package [% class %]; use strict; use base 'Catalyst::View::TT'; __PACKAGE__->config( TEMPLATE_EXTENSION => '.tt', ENCODING => 'UTF-8', ); =head1 NAME [% class %] - TT View for [% app %] =head1 DESCRIPTION TT View for [% app %]. =head1 AUTHOR =head1 SEE ALSO L<[% app %]> [% author %] =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; __list__ [% TAGS <+ +> %] <+ FOR column = field_configs +> <+- IF column.multiple -+> <+ ELSE +> <+ END +> <+ END +> [% WHILE (row = result.next) %] <+ FOR column = field_configs +> <+ END +> [% SET id = row.$pri %] [% END %]
<+ column.name +> [% order_by_column_link('<+ column.name +>', '<+ column.label+>') %]
<+ IF column.multiple +> [% FOR val = row.<+ column.name +>; val; ', '; END %] <+ ELSE +> [% row.<+ column.name +> %] <+ END +> View Edit Destroy
[% PROCESS pager.tt %]
Add __view__ [% TAGS <+ +> %] <+ FOR column = field_configs +> <+ END +>
<+ column.label +>: <+ IF column.multiple +> [% FOR val = item.<+ column.name +>; val; ', '; END %] <+ ELSE +> [% item.<+ column.name +> %] <+ END +>

Edit
List __wrapper__ [% appname %]
[% PROCESS table_menu.tt %]
[% content %]
__login__ [% widget %] __edit__ [% widget %]
List
[% form %] __pager__ [% IF pager %]
Page [% pager.current_page %] of [% pager.last_page %]
[% IF pager.previous_page %] « < [% END %] [% start = (pager.current_page - 3) > 0 ? (pager.current_page - 3) : 1; end = (pager.current_page + 3) < pager.last_page ? (pager.current_page + 3) : pager.last_page; FOREACH page IN [ start .. end ] %] [% IF pager.current_page == page %] [% page %] [% ELSE %] [% page %] [% END %] [% END %] [% IF pager.next_page %] > » [% END %]
[% END %] __destroy__ [% destroywidget %]
List __restricted__ This is the restricted area - available only after loggin in. __home__ This is an application generated by Catalyst::Example::InstantCRUD - a generator of simple database applications for the Catalyst framework. See also Catalyst::Manual::Intro and Catalyst::Manual::Intro __style__ /* HTML TAGS */ body { font: bold 12px Verdana, sans-serif; background-color:#F8F8F8; color: #00283F; } .table_menu { text-align: center; font-size: 16px; padding: 15px 15px 15px 15px; color: #7CBFE5; } .content { clear: both; padding: 30px 12px 12px 12px; font-size: 16px; } hr { border: 1px solid #7CBFE5; margin: 10px 0 15px 0; } A { text-decoration: none; color:#006DAC; font-weight: bold; } A:visited { color:#0073B5; } A:hover { text-decoration: underline; color:#006DAC; } #title { z-index: 6; width: 100%; height: 18px; margin-top: 10px; font-size: 90%; border-bottom: 1px solid #ddf; text-align: left; } input.submit:hover { color: #fff; background-color: #7d95b5; } table { margin: 0 auto 20px auto; background-color: #ffffff; border-collapse: collapse; } table .view_label{ background-color: #DFF6E6; } th { background-color: #DFF6E6; border: 1px solid #7CBFE5; font: bol 14px Verdana, sans-serif; padding: 4px 4px 4px 4px; } tr.alternate { background-color:#e3eaf0; } tr:hover { background-color: #b5cadc; } td { font: 14px Verdana, sans-serif; border: 1px solid #7CBFE5; padding: 4px 4px 4px 4px; } .action { border: 1px outset #7d95b5; } .action:hover { color: #fff; text-decoration: none; background-color: #7d95b5; } .pager { font: bold 14px Verdana, sans-serif; color: #7CBFE5; text-align: center; border: solid 1px #e2e2e2; border-left: 0; border-right: 0; padding: 15px 0 15px 0; background-color: #EBF8EF; } .pager .counter{ padding: 0 0 10px 0; } .pager a { padding: 2px 6px 2px 6px; } .pager a:hover { color: #fff; background: #7d95b5; text-decoration: none; } .pager .current { padding: 2px 6px; font-weight: bold; vertical-align: top; } .pager .current-page { padding: 2px 6px; font-weight: bold; vertical-align: top; } __form_style__ fieldset { padding: 12px 12px 12px 12px; border: 1px solid #7CBFE5; background-color: #FFFFFF; } .main_fieldset { font-size: 12px; } .main_fieldset fieldset { margin: 20px 0 20px 0; } fieldset input, fieldset password, fieldset radio, fieldset select, fieldset textarea { margin: 8px 0 8px 0; } label { float: left; width: 120px; margin: 8px 10px 8px 0; text-align: right; } .main_fieldset fieldset label{ width: 108px; font-weight: normal; } fieldset .error_message { display: block; color: #ff0000; margin: 20px 0 20px 0; } fieldset .error input, fieldset .error textarea, fieldset .error select { background-color: #FFF0F0; border: 1px solid #ff0000; } #submit{ margin: 20px 0 10px 0; padding: 2px 2px 2px 2px; background-color:#DFF6E6;; font: bold 14px Verdana, sans-serif; color:#006DAC; } fieldset .radiogroup span label { /* undo the above style */ float: none; width: auto; text-align: left; padding-right: 0; } fieldset.checkboxgroup, fieldset.radiogroup { margin: 0; margin-left: 12em; padding: 0; width: auto; } fieldset.radiogroup.label { border: 0; margin-left: 0em; } __END__ =head1 NAME Catalyst::Helper::Controller::InstantCRUD - [One line description of module's purpose here] =head1 VERSION This document describes Catalyst::Helper::Controller::InstantCRUD version 0.0.1 =head1 SYNOPSIS use Catalyst::Helper::Controller::InstantCRUD; =for author to fill in: Brief code example(s) here showing commonest usage(s). This section will be as far as many users bother reading so make it as educational and exeplary as possible. =head1 DESCRIPTION =for author to fill in: Write a full description of the module and its features here. Use subsections (=head2, =head3) as appropriate. =head2 METHODS =over 4 =item mk_compclass =back =head1 INTERFACE =for author to fill in: Write a separate section listing the public components of the modules interface. These normally consist of either subroutines that may be exported, or methods that may be called on objects belonging to the classes provided by the module. =head1 DIAGNOSTICS =for author to fill in: List every single error and warning message that the module can generate (even the ones that will "never happen"), with a full explanation of each problem, one or more likely causes, and any suggested remedies. =over =item C<< Error message here, perhaps with %s placeholders >> [Description of error here] =item C<< Another error message here >> [Description of error here] [Et cetera, et cetera] =back =head1 CONFIGURATION AND ENVIRONMENT =for author to fill in: A full explanation of any configuration system(s) used by the module, including the names and locations of any configuration files, and the meaning of any environment variables or properties that can be set. These descriptions must also include details of any configuration language used. Catalyst::Helper::Controller::InstantCRUD requires no configuration files or environment variables. =head1 DEPENDENCIES =for author to fill in: A list of all the other modules that this module relies upon, including any restrictions on versions, and an indication whether the module is part of the standard Perl distribution, part of the module's distribution, or must be installed separately. ] None. =head1 INCOMPATIBILITIES =for author to fill in: A list of any modules that this module cannot be used in conjunction with. This may be due to name conflicts in the interface, or competition for system or program resources, or due to internal limitations of Perl (for example, many modules that use source code filters are mutually incompatible). None reported. =head1 BUGS AND LIMITATIONS =for author to fill in: A list of known problems with the module, together with some indication Whether they are likely to be fixed in an upcoming release. Also a list of restrictions on the features the module does provide: data types that cannot be handled, performance issues and the circumstances in which they may arise, practical limitations on the size of data sets, special cases that are not (yet) handled, etc. No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR C<< <> >> Paginator adapted from example by Oliver Charles. =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, C<< <> >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Catalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Helper/Model/0000755000175000017500000000000011221745410022045 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Helper/Model/InstantCRUD.pm0000644000175000017500000001221611200774502024504 0ustar zbyzbypackage Catalyst::Helper::Model::InstantCRUD; use version; $VERSION = qv('0.0.2'); use warnings; use strict; use Carp; use Path::Class; use Catalyst::Example::InstantCRUD::Utils; use Data::Dumper; sub mk_compclass { my ( $self, $helper, $schema, $dsn, $user, $password, $options, $attrs ) = @_; my $schemaclass = $helper->{app} . "::$schema"; # Create the DBIC Schema Model $helper->mk_component( $helper->{app}, 'model', $helper->{name}, 'DBIC::Schema', $schemaclass, $dsn, $user, $password ); $attrs ||= Catalyst::Example::InstantCRUD::Utils->load_schema( dsn => $dsn, user => $user, password => $password ); my $schemadir = file( $helper->{file} )->parent->parent->subdir($schema); $helper->mk_dir( $schemadir ); # Schema classes $helper->{schema} = $schemaclass; my @classes; for my $table ( keys %{ $attrs->{tables} } ) { $helper->{package} = $helper->{app} . "::" . $attrs->{tables}{$table}{c}; $helper->{class} = $attrs->{tables}{$table}{c}; $helper->{relationships} = $attrs->{rels}{ $helper->{class} }; #my %elements = map { $_ => 1 } @{$attrs->{elems}{$helper->{class}}}; my %elements = map { $_ => 1 } @{ $attrs->{tables}{$table}{qw/cols/} }, @{ $attrs->{tables}{$table}{qw/relationships/} }; $helper->{elements} = join ' ', keys %elements; $helper->{pks} = join ' ', @{ $attrs->{tables}{$table}{pks} }; $helper->{overload_method} = $attrs->{tables}{$table}{overload_method}; $helper->{columns} = $attrs->{tables}{$table}{columns}; $helper->{table} = $table; my $source = $attrs->{tables}{$table}{source}; push @classes, $source; my $file = dir( $schemadir, "$source.pm" ); $helper->render_file( schemaclass => $file ); } # Schema base class my $file = dir( $schemadir, 'base.pm' ); $helper->render_file( baseclass => $file ); # Schema class $helper->{classes} = join ' ', @classes; $file = $schemadir . ".pm"; $helper->render_file( schema => $file ); return 1; } # No test file sub mk_comptest { } 1; __DATA__ =begin pod_to_ignore __schemaclass__ package [% package %]; use strict; use warnings; use base qw/[% schema %]::base/; # Stringifies to the first primary key. # Change it to what makes more sense. # Is that value that appears in HTML Select's and things like that. [% IF overload_method %]use overload '""' => sub {$_[0]->[% overload_method %]}, fallback => 1;[% END %] __PACKAGE__->table('[% table %]'); __PACKAGE__->add_columns(qw/[% FOR col = columns; col; ' '; END %]/); __PACKAGE__->set_primary_key(qw/[% pks %]/); [% relationships %] 1; __baseclass__ package [% schema %]::base; use strict; use warnings; use base 'DBIx::Class'; __PACKAGE__->load_components(qw/DigestColumns Core/); #__PACKAGE__->load_components(qw/InstantCRUD DigestColumns InflateColumn::DateTime Core/); 1; __schema__ package [% schema %]; use base qw/DBIx::Class::Schema/; __PACKAGE__->load_classes(qw/[% classes %]/); 1; __END__ =head1 NAME Catalyst::Helper::Model::InstantCRUD =head1 VERSION This document describes Catalyst::Helper::Model::InstantCRUD =head1 SYNOPSIS use Catalyst::Helper::Controller::InstantCRUD; =head1 DESCRIPTION =head2 METHODS =over 4 =item mk_compclass =item mk_comptest =back =head1 INTERFACE =head1 DIAGNOSTICS =over =item C<< Error message here, perhaps with %s placeholders >> [Description of error here] =item C<< Another error message here >> [Description of error here] [Et cetera, et cetera] =back =head1 AUTHOR C<< <> >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, C<< <> >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Catalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Helper/InstantCRUD.pm0000644000175000017500000002032611200774502023445 0ustar zbyzbypackage Catalyst::Helper::InstantCRUD; use base Catalyst::Helper; use Path::Class; use version; $VERSION = qv('0.0.7'); use warnings; use strict; sub _mk_appclass { my $self = shift; my $mod = $self->{mod}; $self->render_file( 'appclass', "$mod.pm" ); } sub _mk_rootclass { my $self = shift; $self->render_file( 'rootclass', file( $self->{c}, "Root.pm" ) ); } sub _mk_config { my $self = shift; my $dir = $self->{dir}; my $appprefix = $self->{appprefix}; $self->render_file( 'config', file( $dir, "$appprefix.yml" ) ); } # No CHANGES file (already created) sub _mk_changes {} 1; __DATA__ =begin pod_to_ignore __appclass__ use strict; use warnings; package [% name %]; use Catalyst::Runtime '5.70'; [% IF rest %]use Catalyst::Request::REST::ForBrowsers;[% END %] use Catalyst qw/ -Debug ConfigLoader Static::Simple Unicode [% IF auth -%] [% END -%] /; # Session # Session::Store::FastMmap # Session::State::Cookie # Authentication # Authentication::Store::DBIC # Authentication::Credential::Password # Auth::Utils our $VERSION = '0.01'; __PACKAGE__->config( name => '[% name %]' ); [% IF rest %]__PACKAGE__->request_class( 'Catalyst::Request::REST::ForBrowsers' );[% END %] # Start the application __PACKAGE__->setup; # # IMPORTANT: Please look into [% rootname %] for more # =head1 NAME [% name %] - Catalyst based application =head1 SYNOPSIS script/[% appprefix %]_server.pl =head1 DESCRIPTION Catalyst based application. =head1 SEE ALSO L<[% rootname %]>, L =head1 AUTHOR [% author %] =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; __rootclass__ package [% rootname %]; use strict; use warnings; use base 'Catalyst::Controller'; # # Sets the actions in this controller to be registered with no prefix # so they function identically to actions created in MyApp.pm # __PACKAGE__->config->{namespace} = ''; =head1 NAME [% rootname %] - Root Controller for this Catalyst based application =head1 SYNOPSIS See L<[% name %]>. =head1 DESCRIPTION Root Controller for this Catalyst based application. =head1 METHODS =cut =head2 default By default all the pages return 404 =cut sub default : Private { my ( $self, $c ) = @_; $c->response->status(404); $c->response->body("404 Not Found"); }; =head2 index =cut sub index : Private{ my ( $self, $c ) = @_; my @additional_paths = ( $c->config->{root} ); $c->stash->{additional_template_paths} = \@additional_paths; $c->stash->{template} = 'home.tt'; } [% IF auth %] =head2 restricted Action available only for logged in users. Checks if user is logged in, if not, forwards to login page. =cut # sub restricted : Local : ActionClass('Auth::Check') { # my ( $self, $c ) = @_; # } =head2 login Login logic =cut # sub login : Local : ActionClass('Auth::Login') {} =head2 logout Logout logic =cut # sub logout : Local : ActionClass('Auth::Logout') {} [% END %] =head2 end Attempt to render a view, if needed. =cut sub end : ActionClass('RenderView') {} =head1 AUTHOR [% author %] =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; __config__ --- name: [% name %] View::TT: WRAPPER: 'wrapper.tt' InstantCRUD: model_name: [% model_name %] schema_name: [% schema_name %] maxrows: 10 __END__ =head1 NAME Catalyst::Helper::Controller::InstantCRUD - [One line description of module's purpose here] =head1 VERSION This document describes Catalyst::Helper::Controller::InstantCRUD version 0.0.1 =head1 SYNOPSIS use Catalyst::Helper::Controller::InstantCRUD; =for author to fill in: Brief code example(s) here showing commonest usage(s). This section will be as far as many users bother reading so make it as educational and exeplary as possible. =head1 DESCRIPTION =for author to fill in: Write a full description of the module and its features here. Use subsections (=head2, =head3) as appropriate. =head2 METHODS =over 4 =item mk_compclass =back =head1 INTERFACE =for author to fill in: Write a separate section listing the public components of the modules interface. These normally consist of either subroutines that may be exported, or methods that may be called on objects belonging to the classes provided by the module. =head1 DIAGNOSTICS =for author to fill in: List every single error and warning message that the module can generate (even the ones that will "never happen"), with a full explanation of each problem, one or more likely causes, and any suggested remedies. =over =item C<< Error message here, perhaps with %s placeholders >> [Description of error here] =item C<< Another error message here >> [Description of error here] [Et cetera, et cetera] =back =head1 CONFIGURATION AND ENVIRONMENT =for author to fill in: A full explanation of any configuration system(s) used by the module, including the names and locations of any configuration files, and the meaning of any environment variables or properties that can be set. These descriptions must also include details of any configuration language used. Catalyst::Helper::Controller::InstantCRUD requires no configuration files or environment variables. =head1 DEPENDENCIES =for author to fill in: A list of all the other modules that this module relies upon, including any restrictions on versions, and an indication whether the module is part of the standard Perl distribution, part of the module's distribution, or must be installed separately. ] None. =head1 INCOMPATIBILITIES =for author to fill in: A list of any modules that this module cannot be used in conjunction with. This may be due to name conflicts in the interface, or competition for system or program resources, or due to internal limitations of Perl (for example, many modules that use source code filters are mutually incompatible). None reported. =head1 BUGS AND LIMITATIONS =for author to fill in: A list of known problems with the module, together with some indication Whether they are likely to be fixed in an upcoming release. Also a list of restrictions on the features the module does provide: data types that cannot be handled, performance issues and the circumstances in which they may arise, practical limitations on the size of data sets, special cases that are not (yet) handled, etc. No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR C<< <> >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, C<< <> >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Catalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Helper/Controller/0000755000175000017500000000000011221745410023130 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Helper/Controller/InstantCRUD.pm0000644000175000017500000001473611201556617025606 0ustar zbyzbypackage Catalyst::Helper::Controller::InstantCRUD; use version; $VERSION = qv('0.0.8'); use warnings; use strict; use Path::Class; use Data::Dumper; use HTML::FormHandler::Generator::DBIC; sub mk_compclass { my ( $self, $helper, $schema, $m2m) = @_; my $dir = dir( $helper->{dir}, 'root' ); $helper->mk_dir($dir); # controllers my @source_monikers = $schema->sources; for my $class( @source_monikers ) { mk_controller( $helper, $class, $schema, $m2m ); } } sub mk_controller { my( $helper, $class, $schema, $m2m ) = @_; $helper->{class} = $helper->{app} . '::Controller::' . $class; (my $file = $helper->{file}) =~ s/InstantCRUD/$class/; my $generator = HTML::FormHandler::Generator::DBIC->new( schema => $schema, class_prefix => $helper->{class}, style => 'single', m2m => $m2m, rs_name => $class, ); $helper->{form_code} = $generator->generate_form(); $helper->render_file( compclass => $file ); } sub _strip_class { my $fullclass = shift; my @parts = split /::/, $fullclass; my $class = pop @parts; return $class; } 1; # Magic true value required at end of module __DATA__ =begin pod_to_ignore __compclass__ use strict; use warnings; package [% class %]; [% IF rest %] use base "Catalyst::Example::Controller::InstantCRUD::REST"; __PACKAGE__->config( serialize => { default => 'text/html', map => { 'text/html' => [ 'View', 'TT' ], 'text/x-json' => 'JSON::Syck', } } ); [% ELSE %] use base "Catalyst::Example::Controller::InstantCRUD"; [% END %] [% form_code %] 1; __END__ =head1 NAME Catalyst::Helper::Controller::InstantCRUD - [One line description of module's purpose here] =head1 VERSION This document describes Catalyst::Helper::Controller::InstantCRUD version 0.0.1 =head1 SYNOPSIS use Catalyst::Helper::Controller::InstantCRUD; =for author to fill in: Brief code example(s) here showing commonest usage(s). This section will be as far as many users bother reading so make it as educational and exeplary as possible. =head1 DESCRIPTION =for author to fill in: Write a full description of the module and its features here. Use subsections (=head2, =head3) as appropriate. =head2 METHODS =over 4 =item mk_compclass =item mk_controller =back =head1 INTERFACE =for author to fill in: Write a separate section listing the public components of the modules interface. These normally consist of either subroutines that may be exported, or methods that may be called on objects belonging to the classes provided by the module. =head1 DIAGNOSTICS =for author to fill in: List every single error and warning message that the module can generate (even the ones that will "never happen"), with a full explanation of each problem, one or more likely causes, and any suggested remedies. =over =item C<< Error message here, perhaps with %s placeholders >> [Description of error here] =item C<< Another error message here >> [Description of error here] [Et cetera, et cetera] =back =head1 CONFIGURATION AND ENVIRONMENT =for author to fill in: A full explanation of any configuration system(s) used by the module, including the names and locations of any configuration files, and the meaning of any environment variables or properties that can be set. These descriptions must also include details of any configuration language used. Catalyst::Helper::Controller::InstantCRUD requires no configuration files or environment variables. =head1 DEPENDENCIES =for author to fill in: A list of all the other modules that this module relies upon, including any restrictions on versions, and an indication whether the module is part of the standard Perl distribution, part of the module's distribution, or must be installed separately. ] None. =head1 INCOMPATIBILITIES =for author to fill in: A list of any modules that this module cannot be used in conjunction with. This may be due to name conflicts in the interface, or competition for system or program resources, or due to internal limitations of Perl (for example, many modules that use source code filters are mutually incompatible). None reported. =head1 BUGS AND LIMITATIONS =for author to fill in: A list of known problems with the module, together with some indication Whether they are likely to be fixed in an upcoming release. Also a list of restrictions on the features the module does provide: data types that cannot be handled, performance issues and the circumstances in which they may arise, practical limitations on the size of data sets, special cases that are not (yet) handled, etc. No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR C<< <> >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, C<< <> >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Catalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Plugin/0000755000175000017500000000000011221745410021024 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Plugin/Auth/0000755000175000017500000000000011221745410021725 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Plugin/Auth/Utils.pm0000644000175000017500000001236111200774502023367 0ustar zbyzbypackage Catalyst::Plugin::Auth::Utils; use warnings; use strict; use Carp; our $VERSION = '0.01'; =head1 NAME Catalyst::Plugin::Auth::Utils - Methods and actions to simplify authentication =head1 SYNOPSIS use Catalyst qw/ HTML::Widget Authentication Authentication::Store::DBIC Authentication::Credential::Password Auth::Utils /; # in your Controller::Root.pm sub auto : ActionClass('Auth::Check') { $_[1]->stash->{login_action} = 'login'; } sub login : Local : ActionClass('Auth::Login') {} sub logout : Local : ActionClass('Auth::Logout') {} =head1 DESCRIPTION Methods and actions to simplify authentication =head1 METHODS =head2 $c->login_widget() Returns a L object filled with login and password fields to be used in login forms. =cut sub login_widget { my ( $c, %a ) = @_; my $login_field = $c->config->{authentication}{dbic}{user_field}; # Don't know why but sometimes login_field is an array ref ??? $login_field = $login_field->[0] if ref $login_field; my $pass_field = $c->config->{authentication}{dbic}{password_field}; my $user_class = $c->config->{authentication}{dbic}{user_class}; my $source = $user_class->result_source; my $login_info = $source->column_info($login_field); my $pass_info = $source->column_info($pass_field); $c->widget('widget')->method('post'); #$c->widget->action( $c->uri_for( $a{action} ? "/$a{action}" : '/login' )); # username field $c->widget('login')->element('Textfield', $login_field) ->label($login_info->{label} || 'Username')->size(30); # Constraints for username for my $const ( @{ $login_info->{constraints} || [] } ){ my $constraint = $c->widget('login')->constraint( $const->{constraint}, $login_field, $const->{args} ? @{$const->{args}} : () ); $const->{$_} and $constraint->$_($const->{$_}) for qw/min max regex callback in message/; } # password field $c->widget('login')->element('Password', $pass_field) ->label($pass_info->{label} || 'Password')->size(30); # Constraints for password for my $const ( @{ $pass_info->{constraints} || [] } ){ next if $const->{args} && $const->{args}[0] eq "$pass_field\_2"; my $constraint = $c->widget('login')->constraint( $const->{constraint}, $pass_field, $const->{args} ? @{$const->{args}} : () ); $const->{$_} and $constraint->$_($const->{$_}) for qw/min max regex callback in message/; } # Login my $failled_logon = $c->config->{authentication}{dbic}{failled_logon_message}; $c->widget('login')->constraint('Callback', $login_field)->callback(sub { my $username = shift; my $password = $c->request->params->{$pass_field}; return $c->login($username, $password); })->message($failled_logon || 'Bad username or password.'); $c->widget('button')->element( 'Submit', 'ok' )->value('Ok'); return $c->widget('widget') ->embed($c->widget('login')) ->embed($c->widget('button')); } =head2 $c->redirect_to_login_unless_user_exists() This method redirects to the login action unless an authenticated user is found =cut sub redirect_to_login_unless_user_exists { my ( $c ) = @_; my $action = $c->stash->{login_action} || 'login'; # Allow unauthenticated users to reach the login page return 1 if $c->action->reverse eq $action; # If a user doesn't exist, force login if (!$c->user_exists) { $c->log->debug("User not found, forwarding to /$action"); # Redirect the user to the login page $c->response->redirect($c->uri_for("/$action", { request_uri => $c->req->uri->as_string })); # Return 0 to cancel 'post-auto' processing and prevent use of application return 0; } # User found, so return 1 to continue with processing after this return 1; }; package Catalyst::Action::Auth::Check; use base 'Catalyst::Action'; sub execute { my $self = shift; my ($controller, $c ) = @_; $self->NEXT::execute( @_ ); return $c->redirect_to_login_unless_user_exists; } package Catalyst::Action::Auth::Login; use base 'Catalyst::Action'; sub execute { my $self = shift; my ($controller, $c ) = @_; my $widget = $c->login_widget->action($c->uri_for($c->action->reverse)); if ($c->request->method eq 'POST') { $c->stash->{widget} = $widget->process($c->request); $c->response->redirect($c->req->params->{request_uri} || $c->uri_for('/')) unless $c->stash->{widget}->has_errors; } else { $c->stash->{widget} = $widget->process; } $self->NEXT::execute( @_ ); } package Catalyst::Action::Auth::Logout; use base 'Catalyst::Action'; sub execute { my $self = shift; my ($controller, $c ) = @_; $self->NEXT::execute( @_ ); # Clear the user's state $c->logout; # Send the user to the starting point $c->response->redirect($c->uri_for('/')); } =head1 SEE ALSO L, L, L =head1 AUTHOR Zbigniew Lukasiak> C Jonas Alves, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; Catalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Example/0000755000175000017500000000000011221745410021161 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Example/InstantCRUD.pm0000644000175000017500000001111011221745320023607 0ustar zbyzbypackage Catalyst::Example::InstantCRUD; use version; $VERSION = qv('0.0.32'); use warnings; use strict; use Carp; # Module implementation here 1; # Magic true value required at end of module __END__ =head1 NAME Catalyst::Example::InstantCRUD - A CRUD scaffolding for Catalyst. =head1 VERSION This document describes Catalyst::Example::InstantCRUD version 0.0.30 =head1 SYNOPSIS instantcrud.pl My::App -dsn='dbi:Pg:dbname=CE' -user=zby -password='pass' The L executable creates a skeleton CRUD application in current directory. =head1 DESCRIPTION The script will create CRUD interface (CReate, Update, Delete) with paging and sort for all tables defined in the accessed database. The Create and Update forms let you manipulate also on relations (even many to many). I am waiting for suggestions what else basic functionality would be nice to have in the generated application. When the code is generated you can run the application: $ My-App/script/my_app_server.pl You can connect to your server at http://zby.aster.net.pl:3000 To access the CRUD interface to the tables you need to add '/tablename' (in lowercase) to the address: http://localhost:3000/tablename (Note that if the table name has a underscore, that underscore should be deleted in the address so table foo_bar is available at http://localhost:3000/foobar, this is due to some conversions made by the underlying libraries). The generated application will use DBIx::Class for model classes and Template::Toolkit for View. =head1 CUSTOMISATION AND EXTENDING The first place for customisations are the Template Toolkit templates and the CSS file. The CSS file used by the application is root/static/pagingandsort.css. The templates are generated in directories named after the controllers in the root directory. The generated controller is a subclass of Catalyst::Example::Controller::InstantCRUD. You can use the standard OO technique of overriding the documented methods to customize and extend it. The form handling code is in the controller. =head1 DEPENDENCIES See Makefile.PL =head1 RESOURCES L - InstantCRUD page at the Catalyst wiki. svn: http://dev.catalystframework.org/repos/Catalyst/trunk/Catalyst-Example-InstantCRUD =head1 BUGS AND LIMITATIONS This is still experimental and it is a first new release after a long time and substantial refactoring so treat with caution. The '0.04005' vesion of DBIx::Class::Schema::Loader does not assigne 'is_nullable' to any column when loading from some SQLite versions. In currently in applications generated out of SQLite databases all fields are marked as 'required'. The main generator script (instantcrud.pl) is an ugly hack. First the Catalyst helpers assume where the executable is located so I had to fool them, second there is no API for creation of the main application module (My::App). Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR C<< <> >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, C<< <> >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Catalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Example/Controller/0000755000175000017500000000000011221745410023304 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Example/Controller/InstantCRUD.pm0000644000175000017500000002335211220230477025746 0ustar zbyzbyuse strict; use warnings; package Catalyst::Example::Controller::InstantCRUD; use base 'Catalyst::Controller'; use Carp; use Data::Dumper; use Path::Class; #use Rose::HTMLx::Form::DBIC; use version; our $VERSION = qv('0.0.15'); sub auto : Local { my ( $self, $c ) = @_; $c->stash->{additional_template_paths} = [ dir( $c->config->{root}, lc $self->source_name) . '', $c->config->{root} . '']; } sub source_name { my $self = shift; my $class = ref $self; $class =~ /([^:]*)$/; return $1; } sub model_item { my ( $self, $c, @pks ) = @_; my $rs = $self->model_resultset($c); my $item = $rs->find( @pks, { key => 'primary' }); return $item; } sub model_pks { my ( $self, $c ) = @_; my $rs = $self->model_resultset($c); my @pks = $rs->result_source->primary_columns; return @pks; } sub model_resultset { my ( $self, $c ) = @_; my $model_name = $c->config->{InstantCRUD}{model_name}; my $source = $self->source_name; return $c->model($model_name)->resultset($source); } sub model_schema { my ( $self, $c ) = @_; my $model_name = $c->config->{InstantCRUD}{model_name}; return $c->model($model_name); } sub index : Private { my ( $self, $c ) = @_; $c->stash->{template} = lc( $self->source_name ) . '/list.tt'; $c->forward('list'); } sub destroy : Local { my ( $self, $c, @pks ) = @_; if ( $c->req->method eq 'POST' ) { $self->model_item( $c, @pks )->delete; $c->stash->{template} = lc( $self->source_name ) . '/list.tt'; $c->forward('list'); } else { my $action_uri = $c->uri_for( 'destroy', @pks); $c->stash->{destroywidget} = <
END } } sub edit : Local { my ( $self, $c, @pks ) = @_; my $form_name = ref( $self ) . '::' . $self->source_name . 'Form'; my @ids; @ids = ( item_id => [ @pks ] ) if @pks; my $form = $form_name->new( schema => $self->model_schema($c), params => $c->req->params, @ids, ); if( $c->req->method eq 'POST' && $form->process() ){ my $item = $form->item; $c->res->redirect( $c->uri_for( 'view', $item->id ) ); $c->stash( item => $item ); } if( @pks ){ $form->field( 'submit' )->value( 'Update' ); } else{ $form->field( 'submit' )->value( 'Create' ); } $c->stash( form => $form->render ); } sub view : Local { my ( $self, $c, @pks ) = @_; die "You need to pass an id" unless @pks; my $item = $self->model_item( $c, @pks ); $c->stash->{item} = $item; } sub get_resultset { my ( $self, $c ) = @_; my $params = $c->request->params; my $order = $params->{'order'}; $order .= ' DESC' if $params->{'o2'}; my $maxrows = $c->config->{InstantCRUD}{maxrows} || 10; my $page = $params->{'page'} || 1; return $self->model_resultset($c)->search( {}, { page => $page, order_by => $order, rows => $maxrows, } ); } sub create_col_link { my ( $self, $c, $source ) = @_; my $origparams = $c->request->params; return sub { my ( $column, $label ) = @_; my $addr; no warnings 'uninitialized'; if ( $origparams->{'order'} eq $column && !$origparams->{'o2'} ) { $addr = $c->request->uri_with({ page => 1, order => $column, o2 => 'desc' }); }else{ $addr = $c->request->uri_with({ page => 1, order => $column, o2 => undef }); } my $result = qq{$label}; if ( $origparams->{'order'} && $column eq $origparams->{'order'} ) { $result .= $origparams->{'o2'} ? "↓" : "↑"; } return $result; }; } sub list : Local { my ( $self, $c ) = @_; my $result = $self->get_resultset($c); $c->stash->{pager} = $result->pager; my $source = $result->result_source; ($c->stash->{pri}) = $source->primary_columns; $c->stash->{order_by_column_link} = $self->create_col_link($c, $source); $c->stash->{result} = $result; } 1; __END__ =head1 NAME Catalyst::Example::Controller::InstantCRUD - Catalyst CRUD example Controller =head1 VERSION This document describes Catalyst::Example::Controller::InstantCRUD version 0.0.14 =head1 SYNOPSIS use base Catalyst::Example::Controller::InstantCRUD; =for author to fill in: Brief code example(s) here showing commonest usage(s). This section will be as far as many users bother reading so make it as educational and exeplary as possible. =head1 DESCRIPTION =for author to fill in: Write a full description of the module and its features here. Use subsections (=head2, =head3) as appropriate. =head1 INTERFACE =head2 METHODS =over 4 =item load_interface_config Returns the config hash for input forms (widgets) and other interface elements =item get_resultset Returns the resultset appriopriate for the page parameters. =item model_resultset Returns a resultset from the model. =item model_item Returns an item from the model. =item model_pks Returns columns comprising the primary key. =item source_name Class method for finding name of corresponding database table. =item add Method for displaying form for adding new records =item create_col_link Subroutine placed on stash for templates to use. =item auto Adds Controller name as additional directory to search for templates =item index Forwards to list =item destroy Deleting records. =item do_add Method for adding new records =item do_edit Method for editin existing records =item edit Method for displaying form for editing a record. =item list Method for displaying pages of records =item view Method for diplaying one record =back =head1 DIAGNOSTICS =for author to fill in: List every single error and warning message that the module can generate (even the ones that will "never happen"), with a full explanation of each problem, one or more likely causes, and any suggested remedies. =over =item C<< Error message here, perhaps with %s placeholders >> [Description of error here] =item C<< Another error message here >> [Description of error here] [Et cetera, et cetera] =back =head1 CONFIGURATION AND ENVIRONMENT =for author to fill in: A full explanation of any configuration system(s) used by the module, including the names and locations of any configuration files, and the meaning of any environment variables or properties that can be set. These descriptions must also include details of any configuration language used. Catalyst::Example::Controller::InstantCRUD requires no configuration files or environment variables. =head1 DEPENDENCIES =for author to fill in: A list of all the other modules that this module relies upon, including any restrictions on versions, and an indication whether the module is part of the standard Perl distribution, part of the module's distribution, or must be installed separately. ] None. =head1 INCOMPATIBILITIES =for author to fill in: A list of any modules that this module cannot be used in conjunction with. This may be due to name conflicts in the interface, or competition for system or program resources, or due to internal limitations of Perl (for example, many modules that use source code filters are mutually incompatible). None reported. =head1 BUGS AND LIMITATIONS =for author to fill in: A list of known problems with the module, together with some indication Whether they are likely to be fixed in an upcoming release. Also a list of restrictions on the features the module does provide: data types that cannot be handled, performance issues and the circumstances in which they may arise, practical limitations on the size of data sets, special cases that are not (yet) handled, etc. No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR C<< <> >> C<< <> >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, C<< <> >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Catalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Example/Controller/InstantCRUD/0000755000175000017500000000000011221745410025402 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/lib/Catalyst/Example/Controller/InstantCRUD/REST.pm0000644000175000017500000001554611202750724026533 0ustar zbyzbyuse strict; use warnings; package Catalyst::Example::Controller::InstantCRUD::REST; use base qw/ Catalyst::Example::Controller::InstantCRUD /; use Class::C3; sub create_action { my $self = shift; return $self->maybe::next::method(@_); } use Carp; use Data::Dumper; use version; our $VERSION = qv('0.0.1'); sub create_form : Local { my ( $self, $c, @pks ) = @_; $self->edit( $c, @pks ); $c->stash( template => 'edit.tt' ); } sub by_id : Local : ActionClass('REST') { } sub _get_form { my( $self, $c, $pks ) = @_; my $form_name = ref( $self ) . '::' . $self->source_name . 'Form'; my @ids; @ids = ( item_id => $pks ) if defined $pks && @$pks; my $form = $form_name->new( schema => $self->model_schema($c), # item_class => $self->source_name($c), method => $c->req->method, params => $c->req->params, @ids, ); my $field = HTML::FormHandler::Field::Hidden->new( name => 'x-tunneled-method', form => $form, value => 'PUT', ); $form->add_field($field); return $form; } sub by_id_GET : Local { my ( $self, $c, @args ) = @_; my @model_pks = $self->model_pks( $c ); my @pks = @args[ 0 .. scalar @model_pks - 1 ]; my $view_type = $args[ scalar @model_pks ]; $view_type = 'view' if !defined( $view_type ) or $view_type ne 'edit'; my $item = $self->model_item( $c, @pks ); $c->stash->{item} = $item; if( $view_type eq 'edit' ){ my $form = $self->_get_form( $c, \@pks ); $c->stash( form => $form ); } $c->stash( template => $view_type . '.tt' ); } sub by_id_PUT : Local { my ( $self, $c, @args ) = @_; my @model_pks = $self->model_pks( $c ); my @pks = @args[ 0 .. scalar @model_pks - 1 ]; my $form = $self->_get_form( $c, \@pks ); if( $form->process ){ my $item = $form->item; my @new_pks = map { $item->$_ } @model_pks; $c->res->redirect( $c->uri_for( 'by_id', @new_pks ) ); } else{ $c->stash( form => $form ); $c->stash( template => 'edit.tt' ); } } 1; __END__ =head1 NAME Catalyst::Example::Controller::InstantCRUD::REST - Catalyst CRUD example RESTful Controller =head1 VERSION This document describes Catalyst::Example::Controller::InstantCRUD::REST version 0.0.1 =head1 SYNOPSIS use base Catalyst::Example::Controller::InstantCRUD::REST; =for author to fill in: Brief code example(s) here showing commonest usage(s). This section will be as far as many users bother reading so make it as educational and exeplary as possible. =head1 DESCRIPTION =for author to fill in: Write a full description of the module and its features here. Use subsections (=head2, =head3) as appropriate. =head1 INTERFACE =head2 METHODS =over 4 =item by_id The main dispatch point. =item by_id_PUT Updates an object (or creates one). =item by_id_GET Shows object representation =item create_form Form for object creation. =back =head1 DIAGNOSTICS =for author to fill in: List every single error and warning message that the module can generate (even the ones that will "never happen"), with a full explanation of each problem, one or more likely causes, and any suggested remedies. =over =item C<< Error message here, perhaps with %s placeholders >> [Description of error here] =item C<< Another error message here >> [Description of error here] [Et cetera, et cetera] =back =head1 CONFIGURATION AND ENVIRONMENT =for author to fill in: A full explanation of any configuration system(s) used by the module, including the names and locations of any configuration files, and the meaning of any environment variables or properties that can be set. These descriptions must also include details of any configuration language used. Catalyst::Example::Controller::InstantCRUD requires no configuration files or environment variables. =head1 DEPENDENCIES =for author to fill in: A list of all the other modules that this module relies upon, including any restrictions on versions, and an indication whether the module is part of the standard Perl distribution, part of the module's distribution, or must be installed separately. ] None. =head1 INCOMPATIBILITIES =for author to fill in: A list of any modules that this module cannot be used in conjunction with. This may be due to name conflicts in the interface, or competition for system or program resources, or due to internal limitations of Perl (for example, many modules that use source code filters are mutually incompatible). None reported. =head1 BUGS AND LIMITATIONS =for author to fill in: A list of known problems with the module, together with some indication Whether they are likely to be fixed in an upcoming release. Also a list of restrictions on the features the module does provide: data types that cannot be handled, performance issues and the circumstances in which they may arise, practical limitations on the size of data sets, special cases that are not (yet) handled, etc. No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR C<< <> >> C<< <> >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, C<< <> >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Catalyst-Example-InstantCRUD-0.0.32/README0000644000175000017500000000162111200774502016115 0ustar zbyzbyCatalyst-Example-InstantCRUD version 0.0.1 Create a working CRUD Catalyst example for all tables in a specified database with least of effort. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install DEPENDENCIES 'Test::More' => 0, 'version' => 0, 'Catalyst' => 0, 'URI::Escape' => 0, 'HTML::Entities' => 0, 'HTML::Widget' => 0, 'File::Spec' => 0, 'Catalyst::View::TT' => 0.21, 'Template::Plugin::Class' => 0, 'Catalyst::Model::DBIC' => 0, 'Catalyst::Helper::Model::DBIC' => 0, 'DBIx::Class::Loader' => 0, 'DBIx::Class::Schema::Loader' => 0.03, COPYRIGHT AND LICENCE Copyright (C) 2005, This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Catalyst-Example-InstantCRUD-0.0.32/Changes0000644000175000017500000000354211221745400016532 0ustar zbyzbyRevision history for Catalyst-Example-InstantCRUD 0.0.32 Sun Jun 28 21:56:24 CEST 2009 HTML::FormHandler based 0.0.30 Sat Feb 28 11:15:15 CET 2009 Better pager 0.0.29 Thu Feb 26 21:19:55 CET 2009 UTF-8 ======================================================== The Old Changes Log 0.0.1 Thu Dec 8 15:29:28 2005 Initial release. 0.0.2 initial CPAN release 0.0.3 Fri Jan 20 23:45:45 CET 2006 - simplified templates dirs - model_class instead of table_class - destroy via form (POST) 0.0.4 Sat Feb 4 17:30:19 CET 2006 - added verification of submitted form values 0.0.8 Tue Mar 14 16:20:41 CET 2006 - model based on DBIx::Class::Schema - added some initial support for relations between tables (author Lars Balker Rasmussen) - adopted for Catalyst 1.56 0.0.10 Mon Apr 3 16:16:48 CEST 2006 - fixed bug with -short (thanks Jonathan Manning) - added menu with all available tables 0.0.12 Tue Aug 22 15:43:44 CEST 2006 - added one to many and many to many relations - added some authentication/authorisation framework - all datatype config goes now into generated DBIC delclarations - added some first tests - other big changes 0.0.14 Wed Aug 23 17:35:35 CEST 2006 - Generating separate templates per Controller 0.0.16 Mon Sep 18 08:48:30 CEST 2006 - Generating alternative controllers (with model_widget implemented) 0.0.17 Fri Oct 6 12:54:18 CEST 2006 - Generating interface_config.dat - config for forms used to create and update records - Form config removed from the generated 'DBIx::Class'es - Not generating alternative controllers any more 0.0.18 Mon Oct 23 13:58:40 CEST 2006 - interface_config.dat a bit shallower - got rid of 'column_value' function - unwinding loops in templates - Schema moved to application directory (name changed) - HTML::Widget::DBIC published separately 0.0.20 Wed Sep 12 - upgraded to newer versions of DBIC and other libraries Catalyst-Example-InstantCRUD-0.0.32/Makefile.PL0000644000175000017500000000505111221745267017221 0ustar zbyzbyuse strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Catalyst::Example::InstantCRUD', AUTHOR => ' <>', VERSION_FROM => 'lib/Catalyst/Example/InstantCRUD.pm', ABSTRACT_FROM => 'lib/Catalyst/Example/InstantCRUD.pm', PL_FILES => {}, PREREQ_PM => { 'Catalyst::Runtime' => '5.7000', 'Catalyst::Devel' => '1.00', 'Catalyst::View::TT' => '0.21', 'DBIx::Class' => '0.08003', 'DBIx::Class::Schema::Loader' => '0.03', 'DBIx::Class::ResultSet::RecursiveUpdate' => 0, 'DBIx::Class::UTF8Columns' => 0, # 'DBIx::Class::DigestColumns' => 0, # 'Template::Plugin::Class' => 0, 'Catalyst::Model::DBIC::Schema' => 0, 'Catalyst::Helper::Model::DBIC::Schema' => 0, 'Catalyst::Plugin::ConfigLoader' => 0, 'Catalyst::Plugin::Static::Simple' => 0, 'Catalyst::Plugin::Unicode' => 0, # 'Catalyst::Plugin::Authentication' => '0.07', # 'Catalyst::Plugin::Authentication::Store::DBIC' => '0.07', # 'Catalyst::Plugin::Authentication::Credential::Password' => 0, 'Catalyst::Plugin::Session::State::Cookie' => 0, 'Catalyst::Plugin::Session::Store::FastMmap' => 0, 'HTML::FormHandler::Generator::DBIC' => 0.02, 'HTML::FormHandler' => 0.26, 'Path::Class' => 0, # 'version' => 0, # 'URI::Escape' => 0, 'File::Slurp' => 0, 'Pod::Usage' => 0, 'List::Util' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Catalyst-Example-InstantCRUD-*' }, EXE_FILES => ['script/instantcrud.pl'], LICENSE => 'perl', ); Catalyst-Example-InstantCRUD-0.0.32/META.yml0000644000175000017500000000241711221745410016511 0ustar zbyzby--- #YAML:1.0 name: Catalyst-Example-InstantCRUD version: 0.0.32 abstract: A CRUD scaffolding for Catalyst. author: - <> license: perl distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Catalyst::Devel: 1.00 Catalyst::Helper::Model::DBIC::Schema: 0 Catalyst::Model::DBIC::Schema: 0 Catalyst::Plugin::ConfigLoader: 0 Catalyst::Plugin::Session::State::Cookie: 0 Catalyst::Plugin::Session::Store::FastMmap: 0 Catalyst::Plugin::Static::Simple: 0 Catalyst::Plugin::Unicode: 0 Catalyst::Runtime: 5.7000 Catalyst::View::TT: 0.21 DBIx::Class: 0.08003 DBIx::Class::ResultSet::RecursiveUpdate: 0 DBIx::Class::Schema::Loader: 0.03 DBIx::Class::UTF8Columns: 0 File::Slurp: 0 HTML::FormHandler: 0.26 HTML::FormHandler::Generator::DBIC: 0.02 List::Util: 0 Path::Class: 0 Pod::Usage: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.50 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Catalyst-Example-InstantCRUD-0.0.32/script/0000755000175000017500000000000011221745410016540 5ustar zbyzbyCatalyst-Example-InstantCRUD-0.0.32/script/instantcrud.pl0000755000175000017500000003250111211015363021433 0ustar zbyzby#!/usr/bin/perl -w eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}' if 0; # not running under some shell use strict; use Getopt::Long; use Pod::Usage; use Path::Class; use File::Slurp; use Catalyst::Helper::InstantCRUD; use Catalyst::Utils; use Data::Dumper; use DBIx::Class::Schema::Loader qw/ make_schema_at /; use DBIx::Class::Schema::Loader::RelBuilder; use List::Util qw(first); use DBI; use utf8; my $appname = $ARGV[0]; my $help = 0; my $adv_help = 0; my $nonew = 0; my $scripts = 0; my $short = 0; my $auth = 1; my $rest = 0; my $dsn; my $duser; my $dpassword; my $model_name = 'DBICSchemamodel'; my $schema_name = 'DBSchema'; my %auth; my %authz; GetOptions( 'help|?' => \$help, 'advanced_help' => \$adv_help, 'rest' => \$rest, 'nonew' => \$nonew, 'scripts' => \$scripts, 'short' => \$short, 'dsn=s' => \$dsn, 'user=s' => \$duser, 'password=s'=> \$dpassword, 'auth!' => \$auth, 'model_name=s'=> \$model_name, 'schema_name=s'=> \$schema_name, 'auth_user_table=s' => \$auth{user_table}, 'auth_user_field=s' => \$auth{user_field}, 'auth_password_field=s' => \$auth{password_field}, 'auth_password_type=s' => \$auth{password_type}, 'auth_password_hash_type=s' => \$auth{password_hash_type}, 'auth_user_role_user_field=s' => \$auth{user_role_user_field}, 'authz_role_table=s' => \$authz{role_table}, 'authz_role_field=s' => \$authz{role_field}, 'authz_user_role_user_field=s' => \$authz{user_role_user_field}, 'authz_role_rel=s' => \$authz{role_rel}, ); pod2usage($adv_help ? 1 : 2) if $help || $adv_help || !$appname; # Application my $helper = Catalyst::Helper::InstantCRUD->new( { '.newfiles' => !$nonew, 'scripts' => $scripts, 'short' => $short, 'model_name' => $model_name, 'schema_name' => $schema_name, 'auth' => \%auth, 'authz' => \%authz, 'rest' => $rest, } ); my $appdir = $appname; $appdir =~ s/::/-/g; if( -d $appdir ){ warn "\nThe directory '$appdir' already exists! Cannot recreate '$appname'!\n\n"; pod2usage(1); exit; } if( ! $helper->mk_app( $appname ) ){ warn "Cannot create application: $appname\n"; pod2usage(1); exit; } if( ! $dsn ){ my $db_file = lc $appname . '.db'; $db_file =~ s/::/_/g; $db_file = file( $appdir, $db_file )->absolute->stringify; create_example_db( $db_file ); warn "Database created at $db_file\n"; $dsn = "dbi:SQLite:dbname=$db_file"; } local $FindBin::Bin = dir($appdir, 'script'); my $full_schema_name = $appname . '::' . $schema_name; make_schema_at( $full_schema_name, { # debug => 1, dump_directory => dir( $appdir , 'lib')->absolute->stringify, use_namespaces => 1, # default_resultset_class => '+DBIx::Class::ResultSet::RecursiveUpdate', components => [ 'InflateColumn::DateTime', 'UTF8Columns' ], }, [ $dsn, $duser, $dpassword ], ); #{ # no strict 'refs'; # @{"$schema_name\::ISA"} = qw/DBIx::Class::Schema::Loader/; # $schema_name->loader_options(relationships => 1, exclude => qr/^sqlite_sequence$/); #} my $schema = $full_schema_name->connect(); #$dsn, $duser, $dpassword); my ( $m2m, $bridges ) = guess_m2m( $schema ); for my $result_class ( $schema->sources ){ my $result_source = $schema->source( $result_class ); my $overload_method = first { $_ =~ /name/i } $result_source->columns; $overload_method ||= 'id'; my @path = split /::/ , $appname . '::' . $schema_name; my $file = file( $appdir, 'lib', @path, 'Result', $result_class . '.pm' )->absolute->stringify; my $content = File::Slurp::slurp( $file ); my $addition = q/use overload '""' => sub {$_[0]->/ . $overload_method . "}, fallback => 1;\n"; for my $m ( @{$m2m->{$result_class}} ){ my $a0 = $m->[0]; my $a1 = $m->[1]; my $a2 = $m->[2]; $addition .= "__PACKAGE__->many_to_many('$a0', '$a1' => '$a2');\n"; } my @columns = $result_source->columns; $addition .= "__PACKAGE__->utf8_columns(qw/@columns/);\n"; $content =~ s/1;\s*/$addition\n1;/; File::Slurp::write_file( $file, $content ); } # Controllers $helper->mk_component ( $appname, 'controller', 'InstantCRUD', 'InstantCRUD', $schema, $m2m, ); # Model $helper->mk_component ( $appname, 'model', $model_name, 'DBIC::Schema', $appname . '::' . $schema_name, $dsn, $duser, $dpassword, ); # View and Templates $helper->mk_component ( $appname, 'view', 'TT', 'InstantCRUD', $schema, $m2m, $bridges ); sub guess_m2m { my $schema = shift; my %m2m; my %bridges; my $inflector = DBIx::Class::Schema::Loader::RelBuilder->new; CLASS: for my $s ( $schema->sources ) { my $source = $schema->source($s); my @relationships = $source->relationships; my @cols = $source->columns; next if scalar @relationships != 2; next if scalar @cols!= 2; my @rclasses; for my $rel (@relationships) { my $info = $source->relationship_info($rel); next CLASS if $info->{attrs}{accessor} eq 'multi'; my $rclass_name = $info->{class}; $rclass_name =~ /([^:]*)$/; $rclass_name = $1; my $rsource = $schema->source( $rclass_name ); my $found; for my $rrel ( $rsource->relationships ){ my $rinfo = $rsource->relationship_info($rrel); my $rrclass_name = $rinfo->{class}; $rrclass_name =~ /([^:]*)$/; $rrclass_name = $1; if( $rrclass_name eq $s ){ $found = $rrel; last; } } next CLASS if not $found; push @rclasses, { rclass => $rclass_name, bridge => [ $found, $rel ] }; } push @{$m2m{ $rclasses[0]->{rclass} }}, [ $inflector->_inflect_plural( $rclasses[1]->{bridge}[1] ), $rclasses[1]->{bridge}[0], $rclasses[1]->{bridge}[1] ]; push @{$m2m{ $rclasses[1]->{rclass} }}, [ $inflector->_inflect_plural( $rclasses[0]->{bridge}[1] ), $rclasses[0]->{bridge}[0], $rclasses[0]->{bridge}[1] ]; $bridges{$s} = 1; } return \%m2m, \%bridges; } sub create_example_db { my $filename = shift; my $dsn ||= 'dbi:SQLite:dbname=' . $filename; my $dbh = DBI->connect( $dsn ) or die "Cannot connect to $dsn\n"; $dbh->{unicode} = 1; my $sql; { local $/; $sql = ; } for my $statement ( split /;/, $sql ){ next if $statement =~ /\A\s*\z/; # warn "executing: \n$statement"; $dbh->do($statement) or die $dbh->errstr; } } 1; =head1 NAME instantcrud.pl - Bootstrap a Catalyst application example =head1 SYNOPSIS instantcrud.pl ApplicationName [options] Options: -dsn dsn -user database user -password database password -help display this help and exits -model_name model name (default: DBICSchemamodel) -schema_name schema name (default: DBSchema) ApplicationName must be a valid Perl module name and can include "::". This version cannot update previously generated code base - it can only generate a new one. All options are optional, if no dsn is provided an example SQLite database will be created and used. Examples: instantcrud.pl My::App -dsn='dbi:Pg:dbname=CE' -user=zby -password='pass' =head1 DESCRIPTION The C script bootstraps a Catalyst application example, creating a directory structure populated with skeleton files. The application name must be a valid Perl module name. The name of the directory created is formed from the application name supplied, with double colons replaced with hyphens (so, for example, the directory for C is C). Using the example application name C, the application directory will contain the following items: =over 4 =item README a skeleton README file, which you are encouraged to expand on =item Build.PL a C build script =item Changes a changes file with an initial entry for the creation of the application =item Makefile.PL an old-style MakeMaker script. Catalyst uses the C system so this script actually generates a Makeifle that invokes the Build script. =item lib contains the application module (C) and subdirectories for model, view, and controller components (C, C, and C). =item root root directory for your web document content. This is left empty. =item script a directory containing helper scripts: =over 4 =item C helper script to generate new component modules =item C runs the generated application within a Catalyst test server, which can be used for testing without resorting to a full-blown web server configuration. =item C runs the generated application as a CGI script =item C runs the generated application as a FastCGI script =item C runs an action of the generated application from the comand line. =back =item t test directory =back =head1 SEE ALSO L, L =head1 AUTHOR Zbigniew Lukasiak, C Jonas Alves, C Based on catalyst.pl by: Andrew Ford, C Sebastian Riedel, C, Jonathan Manning =head1 COPYRIGHT This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut __DATA__ BEGIN TRANSACTION; CREATE TABLE dvd ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) DEFAULT NULL, imdb_id INTEGER DEFAULT NULL, owner INTEGER NOT NULL REFERENCES user (id), current_borrower INTEGER DEFAULT NULL REFERENCES user (id), creation_date date DEFAULT NULL, alter_date datetime DEFAULT NULL, hour time DEFAULT NULL ); INSERT INTO "dvd" VALUES(2,'Hohoho',1,1,1,'1990-08-23','2000-02-17 10:00:00','10:00'); DELETE FROM sqlite_sequence; INSERT INTO "sqlite_sequence" VALUES('role',2); INSERT INTO "sqlite_sequence" VALUES('tag',25); INSERT INTO "sqlite_sequence" VALUES('user',3); INSERT INTO "sqlite_sequence" VALUES('dvd',4); CREATE TABLE dvdtag ( dvd INTEGER NOT NULL DEFAULT '0' REFERENCES dvd (id), tag INTEGER NOT NULL DEFAULT '0' REFERENCES tag (id), PRIMARY KEY (dvd,tag) ); INSERT INTO "dvdtag" VALUES(2,1); INSERT INTO "dvdtag" VALUES(2,2); INSERT INTO "dvdtag" VALUES(2,5); INSERT INTO "dvdtag" VALUES(2,6); INSERT INTO "dvdtag" VALUES(3,1); INSERT INTO "dvdtag" VALUES(0,7); INSERT INTO "dvdtag" VALUES(4,1); INSERT INTO "dvdtag" VALUES(1,0); INSERT INTO "dvdtag" VALUES(1,1); INSERT INTO "dvdtag" VALUES(1,2); INSERT INTO "dvdtag" VALUES(1,4); INSERT INTO "dvdtag" VALUES(1,6); CREATE TABLE role ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, role VARCHAR(255) ); INSERT INTO "role" VALUES(1,'Write'); INSERT INTO "role" VALUES(2,'Read'); CREATE TABLE tag ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) DEFAULT NULL ); INSERT INTO "tag" VALUES(1,'Action'); INSERT INTO "tag" VALUES(2,'Romance'); INSERT INTO "tag" VALUES(3,'Tag1'); INSERT INTO "tag" VALUES(4,'Tag2'); INSERT INTO "tag" VALUES(5,'Tag3'); INSERT INTO "tag" VALUES(6,'Tag4'); INSERT INTO "tag" VALUES(8,'aa'); INSERT INTO "tag" VALUES(9,'aaa'); INSERT INTO "tag" VALUES(10,'aaaa'); INSERT INTO "tag" VALUES(11,'aaaaa'); INSERT INTO "tag" VALUES(12,'aaaaa'); INSERT INTO "tag" VALUES(13,'aaaaaa'); INSERT INTO "tag" VALUES(14,'aaaaaaa'); INSERT INTO "tag" VALUES(15,'aaaaaaaa'); INSERT INTO "tag" VALUES(16,'aaaaaaaaa'); INSERT INTO "tag" VALUES(17,'aaaaaaaaaa'); INSERT INTO "tag" VALUES(18,'aaaaaaaaaaa'); INSERT INTO "tag" VALUES(19,'aaaaaaaaaaaa'); INSERT INTO "tag" VALUES(20,'aaaaaaaaaaaaa'); INSERT INTO "tag" VALUES(21,'aaaaaaaaaaaaaa'); INSERT INTO "tag" VALUES(22,'aaaaaaaaaaaaaaa'); INSERT INTO "tag" VALUES(23,'aaaaaaaaaaaaaaaa'); INSERT INTO "tag" VALUES(24,'aaaaaaaaaaaaaaaaa'); INSERT INTO "tag" VALUES(25,'aaaaaaaaaaaaaaaaaa'); CREATE TABLE user ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, username VARCHAR(255) DEFAULT NULL, password VARCHAR(255) DEFAULT NULL, name VARCHAR(255) DEFAULT NULL ); INSERT INTO "user" VALUES(1,'jgda','35a2c6fae61f8077aab61faa4019722abf05093c','Jonas Alves'); INSERT INTO "user" VALUES(2,'maya','59dc310530b44e8dd1231682b4cc5f2458af1c60','Maya'); CREATE TABLE user_role ( user INTEGER NOT NULL DEFAULT '0' REFERENCES user (id), role INTEGER NOT NULL DEFAULT '0' REFERENCES role (id), PRIMARY KEY (user, role) ); INSERT INTO "user_role" VALUES(1,1); INSERT INTO "user_role" VALUES(1,2); INSERT INTO "user_role" VALUES(3,0); CREATE TABLE unicode_examples ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, iso_country_code CHAR(2), language_name varchar(255), main_unicode_set varchar(255), example_text text ); INSERT INTO "unicode_examples" VALUES(1,'PL','Polish','Latin Extended A','Literki z ogonkami alfabetycznie: ąćęłńóśżźĄĆĘŁŃÓŚŹŻ (acelnoszzACELNOSZZ)'); INSERT INTO "unicode_examples" VALUES(2,'DE','German','Latin-1 Supplement','äöüÄÖÜß'); INSERT INTO "unicode_examples" VALUES(3,'RU','Russian','Cyrillic','Это текст на русском языке'); INSERT INTO "unicode_examples" VALUES(4,'','Math Symbols','Mathematical Operators','(x ∊ A ∪ B) ≡ (x ∊ A)∨(x ∊ B)'); COMMIT; Catalyst-Example-InstantCRUD-0.0.32/MANIFEST0000644000175000017500000000120211210770076016364 0ustar zbyzbyChanges MANIFEST Makefile.PL README script/instantcrud.pl t/00.createapp.t t/00.load.t t/10.apptest.t t/20.create_dvdzbr.t t/21.test_dvdzbr.t t/30.create_rest.t t/31.test_rest.t t/pod-coverage.t t/pod.t t/var/test.sql t/tmp/test.db lib/Catalyst/Helper/View/InstantCRUD.pm lib/Catalyst/Helper/Model/InstantCRUD.pm lib/Catalyst/Helper/InstantCRUD.pm lib/Catalyst/Helper/Controller/InstantCRUD.pm lib/Catalyst/Plugin/Auth/Utils.pm lib/Catalyst/Example/InstantCRUD.pm lib/Catalyst/Example/Controller/InstantCRUD.pm lib/Catalyst/Example/Controller/InstantCRUD/REST.pm META.yml Module meta-data (added by MakeMaker)