Permalink
Browse files

extensions and examples as separate dists

  • Loading branch information...
1 parent cbd5601 commit 29782b70ce71304f5e32516dcf1fcdab86532941 Zbigniew Lukasiak committed Jun 19, 2010
Showing with 903 additions and 48 deletions.
  1. +0 −9 Makefile.PL
  2. +5 −0 examples/DvdDatabase/app.psgi
  3. +10 −0 examples/DvdDatabase/dist.ini
  4. +55 −0 examples/DvdDatabase/lib/DvdDatabase.pm
  5. +16 −0 examples/DvdDatabase/lib/DvdDatabase/Controller.pm
  6. +5 −5 {t/lib/MyApp → examples/DvdDatabase/lib/DvdDatabase}/Controller/Dvd.pm
  7. +39 −0 examples/DvdDatabase/lib/DvdDatabase/Controller/Dvd/Form.pm
  8. +2 −2 {t/lib/MyApp → examples/DvdDatabase/lib/DvdDatabase}/Controller/Dvd/Record.pm
  9. +4 −4 {t/lib/MyApp → examples/DvdDatabase/lib/DvdDatabase}/Controller/DvdSimpleUrl.pm
  10. +16 −0 examples/DvdDatabase/lib/DvdDatabase/DBSchema.pm
  11. +91 −0 examples/DvdDatabase/lib/DvdDatabase/DBSchema/Result/Dvd.pm
  12. +39 −0 examples/DvdDatabase/lib/DvdDatabase/DBSchema/Result/Dvdtag.pm
  13. +43 −0 examples/DvdDatabase/lib/DvdDatabase/DBSchema/Result/Role.pm
  14. +43 −0 examples/DvdDatabase/lib/DvdDatabase/DBSchema/Result/Tag.pm
  15. +53 −0 examples/DvdDatabase/lib/DvdDatabase/DBSchema/Result/UnicodeExamples.pm
  16. +67 −0 examples/DvdDatabase/lib/DvdDatabase/DBSchema/Result/User.pm
  17. +39 −0 examples/DvdDatabase/lib/DvdDatabase/DBSchema/Result/UserRole.pm
  18. +7 −0 examples/DvdDatabase/t/00.load.t
  19. +3 −4 { → examples/DvdDatabase}/t/crudapp.t
  20. +7 −0 examples/DvdDatabase/t/data/app.conf
  21. BIN { → examples/DvdDatabase}/t/data/dvdzbr.db
  22. 0 { → examples/DvdDatabase}/t/data/templates/Dvd/Record/delete.tt
  23. 0 { → examples/DvdDatabase}/t/data/templates/Dvd/Record/edit.tt
  24. 0 { → examples/DvdDatabase}/t/data/templates/Dvd/Record/record.tt
  25. 0 { → examples/DvdDatabase}/t/data/templates/Dvd/edit.tt
  26. 0 { → examples/DvdDatabase}/t/data/templates/Dvd/list.tt
  27. 0 { → examples/DvdDatabase}/t/data/templates/DvdSimpleUrl/list.tt
  28. +6 −0 examples/DvdDatabase/t/pod.t
  29. 0 { → examples/DvdDatabase}/t/tmp/.gitignore
  30. BIN examples/DvdDatabase/t/tmp/dvdzbr.db
  31. +11 −0 extensions/WebNano-Controller-CRUD/dist.ini
  32. +12 −0 extensions/{ → WebNano-Controller-CRUD}/lib/WebNano/Controller/CRUD.pm
  33. 0 { → extensions/WebNano-Controller-CRUD}/t/crud_base_controller.t
  34. +7 −0 extensions/WebNano-Controller-CRUD/t/data/app.conf
  35. BIN extensions/WebNano-Controller-CRUD/t/data/dvdzbr.db
  36. 0 { → extensions/WebNano-Controller-CRUD}/t/data/templates/DvdWithBaseCRUD/delete.tt
  37. 0 { → extensions/WebNano-Controller-CRUD}/t/data/templates/DvdWithBaseCRUD/edit.tt
  38. 0 { → extensions/WebNano-Controller-CRUD}/t/data/templates/DvdWithBaseCRUD/list.tt
  39. 0 { → extensions/WebNano-Controller-CRUD}/t/data/templates/DvdWithBaseCRUD/record.tt
  40. +40 −0 extensions/WebNano-Controller-CRUD/t/lib/MyApp.pm
  41. +32 −0 extensions/WebNano-Controller-CRUD/t/lib/MyApp/Controller.pm
  42. +1 −1 { → extensions/WebNano-Controller-CRUD}/t/lib/MyApp/Controller/DvdWithBaseCRUD.pm
  43. +1 −1 {t/lib/MyApp/Controller/Dvd → extensions/WebNano-Controller-CRUD/t/lib/MyApp/Controller}/Form.pm
  44. 0 { → extensions/WebNano-Controller-CRUD}/t/lib/MyApp/DBSchema.pm
  45. 0 { → extensions/WebNano-Controller-CRUD}/t/lib/MyApp/DBSchema/Result/Dvd.pm
  46. 0 { → extensions/WebNano-Controller-CRUD}/t/lib/MyApp/DBSchema/Result/Dvdtag.pm
  47. 0 { → extensions/WebNano-Controller-CRUD}/t/lib/MyApp/DBSchema/Result/Role.pm
  48. 0 { → extensions/WebNano-Controller-CRUD}/t/lib/MyApp/DBSchema/Result/Tag.pm
  49. 0 { → extensions/WebNano-Controller-CRUD}/t/lib/MyApp/DBSchema/Result/UnicodeExamples.pm
  50. 0 { → extensions/WebNano-Controller-CRUD}/t/lib/MyApp/DBSchema/Result/User.pm
  51. 0 { → extensions/WebNano-Controller-CRUD}/t/lib/MyApp/DBSchema/Result/UserRole.pm
  52. BIN extensions/WebNano-Controller-CRUD/t/tmp/dvdzbr.db
  53. +10 −0 extensions/WebNano-Controller-DSL/dist.ini
  54. +19 −1 ...ib/WebNano/Controller/WebDispatchTable.pm → WebNano-Controller-DSL/lib/WebNano/Controller/DSL.pm}
  55. +1 −1 ...WebNano/Controller/WebDispatchTable → WebNano-Controller-DSL/lib/WebNano/Controller/DSL}/Moose.pm
  56. 0 extensions/{ → WebNano-Controller-DSL}/lib/WebNano/Controller/Meta/Class/Trait/WebDispatchTable.pm
  57. +5 −0 extensions/WebNano-Controller-DSL/t/app.psgi
  58. +2 −4 t/web_dispatch_table.t → extensions/WebNano-Controller-DSL/t/dsl.t
  59. +8 −0 extensions/WebNano-Controller-DSL/t/lib/MyApp.pm
  60. +32 −0 extensions/WebNano-Controller-DSL/t/lib/MyApp/Controller.pm
  61. +11 −0 extensions/WebNano-Controller-DSL/t/lib/MyApp/Controller/DSL.pm
  62. +6 −0 extensions/WebNano-Controller-DSL/t/pod.t
  63. +39 −0 extensions/WebNano-Controller-WithAttributes/a
  64. +6 −0 extensions/WebNano-Controller-WithAttributes/dist.ini
  65. +4 −3 ...ttributesForMeta.pm → WebNano-Controller-WithAttributes/lib/WebNano/Controller/WithAttributes.pm}
  66. +5 −0 extensions/WebNano-Controller-WithAttributes/t/app.psgi
  67. +8 −0 extensions/WebNano-Controller-WithAttributes/t/lib/MyApp.pm
  68. +32 −0 extensions/WebNano-Controller-WithAttributes/t/lib/MyApp/Controller.pm
  69. +11 −0 extensions/WebNano-Controller-WithAttributes/t/lib/MyApp/Controller/WithAttributes.pm
  70. +6 −0 extensions/WebNano-Controller-WithAttributes/t/pod.t
  71. +18 −0 extensions/WebNano-Controller-WithAttributes/t/with_attributes.t
  72. +11 −0 extensions/WebNano-Renderer-TT/dist.ini
  73. +15 −0 extensions/{ → WebNano-Renderer-TT}/lib/WebNano/Renderer/TT.pm
  74. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt1/include_global.tt
  75. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt1/some_template.tt
  76. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt1/subdir1/template.tt
  77. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt1/subdir2/template.tt
  78. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt1/subdir2/template1.tt
  79. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt2/second_root.tt
  80. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt2/some_template.tt
  81. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt2/subdir1/second_root.tt
  82. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt2/subdir2/second_root.tt
  83. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt2/subdir2/second_root1.tt
  84. 0 { → extensions/WebNano-Renderer-TT}/t/data/tt_globals/some_global.tt
  85. 0 { → extensions/WebNano-Renderer-TT}/t/tt_renderer.t
  86. +0 −2 t/10.main.t
  87. +0 −2 t/11.subclass.t
  88. +0 −9 t/lib/MyApp.pm
