[Jifty-commit] r3504 - in jifty/branches/trimclient: . examples/Yada/lib/Example examples/Yada/lib/Example/Todo examples/Yada/lib/Example/Todo/Action examples/Yada/lib/Example/Todo/Model lib/Jifty lib/Jifty/Plugin/Authentication/Password lib/Jifty/Plugin/CompressedCSSandJS lib/Jifty/Plugin/ErrorTemplates lib/Jifty/View lib/Jifty/View/Declare lib/Jifty/View/Mason lib/Jifty/Web lib/Jifty/Web/Form share/web/static/js share/web/templates/__jifty/webservices t/TestApp/lib/TestApp t/TestApp/lib/TestApp/View t/TestApp/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Jun 15 07:23:27 EDT 2007


Author: clkao
Date: Fri Jun 15 07:23:21 2007
New Revision: 3504

Added:
   jifty/branches/trimclient/examples/Yada/lib/Example/
   jifty/branches/trimclient/examples/Yada/lib/Example/Todo/
   jifty/branches/trimclient/examples/Yada/lib/Example/Todo/Action/
   jifty/branches/trimclient/examples/Yada/lib/Example/Todo/Model/
   jifty/branches/trimclient/examples/Yada/lib/Example/Todo/Model/Todo.pm
Modified:
   jifty/branches/trimclient/   (props changed)
   jifty/branches/trimclient/Makefile.PL
   jifty/branches/trimclient/debian/control
   jifty/branches/trimclient/lib/Jifty/Plugin/Authentication/Password/View.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm
   jifty/branches/trimclient/lib/Jifty/Plugin/ErrorTemplates/View.pm
   jifty/branches/trimclient/lib/Jifty/Request.pm
   jifty/branches/trimclient/lib/Jifty/View.pm
   jifty/branches/trimclient/lib/Jifty/View/Declare.pm
   jifty/branches/trimclient/lib/Jifty/View/Declare/BaseClass.pm
   jifty/branches/trimclient/lib/Jifty/View/Declare/CRUD.pm
   jifty/branches/trimclient/lib/Jifty/View/Declare/Helpers.pm
   jifty/branches/trimclient/lib/Jifty/View/Mason/Handler.pm
   jifty/branches/trimclient/lib/Jifty/Web/Form.pm
   jifty/branches/trimclient/lib/Jifty/Web/Form/Element.pm
   jifty/branches/trimclient/lib/Jifty/Web/PageRegion.pm
   jifty/branches/trimclient/share/web/static/js/jifty.js
   jifty/branches/trimclient/share/web/templates/__jifty/webservices/xml
   jifty/branches/trimclient/t/TestApp/lib/TestApp/View.pm
   jifty/branches/trimclient/t/TestApp/lib/TestApp/View/base.pm
   jifty/branches/trimclient/t/TestApp/lib/TestApp/View/instance.pm
   jifty/branches/trimclient/t/TestApp/t/15-template-subclass.t

