Permalink
Browse files

Renderer-TT and Controller-CRUD have separate github projects now

  • Loading branch information...
1 parent 20f3e7c commit 079bcd75ea52bfc8c629d3eda929e2e607ad25e7 Zbigniew Lukasiak committed Sep 14, 2010
Showing with 0 additions and 1,107 deletions.
  1. +0 −7 extensions/WebNano-Controller-CRUD/app.psgi
  2. +0 −11 extensions/WebNano-Controller-CRUD/dist.ini
  3. +0 −151 extensions/WebNano-Controller-CRUD/lib/WebNano/Controller/CRUD.pm
  4. +0 −10 extensions/WebNano-Controller-CRUD/lib/WebNano/Controller/CRUD/templates/delete.tt
  5. +0 −6 extensions/WebNano-Controller-CRUD/lib/WebNano/Controller/CRUD/templates/edit.tt
  6. +0 −26 extensions/WebNano-Controller-CRUD/lib/WebNano/Controller/CRUD/templates/list.tt
  7. +0 −18 extensions/WebNano-Controller-CRUD/lib/WebNano/Controller/CRUD/templates/record.tt
  8. +0 −52 extensions/WebNano-Controller-CRUD/t/crud_base_controller.t
  9. +0 −10 extensions/WebNano-Controller-CRUD/t/data/app.conf
  10. BIN extensions/WebNano-Controller-CRUD/t/data/dvdzbr.db
  11. +0 −10 extensions/WebNano-Controller-CRUD/t/data/templates/OwnTemplates/delete.tt
  12. +0 −7 extensions/WebNano-Controller-CRUD/t/data/templates/OwnTemplates/edit.tt
  13. +0 −28 extensions/WebNano-Controller-CRUD/t/data/templates/OwnTemplates/list.tt
  14. +0 −71 extensions/WebNano-Controller-CRUD/t/data/templates/OwnTemplates/record.tt
  15. +0 −40 extensions/WebNano-Controller-CRUD/t/lib/MyApp.pm
  16. +0 −17 extensions/WebNano-Controller-CRUD/t/lib/MyApp/Controller.pm
  17. +0 −14 extensions/WebNano-Controller-CRUD/t/lib/MyApp/Controller/DvdWithBaseCRUD.pm
  18. +0 −42 extensions/WebNano-Controller-CRUD/t/lib/MyApp/Controller/Form.pm
  19. +0 −14 extensions/WebNano-Controller-CRUD/t/lib/MyApp/Controller/OwnTemplates.pm
  20. +0 −16 extensions/WebNano-Controller-CRUD/t/lib/MyApp/DBSchema.pm
  21. +0 −90 extensions/WebNano-Controller-CRUD/t/lib/MyApp/DBSchema/Result/Dvd.pm
  22. +0 −38 extensions/WebNano-Controller-CRUD/t/lib/MyApp/DBSchema/Result/Dvdtag.pm
  23. +0 −42 extensions/WebNano-Controller-CRUD/t/lib/MyApp/DBSchema/Result/Role.pm
  24. +0 −42 extensions/WebNano-Controller-CRUD/t/lib/MyApp/DBSchema/Result/Tag.pm
  25. +0 −52 extensions/WebNano-Controller-CRUD/t/lib/MyApp/DBSchema/Result/UnicodeExamples.pm
  26. +0 −66 extensions/WebNano-Controller-CRUD/t/lib/MyApp/DBSchema/Result/User.pm
  27. +0 −38 extensions/WebNano-Controller-CRUD/t/lib/MyApp/DBSchema/Result/UserRole.pm
  28. BIN extensions/WebNano-Controller-CRUD/t/tmp/dvdzbr.db
  29. +0 −11 extensions/WebNano-Renderer-TT/dist.ini
  30. +0 −95 extensions/WebNano-Renderer-TT/lib/WebNano/Renderer/TT.pm
  31. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt1/include_global.tt
  32. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt1/some_template.tt
  33. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt1/subdir1/template.tt
  34. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt1/subdir2/some
  35. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt1/subdir2/template.tt
  36. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt1/subdir2/template1.tt
  37. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt2/second_root.tt
  38. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt2/some_template.tt
  39. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt2/subdir1/second_root.tt
  40. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt2/subdir2/second_root.tt
  41. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt2/subdir2/second_root1.tt
  42. +0 −1 extensions/WebNano-Renderer-TT/t/data/tt_globals/some_global.tt
  43. +0 −71 extensions/WebNano-Renderer-TT/t/tt_renderer.t