View
@@ -14,18 +14,9 @@ requires 'URI::Escape';
requires 'Try::Tiny';
requires 'Template::Tiny';
-build_requires 'Moose';
-build_requires 'Any::Moose';
-build_requires 'MooseX::NonMoose';
-build_requires 'MooseX::MethodAttributes';
-build_requires 'Class::MOP';
build_requires 'Test::More';
-build_requires 'DBIx::Class';
build_requires 'Config::Any';
build_requires 'Config::General';
-build_requires 'HTML::FormHandler';
-build_requires 'HTML::FormHandler::Model::DBIC';
-build_requires 'Template';
auto_install;
@@ -0,0 +1,5 @@
+use DvdDatabase;
+my $app = DvdDatabase->new();
+$app->psgi_callback;
+
+
@@ -0,0 +1,10 @@
+name = DvdDatabase
+author = Zbigniew Lukasiak <zby@cpan.org>
+license = Perl_5
+copyright_holder = Zbigniew Lukasiak <zby@cpan.org>
+copyright_year = 2010
+
+[@Basic]
+[AutoVersion]
+[AutoPrereq]
+[TestRelease]
@@ -0,0 +1,55 @@
+package DvdDatabase;
+use Moose;
+use MooseX::NonMoose;
+extends 'WebNano';
+use Config::Any;
+use DvdDatabase::DBSchema;
+use WebNano::TTTRenderer;
+
+has config => ( is => 'ro', isa => 'HashRef', lazy_build => 1 );
+
+sub _build_config {
+ my( $self ) = @_;
+ return $self->get_config( 't/data/app' );
+}
+
+has schema => ( is => 'ro', isa => 'DBIx::Class::Schema', lazy_build => 1 );
+
+sub _build_schema {
+ my $self = shift;
+ my $config = $self->config->{schema};
+ return DvdDatabase::DBSchema->connect( $config->{dbi_dsn}, $config->{user}, $config->{pass}, $config->{dbi_params} );
+}
+
+has renderer => ( is => 'ro', lazy_build => 1 );
+sub _build_renderer {
+ my $self = shift;
+ my $config = $self->config->{renderer};
+ return WebNano::TTTRenderer->new( %$config );
+}
+
+sub get_config {
+ my( $self, $conf_file ) = @_;
+
+ my $cfg = Config::Any->load_stems({ stems => [ $conf_file ], use_ext => 1 });
+ my @values = values %{$cfg->[0]};
+ return $values[0];
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+DvdDatabase - A WebNano based example application.
+
+=head1 SYNOPSIS
+
+ zby@zby:~/progs/WebNano/examples/DvdDatabase$ plackup -Ilib
+ HTTP::Server::PSGI: Accepting connections at http://0:5000/
+
+=head1 DESCRIPTION
+
+CRUD operations on a database of DVD films.
+
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+
+package DvdDatabase::Controller;
+
+use base 'WebNano::Controller';
+
+sub index_action {
+ my $self = shift;
+ my $res = $self->request->new_response();
+ $res->redirect( '/Dvd/' );
+ return $res;
+}
+
+1;
+
@@ -1,11 +1,11 @@
use strict;
use warnings;
-package MyApp::Controller::Dvd;
+package DvdDatabase::Controller::Dvd;
use base 'WebNano::Controller';
-use MyApp::Controller::Dvd::Form;
-use MyApp::Controller::Dvd::Record;
+use DvdDatabase::Controller::Dvd::Form;
+use DvdDatabase::Controller::Dvd::Record;
sub index_action {
my( $self ) = @_;
@@ -17,7 +17,7 @@ sub create_action {
my ( $self ) = @_;
my $req = $self->request;
- my $form = MyApp::Controller::Dvd::Form->new(
+ my $form = DvdDatabase::Controller::Dvd::Form->new(
params => $req->parameters->as_hashref,
schema => $self->application->schema,
);
@@ -41,7 +41,7 @@ sub record_action {
$res->body( 'No record with id: ' . $id );
return $res;
}
- return MyApp::Controller::Dvd::Record->handle(
+ return DvdDatabase::Controller::Dvd::Record->handle(
path => $action,
application => $self->application,
env => $self->env,
@@ -0,0 +1,39 @@
+package DvdDatabase::Controller::Dvd::Form;
+use HTML::FormHandler::Moose;
+extends 'HTML::FormHandler::Model::DBIC';
+with 'HTML::FormHandler::Render::Simple';
+
+use DateTime;
+
+
+has '+item_class' => ( default => 'Dvd' );
+
+has_field 'tags' => ( type => 'Select', multiple => 1 );
+has_field 'hour' => ( type => 'Text', );
+has_field 'alter_date' => (
+ type => 'Compound',
+ apply => [
+ {
+ transform => sub{ DateTime->new( $_[0] ) },
+ message => "Not a valid DateTime",
+ }
+ ],
+ );
+has_field 'alter_date.year'; has_field 'alter_date.month'; has_field 'alter_date.day';
+has_field 'creation_date' => (
+ type => 'Compound',
+ apply => [
+ {
+ transform => sub{ DateTime->new( $_[0] ) },
+ message => "Not a valid DateTime",
+ }
+ ],
+ );
+has_field 'creation_date.year'; has_field 'creation_date.month'; has_field 'creation_date.day';
+has_field 'imdb_id' => ( type => 'Text', );
+has_field 'name' => ( type => 'TextArea', );
+has_field 'owner' => ( type => 'Select', );
+has_field 'current_borrower' => ( type => 'Select', );
+has_field 'submit' => ( widget => 'submit' );
+
+1;
@@ -1,7 +1,7 @@
use strict;
use warnings;
-package MyApp::Controller::Dvd::Record;
+package DvdDatabase::Controller::Dvd::Record;
use base 'WebNano::Controller';
@@ -37,7 +37,7 @@ sub delete_action {
sub edit_action {
my $self = shift;
my $req = $self->request;
- my $form = MyApp::Controller::Dvd::Form->new(
+ my $form = DvdDatabase::Controller::Dvd::Form->new(
item => $self->record,
params => $req->parameters->as_hashref,
);
@@ -1,10 +1,10 @@
-package MyApp::Controller::DvdSimpleUrl;
+package DvdDatabase::Controller::DvdSimpleUrl;
use Moose;
use MooseX::NonMoose;
extends 'WebNano::Controller';
-use MyApp::Controller::Dvd::Form;
+use DvdDatabase::Controller::Dvd::Form;
has record_methods => (
is => 'ro',
@@ -40,7 +40,7 @@ sub create_action {
my ( $self ) = @_;
my $req = $self->request;
- my $form = MyApp::Controller::Dvd::Form->new(
+ my $form = DvdDatabase::Controller::Dvd::Form->new(
params => $req->parameters->as_hashref,
schema => $self->application->schema,
);
@@ -76,7 +76,7 @@ sub delete {
sub edit {
my ( $self, $record ) = @_;
my $req = $self->request;
- my $form = MyApp::Controller::Dvd::Form->new(
+ my $form = DvdDatabase::Controller::Dvd::Form->new(
item => $record,
params => $req->parameters->as_hashref,
);
@@ -0,0 +1,16 @@
+package DvdDatabase::DBSchema;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_namespaces;
+
+
+# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-10-16 17:19:33
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:JDPcONC7Pl2Z6lIiq+c0yg
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
@@ -0,0 +1,91 @@
+package DvdDatabase::DBSchema::Result::Dvd;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("InflateColumn::DateTime", "UTF8Columns", "Core");
+__PACKAGE__->table("dvd");
+__PACKAGE__->add_columns(
+ "id",
+ {
+ data_type => "INTEGER",
+ default_value => undef,
+ is_nullable => 0,
+ size => undef,
+ },
+ "name",
+ {
+ data_type => "VARCHAR",
+ default_value => "NULL",
+ is_nullable => 1,
+ size => 255,
+ },
+ "imdb_id",
+ {
+ data_type => "INTEGER",
+ default_value => "NULL",
+ is_nullable => 1,
+ size => undef,
+ },
+ "owner",
+ {
+ data_type => "INTEGER",
+ default_value => undef,
+ is_nullable => 0,
+ size => undef,
+ },
+ "current_borrower",
+ {
+ data_type => "INTEGER",
+ default_value => "NULL",
+ is_nullable => 1,
+ size => undef,
+ },
+ "creation_date",
+ {
+ data_type => "date",
+ default_value => "NULL",
+ is_nullable => 1,
+ size => undef,
+ },
+ "alter_date",
+ {
+ data_type => "datetime",
+ default_value => "NULL",
+ is_nullable => 1,
+ size => undef,
+ },
+ "hour",
+ {
+ data_type => "time",
+ default_value => "NULL",
+ is_nullable => 1,
+ size => undef,
+ },
+);
+__PACKAGE__->set_primary_key("id");
+__PACKAGE__->belongs_to("owner", "DvdDatabase::DBSchema::Result::User", { id => "owner" });
+__PACKAGE__->belongs_to(
+ "current_borrower",
+ "DvdDatabase::DBSchema::Result::User",
+ { id => "current_borrower" },
+);
+__PACKAGE__->has_many(
+ "dvdtags",
+ "DvdDatabase::DBSchema::Result::Dvdtag",
+ { "foreign.dvd" => "self.id" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-10-16 17:19:33
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UoDXZVFJ2iiSBDyuryAqgA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+use overload '""' => sub {$_[0]->name}, fallback => 1;
+__PACKAGE__->many_to_many('tags', 'dvdtags' => 'tag');
+__PACKAGE__->utf8_columns(qw/id name imdb_id owner current_borrower creation_date alter_date hour/);
+
+1;
@@ -0,0 +1,39 @@
+package DvdDatabase::DBSchema::Result::Dvdtag;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("InflateColumn::DateTime", "UTF8Columns", "Core");
+__PACKAGE__->table("dvdtag");
+__PACKAGE__->add_columns(
+ "dvd",
+ {
+ data_type => "INTEGER",
+ default_value => "'0'",
+ is_nullable => 0,
+ size => undef,
+ },
+ "tag",
+ {
+ data_type => "INTEGER",
+ default_value => "'0'",
+ is_nullable => 0,
+ size => undef,
+ },
+);
+__PACKAGE__->set_primary_key("dvd", "tag");
+__PACKAGE__->belongs_to("dvd", "DvdDatabase::DBSchema::Result::Dvd", { id => "dvd" });
+__PACKAGE__->belongs_to("tag", "DvdDatabase::DBSchema::Result::Tag", { id => "tag" });
+
+
+# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-10-16 17:19:33
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8ORWqxYKxkfoxPBWSdb4vw
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+use overload '""' => sub {$_[0]->id}, fallback => 1;
+__PACKAGE__->utf8_columns(qw/dvd tag/);
+
+1;
Oops, something went wrong.

0 comments on commit 29782b7

Please sign in to comment.