Log:
 r18204 at ubuntu (orig r3448):  clkao | 2007-06-12 13:27:03 +0100
 Do not call update() when ctrl-clicked
 r18209 at ubuntu (orig r3453):  clkao | 2007-06-12 16:27:39 +0100
 Always give the dispatcher unescaped path like fastcgi does,
 from standalone, webservice, and region entrance.
 
 r18212 at ubuntu (orig r3455):  clkao | 2007-06-12 17:33:02 +0100
 Fix the template subclassing tests.
 
 r18213 at ubuntu (orig r3456):  clkao | 2007-06-12 20:12:54 +0100
 YourApp::View->use_mason_wrapper now lets your write page {} in TD but uses
 your mason wrapper.
 
 r18221 at ubuntu (orig r3461):  clkao | 2007-06-12 20:53:31 +0100
 Make use_mason_wrapper actually work.
 
 r18224 at ubuntu (orig r3462):  trs | 2007-06-12 21:23:20 +0100
 
 r18225 at ubuntu (orig r3463):  trs | 2007-06-12 21:23:37 +0100
  r22078 at zot:  tom | 2007-06-12 15:30:55 -0400
  Extraneous warning
 
 r18226 at ubuntu (orig r3464):  trs | 2007-06-12 21:23:47 +0100
  r22079 at zot:  tom | 2007-06-12 16:22:25 -0400
  Be more in line with original code and apply Behaviour immediately, not in the callback
 
 r18233 at ubuntu (orig r3466):  jesse | 2007-06-12 23:05:18 +0100
 
 r18234 at ubuntu (orig r3467):  jesse | 2007-06-12 23:05:48 +0100
 
 r18235 at ubuntu (orig r3468):  jesse | 2007-06-12 23:06:30 +0100
  r58252 at pinglin:  jesse | 2007-06-12 17:54:09 -0400
  * try not to interfere when a user clicks on a link with a modifier key pressed
 
 r18236 at ubuntu (orig r3469):  clkao | 2007-06-12 23:55:15 +0100
 Fix jifty->web->out from without td used with mason wrapper.
 r18237 at ubuntu (orig r3470):  jesse | 2007-06-13 00:15:10 +0100
  r58268 at pinglin:  jesse | 2007-06-12 19:15:01 -0400
   * _redirect expects a local path, not a fully formed URL. (This only actually broke internal redirects)
 
 r18238 at ubuntu (orig r3471):  clkao | 2007-06-13 01:10:14 +0100
 New Template::Declare page syntax for additional code block run
 before wrapper, and have the returned value passed to wrapper:
 
 template foo => 
   page { title => 'this is title', other => 'foo' }
   content {
     h1 { 'blah }
   };
 
 r18257 at ubuntu (orig r3474):  jesse | 2007-06-14 07:15:34 +0100
  r58297 at pinglin:  jesse | 2007-06-14 02:14:20 -0400
  * Jifty->web->form->next_page got dropped when you submit only a specific action with Jifty->web->form->submit. This commit autoadds next_page if you submit only a subset of actions.
 
 r18267 at ubuntu (orig r3481):  sterling | 2007-06-14 15:46:41 +0100
 
 r18268 at ubuntu (orig r3482):  sterling | 2007-06-14 15:49:08 +0100
  r7618 at dynpc145:  andrew | 2007-06-14 09:42:56 -0500
  Cleaning up and improving some of the view documentation.
 
 r18269 at ubuntu (orig r3483):  yves | 2007-06-14 16:16:25 +0100
 * debian dependancies
 * T::D 0.21 needed to pass tests
 
 r18280 at ubuntu (orig r3492):  trs | 2007-06-14 22:42:02 +0100
 
 r18281 at ubuntu (orig r3493):  trs | 2007-06-14 22:42:15 +0100
  r22078 at zot:  tom | 2007-06-12 15:30:55 -0400
  Extraneous warning
 
 r18282 at ubuntu (orig r3494):  trs | 2007-06-14 22:42:18 +0100
  r22079 at zot:  tom | 2007-06-12 16:22:25 -0400
  Be more in line with original code and apply Behaviour immediately, not in the callback
 
 r18283 at ubuntu (orig r3495):  trs | 2007-06-14 22:42:31 +0100
  r22184 at zot:  tom | 2007-06-14 17:41:23 -0400
  Also export display_columns so it's not required to override it
 
 r18284 at ubuntu (orig r3496):  jesse | 2007-06-15 01:18:13 +0100
  r58374 at pinglin:  jesse | 2007-06-14 20:17:33 -0400
   * Full doc for the existing CRUD templates
 
 r18289 at ubuntu (orig r3501):  jesse | 2007-06-15 05:17:09 +0100
  r58389 at pinglin:  jesse | 2007-06-15 00:16:54 -0400
  * CRUD plugin cleanup and refactoring
 


Modified: jifty/branches/trimclient/Makefile.PL
==============================================================================
--- jifty/branches/trimclient/Makefile.PL	(original)
+++ jifty/branches/trimclient/Makefile.PL	Fri Jun 15 07:23:21 2007
@@ -61,7 +61,7 @@
 requires('Shell::Command');
 requires('String::Koremutake');
 requires('SQL::ReservedWords');
-requires('Template::Declare' => '0.07');                # Template::Declare::Tags
+requires('Template::Declare' => '0.21');                # Template::Declare::Tags
 requires('Test::Base');
 requires('Test::LongString');
 requires('Test::More' => 0.62 ),

Modified: jifty/branches/trimclient/debian/control
==============================================================================
--- jifty/branches/trimclient/debian/control	(original)
+++ jifty/branches/trimclient/debian/control	Fri Jun 15 07:23:21 2007
@@ -66,14 +66,14 @@
  libhtml-lint-perl, libhtml-mason-perl (>> 1.31), 
  libwww-perl, libhttp-server-simple-perl (>> 0.26), 
  libhttp-server-simple-recorder-perl, libhash-merge-perl, libhook-lexwrap-perl,
- libipc-pubsub-perl (>> 0.23), libjifty-dbi-perl (>> 0.40),
+ libipc-pubsub-perl (>> 0.23), libjifty-dbi-perl (>> 0.40), libipc-run3-perl,
  liblocale-maketext-lexicon-perl, liblocale-maketext-simple-perl, liblog-log4perl-perl,
  libmime-types-perl, libmodule-pluggable-perl (>> 3.5),
  libmodule-corelist-perl, libmodule-refresh-perl,
  libmodule-scandeps-perl, libobject-declare-perl (>> 0.22),
  libparams-validate-perl, libscalar-defer-perl (>> 0.10),
  libstring-koremutake-perl, libsql-reservedwords-perl,
- libtemplate-declare-perl (>> 0.07), 
+ libtemplate-declare-perl (>> 0.21), 
  libtest-base-perl, libuniversal-require-perl, liburi-perl,
  libxml-writer-perl (>> 0.601), libxml-simple-perl,
  libxml-xpath-perl, libversion-perl, libyaml-syck-perl (>> 0.72), 

Added: jifty/branches/trimclient/examples/Yada/lib/Example/Todo/Model/Todo.pm
==============================================================================
--- (empty file)
+++ jifty/branches/trimclient/examples/Yada/lib/Example/Todo/Model/Todo.pm	Fri Jun 15 07:23:21 2007
@@ -0,0 +1,17 @@
+use strict;
+use warnings;
+
+package Example::Todo::Model::Todo;
+use Jifty::DBI::Schema;
+
+use Example::Todo::Record schema {
+
+    column done => type is 'bool';
+    column description => type is 'text';
+
+};
+
+# Your model-specific methods go here.
+
+1;
+

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/Authentication/Password/View.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/Authentication/Password/View.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/Authentication/Password/View.pm	Fri Jun 15 07:23:21 2007
@@ -17,7 +17,7 @@
 use Jifty::View::Declare -base;
 
 { no warnings 'redefine';
-sub page (&) {
+sub page (&;$) {
     no strict 'refs'; 
     BEGIN {Jifty::Util->require(Jifty->app_class('View'))};
     Jifty->app_class('View')->can('page')->(@_);

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm	Fri Jun 15 07:23:21 2007
@@ -63,7 +63,6 @@
 
 on '/__jifty/css/*' => run {
     my $arg = $1;
-    warn "My arg is $arg";
     if ( $arg !~ /^[0-9a-f]{32}\.css$/ ) {
 
         # This doesn't look like a real request for squished CSS,

Modified: jifty/branches/trimclient/lib/Jifty/Plugin/ErrorTemplates/View.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Plugin/ErrorTemplates/View.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Plugin/ErrorTemplates/View.pm	Fri Jun 15 07:23:21 2007
@@ -55,7 +55,7 @@
 {
     no warnings qw'redefine';
 
-    sub wrapper ($) {
+    sub wrapper {
         my $code = shift;
         html {
             head {

Modified: jifty/branches/trimclient/lib/Jifty/Request.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Request.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Request.pm	Fri Jun 15 07:23:21 2007
@@ -221,7 +221,9 @@
     my $self = shift;
     my ($cgi) = @_;
 
-    my $path = $cgi->path_info;
+    # always get the unescaped path for dispatcher, which is already
+    # the case for fastcgi, but not standalone.
+    my $path = URI::Escape::uri_unescape($cgi->path_info);
     $path =~ s/\?.*//;
     $self->path( $path );
 
@@ -511,7 +513,8 @@
     );
 
     # Set us up with the new continuation
-    Jifty->web->_redirect( Jifty->web->url(path => $path)
+    Jifty->web->_redirect( 
+                        $path
                       . ( $path =~ /\?/ ? "&" : "?" ) . "J:C="
                       . $c->id );
 }

Modified: jifty/branches/trimclient/lib/Jifty/View.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/View.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/View.pm	Fri Jun 15 07:23:21 2007
@@ -2,6 +2,16 @@
 use strict;
 use warnings;
 
+=head1 NAME
+
+Jifty::View - Base class for view modules
+
+=head1 DESCRIPTION
+
+This is the base class for L<Jifty::View::Declare> and L<Jifty::View::Mason::Handler>, which are the two view plugins shipped with Jifty. Other view plugins can be built by extending this class.
+
+=head1 METHODS
+
 =head2 auto_send_headers
 
 Doesn't send headers if this is a subrequest (according to the current
@@ -42,5 +52,17 @@
     }
 }
 
+=head1 SEE ALSO
+
+L<Jifty::View::Declare>, L<Jifty::View::Declare::BaseClass>, L<Jifty::View::Mason::Handler>
+
+=head1 LICENSE
+
+Jifty is Copyright 2005-2007 Best Practical Solutions, LLC.
+Jifty is distributed under the same terms as Perl itself.
+
+=cut
+
+
 
 1;

Modified: jifty/branches/trimclient/lib/Jifty/View/Declare.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/View/Declare.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/View/Declare.pm	Fri Jun 15 07:23:21 2007
@@ -5,6 +5,10 @@
 use warnings;
 use constant BaseClass => 'Jifty::View::Declare::BaseClass';
 
+=head1 NAME
+
+Jifty::View::Declare - Build views using Template::Declare
+
 =head1 SYNOPSIS
 
     package MyApp::View;
@@ -15,6 +19,19 @@
         b { "The Index" };
     };
 
+=head1 DESCRIPTION
+
+L<Template::Declare> is a templating system using a declarative syntax built on top of Perl. This provides a templating language built in a similar style to the dispatcher language in L<Jifty::Dispatcher>, the model language in L<Jifty::DBI::Schema>, and the action language in L<Jifty::Param::Schema>.
+
+To use this view system, you must declare a class named C<MyApp::View> (where I<MyApp> is the name of your Jifyt application). Use this library class to bring in all the details needed to make it work:
+
+  package MyApp::View;
+  use Jifty::View::Declare -base;
+
+  # Your code...
+
+For more details on how to write the individual templates, see L<Template::Declare> and also L<Jifty::View::Declare::Helpers> for Jifty specific details.
+
 =cut
 
 sub import {
@@ -29,4 +46,15 @@
     goto &{BaseClass()->can('import')};
 }
 
+=head1 SEE ALSO 
+
+L<Jifty::View::Declare::Helpers>, L<Template::Declare>
+
+=head1 LICENSE
+
+Jifty is Copyright 2005-2007 Best Practical Solutions, LLC.
+Jifty is distrib uted under the same terms as Perl itself.
+
+=cut
+
 1;

Modified: jifty/branches/trimclient/lib/Jifty/View/Declare/BaseClass.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/View/Declare/BaseClass.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/View/Declare/BaseClass.pm	Fri Jun 15 07:23:21 2007
@@ -12,25 +12,62 @@
 
 our @EXPORT = ( @Jifty::View::Declare::Helpers::EXPORT);
 
-
-1;
-__DATA__
-
 =head1 NAME
 
-Jifty::View::Declare::BaseClass
+Jifty::View::Declare::BaseClass - Base class for Template::Declare views
 
 =head1 DESCRIPTION
 
-This class provides a baseclass for your C<Template::Declare> derived view classes.
-
+This class provides a base class for your L<Template::Declare> derived view classes.
 
 =head1 METHODS
 
+=head2 use_mason_wrapper
+
+Call this function in your view class to use your mason wrapper for L<Template::Declare> templates.
+
+=cut
+
+sub use_mason_wrapper {
+    my $class = shift;
+    no strict 'refs';
+    no warnings 'redefine';
+    *{ $class . '::wrapper' } = sub {
+        my $code = shift;
+        my $args = shift;
+        # so in td handler, we made jifty::web->out appends to td
+        # buffer, we need it back for here before we call $code.
+        # someday we need to finish fixing the output system that is
+        # in Jifty::View.
+        my $td_out = \&Jifty::Web::out;
+        local *Jifty::Web::out = sub { shift->mason->out(@_) };
+
+        local *HTML::Mason::Request::content = sub {
+            local *Jifty::Web::out = $td_out;
+            $code->();
+            my $content = Template::Declare->buffer->data;
+            Template::Declare->buffer->clear;
+            $content;
+        };
+
+        Jifty->handler->fallback_view_handler->show('/_elements/wrapper', $args);
+    }
+}
+
+
 =head2 show templatename arguments
 
 Render a C<Template::Declare> template.
 
+=head1 SEE ALSO
+
+L<Template::Declare>, L<Jifty::View::Declare::Helpers>, L<Jifty::View::Declare>
+
+=head1 LICENSE
+
+Jifty is Copyright 2005-2007 Best Practical Solutions, LLC.
+Jifty is distributed under the same terms as Perl itself.
 
 =cut
 
+1;

Modified: jifty/branches/trimclient/lib/Jifty/View/Declare/CRUD.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/View/Declare/CRUD.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/View/Declare/CRUD.pm	Fri Jun 15 07:23:21 2007
@@ -3,8 +3,6 @@
 
 package Jifty::View::Declare::CRUD;
 use Jifty::View::Declare -base;
-use base 'Exporter';
-our @EXPORT = qw(object_type fragment_for get_record current_collection);
 
 # XXX: should register 'template type' handler, so the
 # client_cache_content & the TD sub here agrees with the arguments.
@@ -14,6 +12,24 @@
     $VIEW{$_[2]}++;
 }
 
+
+=head1 NAME
+
+Jifty::View::Declare::CRUD - Provides typical CRUD views to a model
+
+=head1 DESCRIPTION
+
+This class provides a set of views that may be used by a model to display Create/Read/Update/Delete views using the L<Template::Declare> templating langauge.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 mount_view MODELCASS VIEWCLASS /path
+
+=cut
+
 sub mount_view {
     my ($class, $model, $vclass, $path) = @_;
     my $caller = caller(0);
@@ -42,11 +58,21 @@
     goto $code;
 }
 
+
+=head2 object_type
+
+=cut
+
 sub object_type {
     my $self = shift;
     return $self->package_variable('object_type') || get('object_type');
 }
 
+
+=head2 fragment_for
+
+=cut
+
 sub fragment_for {
     my $self     = shift;
     my $fragment = shift;
@@ -59,12 +85,22 @@
         || $self->fragment_base_path . "/" . $fragment;
 }
 
+=head2 fragment_base_path
+
+=cut
+
 sub fragment_base_path {
     my $self = shift;
     return $self->package_variable('base_path') || '/crud';
 }
 
-sub get_record {
+=head2 _get_record $id
+
+Given an $id, returns a record object for the CRUD view's model class.
+
+=cut
+
+sub _get_record {
     my ( $self, $id ) = @_;
 
     my $record_class = Jifty->app_class( "Model", $self->object_type );
@@ -74,6 +110,51 @@
     return $record;
 }
 
+=head2 display_columns
+
+Returns a list of all the columns that this REST view should display
+
+=cut
+
+sub display_columns {
+    my $self = shift;
+    my $action = shift;
+     return   grep { !( m/_confirm/ || lc $action->arguments->{$_}{render_as} eq 'password' ) } $action->argument_names;
+}
+
+
+=head1 TEMPLATES
+
+
+=cut
+
+=head2 index.html
+
+
+=cut
+
+
+template 'index.html' => page {
+    my $self = shift;
+    title is $self->object_type;
+    form {
+            render_region(
+                name     => $self->object_type.'-list',
+                path     => $self->fragment_base_path.'/list');
+    }
+
+};
+
+ 
+
+
+
+=head2 search
+
+The search view displays a search screen connected to the search action of the module. See L<Jifty::Action::Record::Search>.
+
+=cut
+
 template 'search' => sub {
     my $self          = shift;
     my ($object_type) = ( $self->object_type );
@@ -99,11 +180,11 @@
         }
 };
 
-sub display_columns {
-    my $self = shift;
-    my $action = shift;
-     return   grep { !( m/_confirm/ || lc $action->arguments->{$_}{render_as} eq 'password' ) } $action->argument_names;
-}
+=head2 view
+
+This template displays the data held by a single model record.
+
+=cut
 
 template 'view' => sub :CRUDView {
     my ($self, $record) = @_;
@@ -117,6 +198,19 @@
         { class is 'crud read item inline' };
         my @fields = $self->display_columns($update);
         render_action( $update, \@fields, { render_mode => 'read' } );
+
+        show ('./view_item_controls', $record, $update); 
+
+        hr {};
+    };
+
+};
+
+private template view_item_controls  => sub {
+
+        my $self = shift;
+        my $record = shift;
+        my $action = shift;
         hyperlink(
             label   => "Edit",
             class   => "editlink",
@@ -125,11 +219,15 @@
                 args         => { id => $record->id }
             },
         );
-
-        hr {};
     };
 
-};
+
+
+=head2 update
+
+The update template displays a form for editing the data held within a single model record. See L<Jifty::Action::Record::Update>.
+
+=cut
 
 template 'update' => sub {
     my $self = shift;
@@ -148,6 +246,27 @@
         { class is "crud update item inline " . $object_type }
 
         show('./edit_item', $update);
+        show('./edit_item_controls', $record, $update);
+
+        hr {};
+        }
+};
+
+
+
+=head2 edit_item_controls $record $action
+
+The controls we should be rendering in the 'edit' region for a given fragment
+
+=cut
+
+private template edit_item_controls => sub {
+    my $self = shift;
+    my $record = shift;
+    my $update = shift;
+
+    my $object_type = $self->object_type;
+    my $id = $record->id;
         div {
             { class is 'crud editlink' };
             hyperlink(
@@ -169,12 +288,32 @@
             );
         };
 
-        hr {};
-        }
 };
 
+=head2 list
+
+The list template provides an interactive list for showing a list of records in the record collection, adding new records, deleting records, and updating records.
+
+=cut
 
-sub current_collection {
+template 'list' => sub {
+    my $self = shift;
+
+    my ( $page ) = get(qw(page ));
+    my $fragment_for_new_item = get('fragment_for_new_item') || $self->fragment_for('new_item');
+    my $item_path = get('item_path') || $self->fragment_for("view");
+    my $collection =  $self->_current_collection();
+
+    show('./search_region');
+    show( './paging_top',    $collection, $page );
+    show( './list_items',    $collection, $item_path );
+    show( './paging_bottom', $collection, $page );
+    show( './new_item_region', $fragment_for_new_item );
+
+};
+
+
+sub _current_collection {
     my $self =shift; 
     my ( $page, $search_collection ) = get(qw(page  search_collection));
 
@@ -193,21 +332,12 @@
     return $collection;    
 }
 
-template 'list' => sub {
-    my $self = shift;
 
-    my ( $page ) = get(qw(page ));
-    my $fragment_for_new_item = get('fragment_for_new_item') || $self->fragment_for('new_item');
-    my $item_path = get('item_path') || $self->fragment_for("view");
-    my $collection =  $self->current_collection();
+=head2 search_region
 
-    show('./search_region');
-    show( './paging_top',    $collection, $page );
-    show( './list_items',    $collection, $item_path );
-    show( './paging_bottom', $collection, $page );
-    show( './new_item_region', $fragment_for_new_item );
+This I<private> template renders a region to show an expandable region for a search widget.
 
-};
+=cut
 
 private template 'search_region' => sub {
     my $self        = shift;
@@ -231,6 +361,14 @@
 
     outs( $search_region->render );
 };
+
+=head2 new_item_region
+
+This I<private> template renders a region to show a the C<new_item> template.
+
+=cut
+
+
 private template 'new_item_region' => sub {
     my $self        = shift;
     my $fragment_for_new_item = shift;
@@ -245,6 +383,15 @@
     }
 };
 
+
+=head2 list_items $collection $item_path
+
+Renders a div of class list with a region per item.
+
+
+
+=cut
+
 private template 'list_items' => sub {
     my $self        = shift;
     my $collection  = shift;
@@ -267,6 +414,14 @@
 
 };
 
+
+=head2 paging_top $collection $page_number
+
+Paging for your list, rendered at the top of the list
+
+=cut
+
+
 private template 'paging_top' => sub {
     my $self       = shift;
     my $collection = shift;
@@ -282,6 +437,12 @@
 
 };
 
+=head2 paging_bottom $collection $page_number
+
+Paging for your list, rendered at the bottom of the list
+
+=cut
+
 private template paging_bottom => sub {
     my $self       = shift;
     my $collection = shift;
@@ -313,12 +474,26 @@
 };
 
 
+
+=head2 edit_item $action
+
+Renders the action $Action, handing it the array ref returned by L</display_columns>.
+
+=cut
+
+
+
 private template 'edit_item' => sub {
     my $self = shift;
     my $action = shift;
     render_action($action, [$self->display_columns($action)]);
 };
 
+=head1 new_item
+
+The new_item template provides a form for creating new model records. See L<Jifty::Action::Record::Create>.
+
+=cut
 
 template 'new_item' => sub {
     my $self = shift;
@@ -352,5 +527,16 @@
         }
 };
 