@@ -1,7 +0,0 @@
-use lib 't/lib';
-
-use MyApp;
-my $app = MyApp->new();
-$app->psgi_callback;
-
-
@@ -1,11 +0,0 @@
-name = WebNano-Controller-CRUD
-author = Zbigniew Lukasiak <zby@cpan.org>
-license = Perl_5
-copyright_holder = Zbigniew Lukasiak <zby@cpan.org>
-copyright_year = 2010
-
-[@Basic]
-[AutoVersion]
-[AutoPrereq]
-[TestRelease]
-
@@ -1,151 +0,0 @@
-package WebNano::Controller::CRUD;
-use Moose;
-use MooseX::NonMoose;
-use Class::MOP;
-use File::Spec::Functions 'catdir';
-
-extends 'WebNano::Controller';
-
-has form_class => ( is => 'ro', isa => 'Str', required => 1 );
-has rs_name => ( is => 'ro', isa => 'Str', lazy_build => 1, );
-sub _build_rs_name {
- my $self = shift;
- my $my_name = ref $self;
- $my_name =~ /::(\w+)$/;
- return $1;
-}
-
-has record_actions => (
- is => 'ro',
- isa => 'HashRef',
- default => sub { { view => 1, 'delete' => 1, edit => 1 } }
-);
-
-my $FULLPATH;
-BEGIN { use Cwd (); $FULLPATH = Cwd::abs_path(__FILE__) }
-
-sub template_search_path {
- my $self = shift;
- my $mydir = $FULLPATH;
- $mydir =~ s/.pm$//;
- return [ catdir( $mydir, 'templates' ) ];
-}
-
-sub columns {
- my $self = shift;
- my $source = $self->app->schema->source( $self->rs_name );
- return [ $source->columns ];
-}
-
-
-sub parse_path {
- my( $self, $path ) = @_;
- my $parsed;
- my $method_reg = join '|', keys %{ $self->record_actions };
- if( $path =~ s{^(\d+)/($method_reg|)($|/)}{} ){
- $parsed->{ids} = [ $1 ];
- $parsed->{method} = $2 || 'view';
- $parsed->{args} = [ split /\//, $path ];
- return $parsed;
- }
- return;
-}
-
-around 'local_dispatch' => sub {
- my( $orig, $self, $path, @args ) = @_;
- my $parsed = $self->parse_path( $path );
- if( $parsed ){
- my $rs = $self->app->schema->resultset( $self->rs_name );
- my $record = $rs->find( @{ $parsed->{ids} } );
- if( ! $record ) {
- my $res = $self->req->new_response(404);
- $res->content_type('text/plain');
- $res->body( 'No record with ids: ' . join ' ', @{ $parsed->{ids} } );
- return $res;
- }
- my $method = $parsed->{method};
- return $self->$method( $record, @{ $parsed->{args} }, @args );
- }
- return $self->$orig( $path, @args );
-};
-
-sub index_action { shift->list_action( @_ ) }
-
-sub list_action {
- my( $self ) = @_;
- my $rs = $self->app->schema->resultset( $self->rs_name );
- return $self->render( template => 'list.tt', items => [ $rs->search ] );
-}
-
-sub create_action {
- my ( $self ) = @_;
- my $req = $self->req;
-
- my $form_class = $self->form_class;
- Class::MOP::load_class( $form_class );
- my $item = $self->app->schema->resultset( $self->rs_name )->new_result( {} );
- my $form = $form_class->new(
- params => $req->parameters->as_hashref,
- schema => $self->app->schema,
- item => $item,
- );
- if( $req->method eq 'POST' && $form->process() ){
- my $record = $form->item;
- my $res = $req->new_response();
- $res->redirect( $self->self_url . $record->id . '/view' );
- return $res;
- }
- $form->field( 'submit' )->value( 'Create' );
- return $self->render( template => 'edit.tt', form => $form->render );
-}
-
-sub view {
- my ( $self, $record ) = @_;
-
- return $self->render( template => 'record.tt', record => $record );
-}
-
-sub delete {
- my ( $self, $record ) = @_;
- if( $self->req->method eq 'GET' ){
- return $self->render( template => 'delete.tt', record => $record );
- }
- else{
- $record->delete;
- my $res = $self->req->new_response();
- $res->redirect( $self->self_url );
- return $res;
- }
-}
-
-sub edit {
- my ( $self, $record ) = @_;
- my $req = $self->req;
- my $form_class = $self->form_class;
- Class::MOP::load_class( $form_class );
- my $form = $form_class->new(
- item => $record,
- params => $req->parameters->as_hashref,
- );
- if( $req->method eq 'POST' && $form->process() ){
- my $res = $req->new_response();
- $res->redirect( $self->self_url . $record->id . '/view' );
- return $res;
- }
- $form->field( 'submit' )->value( 'Update' );
- return $self->render( template => 'edit.tt', form => $form->render );
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-WebNano::Controller::CRUD - A base controller implementing CRUD operations
-
-=head1 SYNOPSIS
-
-use base 'WebNano::Controller::CRUD';
-
-
@@ -1,10 +0,0 @@
-<html>
-<body>
-<form method="post">
-<fieldset class="widget_fieldset">
-<input class="submit" id="widget_ok" name="ok" type="submit" value="Delete ?" />
-</fieldset>
-</form>
-</body>
-</html>
-
@@ -1,6 +0,0 @@
-<html>
-<body>
-[% form %]
-</body>
-</html>
-
@@ -1,26 +0,0 @@
-<html>
-<body>
-<table>
-<tr>
-[% FOREACH col IN c.columns %]
-<th>[% col %]</td>
-[% END %]
-<td></td>
-<td></td>
-<td></td>
-</tr>
-[% FOREACH record IN items %]
-<tr>
-[% FOREACH col IN c.columns %]
-<td>
-[% record.$col %]
-</td>
-[% END %]
-<td><a href="[% c.self_url %][% record.id %]/view">View</a></td>
-<td><a href="[% c.self_url %][% record.id %]/edit">Edit</a></td>
-<td><a href="[% c.self_url %][% record.id %]/delete">Delete</a></td>
-</tr>
-[% END %]
-</body>
-</html>
-
@@ -1,18 +0,0 @@
-<html>
-<body>
-Fields.
-<table>
-[% FOREACH col IN c.columns %]
-<tr>
-<td>
-<strong>[% col %]</strong>
-</td>
-<td>
-[% record.$col %]
-</td>
-</tr>
-[% END %]
-</table>
-</body>
-</html>
-
@@ -1,52 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-use Plack::Test;
-use HTTP::Request::Common;
-use lib 't/lib';
-use lib 'extensions/lib';
-use MyApp;
-use File::Copy;
-
-for my $controller( qw/DvdWithBaseCRUD OwnTemplates/ ){
-
- copy('t/data/dvdzbr.db','t/tmp/dvdzbr.db') or die "Copy failed: $!";
-
- test_psgi(
- app => MyApp->new()->psgi_callback,
- client => sub {
- my $cb = shift;
- my $res;
- $res = $cb->(GET "/$controller/");
- like( $res->content, qr/Jurassic Park II/ );
- $res = $cb->(POST "/$controller/5/edit", [ name => 'Not Jurassic Park' ] );
- ok( $res->is_redirect, 'Redirect after POST' );
- $res = $cb->(GET $res->header('Location'));
- $res = $cb->(GET "/$controller/create" );
- like( $res->content, qr/alter_date.year/ );
- $res = $cb->(POST "/$controller/create", [ name => 'A new dvd', owner => 1 ] );
- ok( $res->is_redirect, 'Redirect after POST' );
- $res = $cb->(GET $res->header('Location'));
- like( $res->content, qr/A new dvd/ );
- $res = $cb->(GET "/$controller/view/5");
- is( $res->code, 404 , '404 for view with no record' );
- $res = $cb->(GET "/$controller/555/view");
- is( $res->code, 404 , '404 for view with no record' );
- }
- );
-}
-
-test_psgi(
- app => MyApp->new()->psgi_callback,
- client => sub {
- my $cb = shift;
- my $res;
- $res = $cb->(GET "/OwnTemplates/");
- like( $res->content, qr{This is t/data/templates/OwnTemplates/list.tt} );
- $res = $cb->(GET "/OwnTemplates/5/view");
- like( $res->content, qr{This is t/data/templates/OwnTemplates/record.tt} );
- }
-);
-
-done_testing();
@@ -1,10 +0,0 @@
-<renderer>
-root = t/data/templates
-</renderer>
-<schema>
-dbi_dsn = dbi:SQLite:dbname=t/tmp/dvdzbr.db
-<dbi_params>
-sqlite_unicode = 1
-</dbi_params>
-</schema>
-
Binary file not shown.
@@ -1,10 +0,0 @@
-<html>
-<body>
-<form method="post">
-<fieldset class="widget_fieldset">
-<input class="submit" id="widget_ok" name="ok" type="submit" value="Delete ?" />
-</fieldset>
-</form>
-</body>
-</html>
-
@@ -1,7 +0,0 @@
-<html>
-<body>
-[% form %]
-This is t/data/templates/OwnTemplates/edit.tt
-</body>
-</html>
-
@@ -1,28 +0,0 @@
-<html>
-<body>
-<table>
-<tr>
-<th>name</td>
-<th>creation_date</td>
-<td></td>
-<td></td>
-<td></td>
-</tr>
-[% FOREACH record IN items %]
-<tr>
-<td>
-[% record.name %]
-</td>
-<td>
-[% record.creation_date %]
-</td>
-<td><a href="[% c.self_url %][% record.id %]/view">View</a></td>
-<td><a href="[% c.self_url %][% record.id %]/edit">Edit</a></td>
-<td><a href="[% c.self_url %][% record.id %]/delete">Delete</a></td>
-</tr>
-[% END %]
-
-This is t/data/templates/OwnTemplates/list.tt
-</body>
-</html>
-
Oops, something went wrong. Retry.

0 comments on commit 079bcd7

Please sign in to comment.