+=head1 SEE ALSO
+
+L<Jifty::Action::Record::Create>, L<Jifty::Action::Record::Search>, L<Jifty::Action::Record::Update>, L<Jifty::Action::Record::Delete>, L<Template::Declare>, L<Jifty::View::Declare::Helpers>, L<Jifty::View::Declare>
+
+=head1 LICENSE
+
+Jifty is Copyright 2005-2007 Best Practical Solutions, LLC.
+Jifty is distributed under the same terms as Perl tiself.
+
+=cut
+
 1;
 

Modified: jifty/branches/trimclient/lib/Jifty/View/Declare/Helpers.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/View/Declare/Helpers.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/View/Declare/Helpers.pm	Fri Jun 15 07:23:21 2007
@@ -5,7 +5,7 @@
 use base qw/Template::Declare Exporter/;
 use Template::Declare::Tags;
 
-our @EXPORT = ( qw(form hyperlink tangent redirect new_action form_submit form_return  form_next_page page wrapper request get set render_param current_user render_action render_region), @Template::Declare::Tags::EXPORT);
+our @EXPORT = ( qw(form hyperlink tangent redirect new_action form_submit form_return form_next_page page content wrapper request get set render_param current_user render_action render_region), @Template::Declare::Tags::EXPORT);
 
 =head1 NAME
 
@@ -264,27 +264,44 @@
 
  template 'foo' => page {{ title is 'Foo' } ... };
 
+  or
+
+ template 'foo' => page { title => 'Foo' } content { ... };
+
 Renders an HTML page wrapped in L</wrapper>, after calling
 "/_elements/nav" and setting a content type. Generally, you shouldn't
 be using "/_elements/nav" but a Dispatcher rule instead.
 
+If C<page/content> calling convention is used, the return value of the
+first sub will be passed into wrapper as the second argument as a
+hashref, as well as the last argument for the content sub.
+
 =cut
 
-sub page (&) {
-    my $code = shift;
+sub page (&;$) {
+    unshift @_, undef if $#_ == 0;
+    my ( $meta, $code ) = @_;
     sub {
         my $self = shift;
         Jifty->handler->apache->content_type('text/html; charset=utf-8');
-        if ( my $wrapper = Jifty->app_class('View')->can('wrapper') ) {
-            $wrapper->(sub { $code->($self)});
-        } else {
-
-        wrapper(sub { $code->($self) });
+        my $wrapper = Jifty->app_class('View')->can('wrapper') || \&wrapper;
+        my @metadata = $meta ? $meta->() : ();
+        my $metadata = $#metadata == 0 ? $metadata[0] : {@metadata};
+        local *is::title = sub { warn "Can't use 'title is' when mixing mason and TD" };
+        $wrapper->( sub { $code->( $self, $metadata ) }, $metadata );
     }
-    };
 }
 
+=head2 content
 
+Helper function for page { ... } content { ... }
+
+=cut
+
+sub content (&;$) {
+    # XXX: Check for only 1 arg
+    return $_[0];
+}
 
 =head2 wrapper $coderef
 
@@ -293,7 +310,7 @@
 
 =cut
 
-sub wrapper ($) {
+sub wrapper {
     my $app_class = get_current_attr('PageClass') || 'View::Page';
     delete $Template::Declare::Tags::ATTRIBUTES{ 'PageClass' };
 

Modified: jifty/branches/trimclient/lib/Jifty/View/Mason/Handler.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/View/Mason/Handler.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/View/Mason/Handler.pm	Fri Jun 15 07:23:21 2007
@@ -183,13 +183,13 @@
 }
 
 sub handle_comp {
-    my ($self, $comp) = (shift, shift);
+    my ($self, $comp, $args) = @_;
 
     # Set up the global
     my $r = Jifty->handler->apache;
     $self->interp->set_global('$r', $r);
 
-    my %args = $self->request_args($r);
+    my %args = $args ? %$args : $self->request_args($r);
 
     my @result;
     if (wantarray) {

Modified: jifty/branches/trimclient/lib/Jifty/Web/Form.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Web/Form.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Web/Form.pm	Fri Jun 15 07:23:21 2007
@@ -217,7 +217,18 @@
 
 sub submit {
     my $self = shift;
-    my $button = Jifty::Web::Form::Clickable->new(submit => undef, _form => $self, @_)->generate;
+    my %args = (submit => undef,
+                _form => $self,
+                @_);
+
+    my @submit = ref($args{'submit'}) eq 'ARRAY' ? @{$args{'submit'}} : $args{'submit'};
+    if ($self->actions->{'next_page'} && $submit[0] && ! grep {$_->moniker eq 'next_page' } @submit)  {
+        push @submit, $self->actions->{'next_page'};
+        $args{'submit'} = \@submit;
+    }
+
+
+    my $button = Jifty::Web::Form::Clickable->new(%args)->generate;
     Jifty->web->out(qq{<div class="submit_button">});
     $button->render_widget;
     Jifty->web->out(qq{</div>});

Modified: jifty/branches/trimclient/lib/Jifty/Web/Form/Element.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Web/Form/Element.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Web/Form/Element.pm	Fri Jun 15 07:23:21 2007
@@ -326,6 +326,7 @@
         if (@fragments or (!$actions || %$actions)) {
 
             my $update = Jifty->web->escape("update( ". Jifty::JSON::objToJson( {actions => $actions, fragments => \@fragments, continuation => $self->continuation }, {singlequote => 1}) .", this );");
+            $string .= 'if(event.ctrlKey||event.metaKey||event.altKey||event.shiftKey) return true; ';
             $string .= $self->javascript_preempt ? "return $update" : "$update; return true;";
         }
         if ($confirm) {

Modified: jifty/branches/trimclient/lib/Jifty/Web/PageRegion.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/Web/PageRegion.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/Web/PageRegion.pm	Fri Jun 15 07:23:21 2007
@@ -215,7 +215,7 @@
             $self->argument($2 => $value);
         }
         if ($key =~ /^region-(.*)$/ and $1 eq $self->qualified_name and $value ne $self->default_path) {
-            $self->path($value);
+            $self->path(URI::Escape::uri_unescape($value));
         }
 
         # We should always inherit the state variables from the uplevel request.

Modified: jifty/branches/trimclient/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/trimclient/share/web/static/js/jifty.js	(original)
+++ jifty/branches/trimclient/share/web/static/js/jifty.js	Fri Jun 15 07:23:21 2007
@@ -713,9 +713,10 @@
 	    }
 	    // We need to give the browser some "settle" time before
 	    // we eval scripts in the body
-	    YAHOO.util.Event.onAvailable(element.id, function() {
-		    (function() { this.evalScripts() }).bind(textContent)();
-		    Behaviour.apply(element) });
+        YAHOO.util.Event.onAvailable(element.id, function() {
+            (function() { this.evalScripts() }).bind(textContent)();
+        });
+        Behaviour.apply(element);
 	}
     }
     dom_fragment.setArgs(new_dom_args);

Modified: jifty/branches/trimclient/share/web/templates/__jifty/webservices/xml
==============================================================================
--- jifty/branches/trimclient/share/web/templates/__jifty/webservices/xml	(original)
+++ jifty/branches/trimclient/share/web/templates/__jifty/webservices/xml	Fri Jun 15 07:23:21 2007
@@ -35,7 +35,7 @@
 
         $new ||= Jifty::Web::PageRegion->new(
             name           => $f->name,
-            path           => $f->path,
+            path           => URI::Escape::uri_unescape($f->path),
             region_wrapper => $f->wrapper,
             parent         => Jifty->web->current_region,
             defaults       => \%defaults,

Modified: jifty/branches/trimclient/t/TestApp/lib/TestApp/View.pm
==============================================================================
--- jifty/branches/trimclient/t/TestApp/lib/TestApp/View.pm	(original)
+++ jifty/branches/trimclient/t/TestApp/lib/TestApp/View.pm	Fri Jun 15 07:23:21 2007
@@ -44,8 +44,8 @@
 
 require TestApp::View::base;
 require TestApp::View::instance;
-import_templates TestApp::View::base under '/base';
-import_templates TestApp::View::instance under '/instance';
+alias TestApp::View::base under '/base';
+alias TestApp::View::instance under '/instance';
 
 use Jifty::View::Declare::CRUD;
 

Modified: jifty/branches/trimclient/t/TestApp/lib/TestApp/View/base.pm
==============================================================================
--- jifty/branches/trimclient/t/TestApp/lib/TestApp/View/base.pm	(original)
+++ jifty/branches/trimclient/t/TestApp/lib/TestApp/View/base.pm	Fri Jun 15 07:23:21 2007
@@ -1,11 +1,13 @@
 package TestApp::View::base;
 use Jifty::View::Declare -base;
 
+sub base_path { '/base' }
+
 template 'list_ht' => sub {
     my $self = shift;
     outs("/base/list=$self");
     for (0..1) {
-	$self->has_template('view')->();
+	$self->resolve_template('view')->();
     }
 };
 
@@ -13,7 +15,7 @@
     my $self = shift;
     outs("/base/list=$self");
     for (0..1) {
-	show('view');
+	show($self->base_path.'/view');
     }
 };
 
@@ -21,7 +23,7 @@
     my $self = shift;
     outs("/base/list=$self");
     for (0..1) {
-	render_region('view-'.$_, path => 'view');
+	render_region('view-'.$_, path => $self->base_path.'/view');
     }
 };
 

Modified: jifty/branches/trimclient/t/TestApp/lib/TestApp/View/instance.pm
==============================================================================
--- jifty/branches/trimclient/t/TestApp/lib/TestApp/View/instance.pm	(original)
+++ jifty/branches/trimclient/t/TestApp/lib/TestApp/View/instance.pm	Fri Jun 15 07:23:21 2007
@@ -2,6 +2,8 @@
 use Jifty::View::Declare -base;
 use base 'TestApp::View::base';
 
+sub base_path { '/instance' }
+
 template 'myview' => sub {
     
 };

Modified: jifty/branches/trimclient/t/TestApp/t/15-template-subclass.t
==============================================================================
--- jifty/branches/trimclient/t/TestApp/t/15-template-subclass.t	(original)
+++ jifty/branches/trimclient/t/TestApp/t/15-template-subclass.t	Fri Jun 15 07:23:21 2007
@@ -72,14 +72,8 @@
 my $mech = Jifty::Test::WWW::Mechanize->new;
 foreach my $test (@tests) {
     $mech->get_ok( $URL . $test->{url}, "get '$URL: /jifty/jifty/trunk/t/TestApp/t/15-template-subclass.t $test->{url}'" );
-    TODO: { 
-
-    local $TODO = " Template subclassing needs some love";
-    ok($mech->content =~ qr{$test->{text}}, "found the test content");
-    # $mech->content_contains breaks on multiline content
-    #$mech->content_contains( $test->{text}, "found content '$test->{text}'" );
-    };
 
+    $mech->content_contains( $test->{text}, "found content '$test->{text}'" );
 }
 
 1;


More information about the Jifty-commit mailing list