[gantry] r1491 committed - - Fixed sample included with gantry so livesearch works.

6 views
Skip to first unread message

codesite...@google.com

unread,
Jun 16, 2011, 11:24:44 AM6/16/11
to gan...@googlegroups.com
Revision: 1491
Author: net.angelus
Date: Thu Jun 16 08:23:55 2011
Log: - Fixed sample included with gantry so livesearch works.
http://code.google.com/p/gantry/source/detail?r=1491

Added:
/trunk/samples/MANIFEST
/trunk/samples/MANIFEST.bak
/trunk/samples/html/js/gantry.js
/trunk/samples/t/04_manifest.t
/trunk/samples/t/05_config.t
Modified:
/trunk/Changes
/trunk/lib/Gantry.pm
/trunk/samples/app.cgi
/trunk/samples/app.server
/trunk/samples/docs/Gantry-Samples.gantry.conf
/trunk/samples/docs/httpd.conf
/trunk/samples/docs/samples.bigtop
/trunk/samples/docs/schema.postgres
/trunk/samples/html/templates/genwrapper.tt
/trunk/samples/lib/Gantry/GENSamples.pm
/trunk/samples/lib/Gantry/Samples/GEN/TablePermCRUD.pm
/trunk/samples/lib/Gantry/Samples/GEN/TablePermissions.pm
/trunk/samples/lib/Gantry/Samples/GEN/User/Group.pm
/trunk/samples/lib/Gantry/Samples/GEN/User.pm
/trunk/samples/lib/Gantry/Samples/GENModel.pm
/trunk/samples/lib/Gantry/Samples/Model/GEN/item.pm
/trunk/samples/lib/Gantry/Samples/Model/GEN/user.pm
/trunk/samples/lib/Gantry/Samples/Model/GEN/user_user_group.pm
/trunk/samples/t/10_run.t

=======================================
--- /dev/null
+++ /trunk/samples/MANIFEST Thu Jun 16 08:23:55 2011
@@ -0,0 +1,60 @@
+app.cgi
+app.db
+app.htpasswd
+app.server
+bin/soapclient
+Build.PL
+Changes
+docs/app.gantry.conf
+docs/Gantry-Samples.gantry.conf
+docs/httpd.conf
+docs/samples.bigtop
+docs/schema.mysql
+docs/schema.postgres
+docs/schema.sqlite
+html/js/jquery.js
+html/templates/ajaxrequest.tt
+html/templates/authcookie.tt
+html/templates/authcookie_sqlite.tt
+html/templates/fileupload.tt
+html/templates/genwrapper.tt
+lib/Gantry/GENSamples.pm
+lib/Gantry/Samples.pm
+lib/Gantry/Samples/AjaxRequest.pm
+lib/Gantry/Samples/AuthCookie.pm
+lib/Gantry/Samples/AuthCookie/SQLite.pm
+lib/Gantry/Samples/AuthCookie/SQLite/Closed.pm
+lib/Gantry/Samples/FileUpload.pm
+lib/Gantry/Samples/GEN/AuthCookie/SQLite.pm
+lib/Gantry/Samples/GEN/TablePermCRUD.pm
+lib/Gantry/Samples/GEN/TablePermissions.pm
+lib/Gantry/Samples/GEN/User.pm
+lib/Gantry/Samples/GEN/User/Group.pm
+lib/Gantry/Samples/GENModel.pm
+lib/Gantry/Samples/Model.pm
+lib/Gantry/Samples/Model/auth_group.pm
+lib/Gantry/Samples/Model/GEN/auth_group.pm
+lib/Gantry/Samples/Model/GEN/item.pm
+lib/Gantry/Samples/Model/GEN/user.pm
+lib/Gantry/Samples/Model/GEN/user_group.pm
+lib/Gantry/Samples/Model/GEN/user_user_group.pm
+lib/Gantry/Samples/Model/item.pm
+lib/Gantry/Samples/Model/user.pm
+lib/Gantry/Samples/Model/user_auth_group.pm
+lib/Gantry/Samples/Model/user_group.pm
+lib/Gantry/Samples/Model/user_user_group.pm
+lib/Gantry/Samples/SOAP.pm
+lib/Gantry/Samples/TablePermCRUD.pm
+lib/Gantry/Samples/TablePermissions.pm
+lib/Gantry/Samples/User.pm
+lib/Gantry/Samples/User/Group.pm
+MANIFEST This list of files
+MANIFEST.SKIP
+README
+soap.server
+t/01_use.t
+t/02_pod.t
+t/03_podcover.t
+t/04_manifest.t
+t/05_config.t
+t/10_run.t
=======================================
--- /dev/null
+++ /trunk/samples/MANIFEST.bak Thu Jun 16 08:23:55 2011
@@ -0,0 +1,58 @@
+app.cgi
+app.db
+app.htpasswd
+app.server
+bin/soapclient
+Build.PL
+Changes
+docs/app.gantry.conf
+docs/Gantry-Samples.gantry.conf
+docs/httpd.conf
+docs/samples.bigtop
+docs/schema.mysql
+docs/schema.postgres
+docs/schema.sqlite
+html/js/jquery.js
+html/templates/ajaxrequest.tt
+html/templates/authcookie.tt
+html/templates/authcookie_sqlite.tt
+html/templates/fileupload.tt
+html/templates/genwrapper.tt
+lib/Gantry/GENSamples.pm
+lib/Gantry/Samples.pm
+lib/Gantry/Samples/AjaxRequest.pm
+lib/Gantry/Samples/AuthCookie.pm
+lib/Gantry/Samples/AuthCookie/SQLite.pm
+lib/Gantry/Samples/AuthCookie/SQLite/Closed.pm
+lib/Gantry/Samples/FileUpload.pm
+lib/Gantry/Samples/GEN/AuthCookie/SQLite.pm
+lib/Gantry/Samples/GEN/TablePermCRUD.pm
+lib/Gantry/Samples/GEN/TablePermissions.pm
+lib/Gantry/Samples/GEN/User.pm
+lib/Gantry/Samples/GEN/User/Group.pm
+lib/Gantry/Samples/GENModel.pm
+lib/Gantry/Samples/Model.pm
+lib/Gantry/Samples/Model/auth_group.pm
+lib/Gantry/Samples/Model/GEN/auth_group.pm
+lib/Gantry/Samples/Model/GEN/item.pm
+lib/Gantry/Samples/Model/GEN/user.pm
+lib/Gantry/Samples/Model/GEN/user_group.pm
+lib/Gantry/Samples/Model/GEN/user_user_group.pm
+lib/Gantry/Samples/Model/item.pm
+lib/Gantry/Samples/Model/user.pm
+lib/Gantry/Samples/Model/user_auth_group.pm
+lib/Gantry/Samples/Model/user_group.pm
+lib/Gantry/Samples/Model/user_user_group.pm
+lib/Gantry/Samples/SOAP.pm
+lib/Gantry/Samples/TablePermCRUD.pm
+lib/Gantry/Samples/TablePermissions.pm
+lib/Gantry/Samples/User.pm
+lib/Gantry/Samples/User/Group.pm
+MANIFEST This list of files
+MANIFEST.SKIP
+README
+soap.server
+t/01_use.t
+t/02_pod.t
+t/03_podcover.t
+t/10_run.t
=======================================
--- /dev/null
+++ /trunk/samples/html/js/gantry.js Thu Jun 16 08:23:55 2011
@@ -0,0 +1,133 @@
+function ajax_action ( url, cb_output ) {
+
+ var html = $.ajax({
+ url: url,
+ async: false,
+ success: function(msg){
+ if ( cb_output ) {
+ $( cb_output ).innerHTML = msg;
+ }
+ }
+ }).responseText;
+
+}
+
+function livesearch ( url ) {
+
+ if ( ! url ) {
+ url = "[% self.location %]";
+ }
+
+ $('tr.livedata').css({ display: 'none' });
+
+ if ( ! $('#livesearch').val() || $('#livesearch').val() == '' ) {
+ return
+ }
+
+ var html = $.ajax({
+ url: ( "?search=" + $('#livesearch').val() + "&json=1" ),
+ async: false,
+ success: function(msg){
+ $('tr.livedata').empty();
+ }
+ }).responseText;
+
+ $('.livedata').empty();
+
+ var json;
+ if ( html ) {
+ json = eval( '(' + html + ')' );
+ }
+ if ( ! json.rows ) { return true; }
+
+ var livehtml = '';
+
+ for ( var r=0; r < json.rows.length; ++r ) {
+ //$.each( json.rows, function( i, item ){
+ var item = json.rows[r];
+ var row = '';
+
+ for ( var j=0; j < item.data.length; ++j ) {
+ var val = '';
+ val = item.data[j];
+
+ row += sprintf( '<td class="livedata">%s</td>', ( val ?
val : '' ) );
+ }
+
+ row += "<td class='rdta'>";
+
+ var links = [];
+ for ( var k=0; k < item.options.length; ++k ) {
+ var link = '';
+ if ( item.options[k] ) {
+ links.push(
+ sprintf( '<a href="%s">%s</a>',
+ item.options[k].link,
+ item.options[k].text
+ )
+ );
+ }
+ }
+
+ var edit_links = links.join( ' | ' );
+ row += edit_links ? '[ ' + edit_links + ' ]' : '';
+ row += "</td>";
+
+ $( 'table#results' ).prepend(
+ "<tr class='livedata'>" + row + "</tr>"
+ );
+ }
+}
+
+function sprintf() {
+ if (!arguments || arguments.length < 1 || !RegExp)
+ {
+ return;
+ }
+ var str = arguments[0];
+ var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|
X)(.*)/;
+ var a = b = [], numSubstitutions = 0, numMatches = 0;
+ while (a = re.exec(str))
+ {
+ var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
+ var pPrecision = a[5], pType = a[6], rightPart = a[7];
+
+ //alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength,
pPrecision);
+
+ numMatches++;
+ if (pType == '%')
+ {
+ subst = '%';
+ }
+ else
+ {
+ numSubstitutions++;
+ if (numSubstitutions >= arguments.length)
+ {
+ alert('Error! Not enough function arguments (' + (arguments.length -
1) + ', excluding the string)\nfor the number of substitution parameters in
string (' + numSubstitutions + ' so far).');
+ }
+ var param = arguments[numSubstitutions];
+ var pad = '';
+ if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
+ else if (pPad) pad = pPad;
+ var justifyRight = true;
+ if (pJustify && pJustify === "-") justifyRight = false;
+ var minLength = -1;
+ if (pMinLength) minLength = parseInt(pMinLength);
+ var precision = -1;
+ if (pPrecision && pType == 'f') precision =
parseInt(pPrecision.substring(1));
+ var subst = param;
+ if (pType == 'b') subst = parseInt(param).toString(2);
+ else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
+ else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
+ else if (pType == 'u') subst = Math.abs(param);
+ else if (pType == 'f') subst = (precision > -1) ?
Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10,
precision): parseFloat(param);
+ else if (pType == 'o') subst = parseInt(param).toString(8);
+ else if (pType == 's') subst = param;
+ else if (pType == 'x') subst = ('' +
parseInt(param).toString(16)).toLowerCase();
+ else if (pType == 'X') subst = ('' +
parseInt(param).toString(16)).toUpperCase();
+ }
+ str = leftpart + subst + rightPart;
+ }
+ return str;
+}
=======================================
--- /dev/null
+++ /trunk/samples/t/04_manifest.t Thu Jun 16 08:23:55 2011
@@ -0,0 +1,9 @@
+use Test::More;
+
+eval 'use Test::CheckManifest;';
+
+if ($@) {
+ plan skip_all => 'Test::CheckManifest required to test MANIFEST';
+}
+
+ok_manifest();
=======================================
--- /dev/null
+++ /trunk/samples/t/05_config.t Thu Jun 16 08:23:55 2011
@@ -0,0 +1,82 @@
+use Test::More;
+use Gantry::Conf ();
+
+plan skip_all => 'set TEST_CONFIG to enable this test' unless
$ENV{TEST_CONFIG};
+
+my @avail_configs = qw/base/;
+my $instances = {
+ base => 'samples',
+};
+my $configs = {
+ samples => [
+ qw/
+ template_wrapper
+ auth_user_password
+ doc_root
+ app_name
+ doc_rootp
+ auth_group_join_table
+ auth_user_field
+ auth_group_table
+ show_dev_navigation
+ root
+ dbconn
+ auth_table
+ /
+ ],
+};
+
+diag( "" );
+diag( "which config would you like to test?" );
+diag( "0. samples" );
+diag( "1. None" );
+my $p = <STDIN>;
+chomp( $p );
+
+if ( $p >= 1) {
+ plan skip_all => "config test";
+}
+else {
+ my $instance = $instances->{$avail_configs[$p]};
+ my $gconf;
+
+ # Set number of tests to number of config items to test
+ # plus 1 for the gantry config test.
+ plan tests => scalar( @{$configs->{$instance}} ) + 1;
+
+ diag( "" );
+ diag( "Location of gantry config file [/etc/gantry.conf]: ");
+ my $config_file = <STDIN>;
+ chomp( $config_file );
+
+ unless ($config_file) {
+ $config_file = File::Spec->catfile( qw/ \/ etc gantry.conf / );
+ }
+
+ eval {
+ $gconf = Gantry::Conf->retrieve(
+ {
+ instance => "$instance",
+ config_file => "$config_file",
+ }
+ );
+ };
+
+ ok(! $@, 'loaded gantry config');
+
+ # Warn about any items found in the gantry config that are missing
+ # from the app.
+ foreach my $item (@{$configs->{$instance}}) {
+ is( exists $gconf->{$item}, 1, "$item found in config" );
+ delete $gconf->{$item};
+ }
+
+ if (scalar(keys %$gconf)) {
+ diag( "" );
+ diag( 'The following config items were found but are not present
in the app config' );
+ }
+
+ foreach my $item (keys %$gconf) {
+ diag( $item );
+ }
+}
=======================================
--- /trunk/Changes Mon Apr 4 09:19:36 2011
+++ /trunk/Changes Thu Jun 16 08:23:55 2011
@@ -1,5 +1,8 @@
This file documents the revision history for Perl extension Gantry

+3.80 Thu Jun 16 10:22:00 CDT 2011
+ - Fixed sample included with gantry so livesearch works.
+
3.79 Wed Mar 31 15:22:00 CDT 2011
- Added javascript functions to enable display of gantry forms/results
via ajax.
=======================================
--- /trunk/lib/Gantry.pm Mon Apr 4 09:19:36 2011
+++ /trunk/lib/Gantry.pm Thu Jun 16 08:23:55 2011
@@ -11,7 +11,7 @@
############################################################
# Variables #
############################################################
-our $VERSION = '3.79';
+our $VERSION = '3.80';
our $DEFAULT_PLUGIN_TEMPLATE = 'Gantry::Template::Default';
our $DEFAULT_STATE_MACHINE = 'Gantry::State::Default';
our $CONF;
=======================================
--- /trunk/samples/app.cgi Thu Apr 26 10:46:04 2007
+++ /trunk/samples/app.cgi Thu Jun 16 08:23:55 2011
@@ -9,7 +9,7 @@
-Engine=CGI
-TemplateEngine=TT
-PluginNamespace=Gantry::Samples
- AuthCookie
+ AuthCookie Static
};

use Gantry::Engine::CGI;
=======================================
--- /trunk/samples/app.server Tue Jul 1 20:54:24 2008
+++ /trunk/samples/app.server Thu Jun 16 08:23:55 2011
@@ -8,10 +8,9 @@
use Gantry::Samples qw{
-Engine=CGI
-TemplateEngine=TT
- -StateMachine=Simple
Static
-PluginNamespace=Gantry::Samples
- AuthCookie
+ AuthCookie Static
};

use Getopt::Long;
@@ -57,7 +56,7 @@
}

$config->{ dbuser } = $dbuser if $dbuser;
-$config->{ dbpass } = $dbuser if $dbpass;
+$config->{ dbpass } = $dbpass if $dbpass;

my $cgi = Gantry::Engine::CGI->new( {
config => $config,
=======================================
--- /trunk/samples/docs/Gantry-Samples.gantry.conf Tue May 22 12:02:39 2007
+++ /trunk/samples/docs/Gantry-Samples.gantry.conf Thu Jun 16 08:23:55 2011
@@ -1,6 +1,6 @@
<instance samples>
dbconn dbi:SQLite:dbname=app.db
- template_wrapper gantry_wrapper.tt
+ template_wrapper genwrapper.tt
doc_rootp /static
doc_root html
auth_user_field username
=======================================
--- /trunk/samples/docs/httpd.conf Thu Apr 26 10:46:04 2007
+++ /trunk/samples/docs/httpd.conf Thu Jun 16 08:23:55 2011
@@ -3,10 +3,10 @@

use lib qw( ../lib );
use Gantry::Samples qw{
+ -PluginNamespace=Gantry::Samples
-Engine=MP20
-TemplateEngine=TT
- -PluginNamespace=Gantry::Samples
- AuthCookie
+ AuthCookie Static
};
use Gantry::Samples::FileUpload;
use Gantry::Samples::AjaxRequest;
=======================================
--- /trunk/samples/docs/samples.bigtop Thu Apr 26 11:58:39 2007
+++ /trunk/samples/docs/samples.bigtop Thu Jun 16 08:23:55 2011
@@ -1,7 +1,7 @@
config {
engine MP20;
template_engine TT;
- plugins AuthCookie;
+ plugins `AuthCookie Static`;
Conf Gantry { conffile `docs/app.gantry.conf`; instance samples; }
HttpdConf Gantry { gantry_conf 1; }
Init Std { }
@@ -16,7 +16,7 @@
app Gantry::Samples {
config {
dbconn `dbi:SQLite:dbname=app.db` => no_accessor;
- template_wrapper `gantry_wrapper.tt` => no_accessor;
+ template_wrapper `genwrapper.tt` => no_accessor;
doc_rootp `/static` => no_accessor;
doc_root html => no_accessor;
auth_user_field username;
=======================================
--- /trunk/samples/docs/schema.postgres Fri Apr 6 12:40:32 2007
+++ /trunk/samples/docs/schema.postgres Thu Jun 16 08:23:55 2011
@@ -29,8 +29,8 @@

CREATE TABLE user_user_group (
id SERIAL PRIMARY KEY,
- user int4,
- user_group int4
+ user int4 REFERENCES user(id),
+ user_group int4 REFERENCES user_group(id)
);
CREATE TABLE item (
id SERIAL PRIMARY KEY,
=======================================
--- /trunk/samples/html/templates/genwrapper.tt Tue Mar 27 09:13:39 2007
+++ /trunk/samples/html/templates/genwrapper.tt Thu Jun 16 08:23:55 2011
@@ -10,6 +10,8 @@

<script type="text/javascript" src="[% self.doc_rootp %]/js/jquery.js">
</script>
+ <script type="text/javascript" src="[% self.doc_rootp %]/js/gantry.js">
+ </script>

<!-- include a style sheet if you like:
<link rel="stylesheet" type="text/css" media="screen"
@@ -35,10 +37,10 @@
#footer #site_links { visibility: visible;}
fieldset { background: #e9e9e9; border: 1px solid #c7c7c7;}
legend { padding: 0 10px 0 10px; border: 1px solid #c7c7c7;
background: #fff;}
- #content .box table { padding: 0; margin: 0; background: #eee; width:
100%;}
- #content .box table td { padding: 0 4px 0 4px; margin: 0; border: 0;}
- #content .box table tr { background: #b9c5b4;}
- #content .box table tr + tr { background: #fff;}
+ #content .results-box table { padding: 0; margin: 0; background: #eee;
width: 100%;}
+ #content .results-box table td { padding: 0 4px 0 4px; margin: 0;
border: 0;}
+ #content .results-box table tr.heading { background: #b9c5b4;}
+ #content .results-box table tr { background: #fff;}
#footer { font: normal 12px/20px sans-serif; text-align: center;
padding: 10px; margin: 0px auto ; width: 740px;}
#float_right { float: right;}
#float_left { float: left;}
=======================================
--- /trunk/samples/lib/Gantry/GENSamples.pm Tue May 22 12:02:39 2007
+++ /trunk/samples/lib/Gantry/GENSamples.pm Thu Jun 16 08:23:55 2011
@@ -186,6 +186,8 @@

=over 4

+=item schema_base_class
+
=item namespace

=item init
@@ -219,11 +221,11 @@

=head1 AUTHOR

-Phil Crow, E<lt>phil@localdomainE<gt>
+John Weigel, E<lt>jwe...@apple.comE<gt>

=head1 COPYRIGHT AND LICENSE

-Copyright (C) 2007 Phil Crow
+Copyright (C) 2011 John Weigel

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.6 or,
=======================================
--- /trunk/samples/lib/Gantry/Samples/GEN/TablePermCRUD.pm Tue May 22
12:02:39 2007
+++ /trunk/samples/lib/Gantry/Samples/GEN/TablePermCRUD.pm Thu Jun 16
08:23:55 2011
@@ -60,17 +60,17 @@
],
};

- my %param = $self->get_param_hash;
+ my $params = $self->params;

my $search = {};
- if ( $param{ search } ) {
+ if ( $params->{ search } ) {
my $form = $self->form();

my @searches;
foreach my $field ( @{ $form->{ fields } } ) {
if ( $field->{ searchable } ) {
push( @searches,
- ( $field->{ name } => { 'like', "%$param{ search }%"
} )
+ ( $field->{ name } => { 'like', "%$params->{ search
}%" } )
);
}
}
@@ -112,8 +112,8 @@
my $schema = $self->get_schema();
my @rows = $ITEM->get_listing(
{
- schema => $schema,
- where => $search,
+ schema => $schema,
+ where => $search,
}
);

@@ -139,7 +139,7 @@
);
}

- if ( $param{ json } ) {
+ if ( $params->{ json } ) {
$self->template_disable( 1 );

my $obj = {
@@ -148,7 +148,7 @@
rows => $retval->{ rows },
};

- my $json = objToJson( $obj, { skipinvalid => 1 } );
+ my $json = to_json( $obj, { allow_blessed => 1 } );
return( $json );
}

@@ -162,7 +162,9 @@
my ( $self, $data ) = @_;

my $selections = $ITEM->get_form_selections(
- { schema => $self->get_schema() }
+ {
+ schema => $self->get_schema(),
+ }
);

return {
=======================================
--- /trunk/samples/lib/Gantry/Samples/GEN/TablePermissions.pm Tue May 22
12:02:39 2007
+++ /trunk/samples/lib/Gantry/Samples/GEN/TablePermissions.pm Thu Jun 16
08:23:55 2011
@@ -60,17 +60,17 @@
],
};

- my %param = $self->get_param_hash;
+ my $params = $self->params;

my $search = {};
- if ( $param{ search } ) {
+ if ( $params->{ search } ) {
my $form = $self->form();

my @searches;
foreach my $field ( @{ $form->{ fields } } ) {
if ( $field->{ searchable } ) {
push( @searches,
- ( $field->{ name } => { 'like', "%$param{ search }%"
} )
+ ( $field->{ name } => { 'like', "%$params->{ search
}%" } )
);
}
}
@@ -112,8 +112,8 @@
my $schema = $self->get_schema();
my @rows = $ITEM->get_listing(
{
- schema => $schema,
- where => $search,
+ schema => $schema,
+ where => $search,
}
);

@@ -139,7 +139,7 @@
);
}

- if ( $param{ json } ) {
+ if ( $params->{ json } ) {
$self->template_disable( 1 );

my $obj = {
@@ -148,7 +148,7 @@
rows => $retval->{ rows },
};

- my $json = objToJson( $obj, { skipinvalid => 1 } );
+ my $json = to_json( $obj, { allow_blessed => 1 } );
return( $json );
}

@@ -162,7 +162,9 @@
my ( $self, $row ) = @_;

my $selections = $ITEM->get_form_selections(
- { schema => $self->get_schema() }
+ {
+ schema => $self->get_schema(),
+ }
);

return {
=======================================
--- /trunk/samples/lib/Gantry/Samples/GEN/User/Group.pm Thu Apr 26 10:46:04
2007
+++ /trunk/samples/lib/Gantry/Samples/GEN/User/Group.pm Thu Jun 16 08:23:55
2011
@@ -43,17 +43,17 @@
],
};

- my %param = $self->get_param_hash;
+ my $params = $self->params;

my $search = {};
- if ( $param{ search } ) {
+ if ( $params->{ search } ) {
my $form = $self->form();

my @searches;
foreach my $field ( @{ $form->{ fields } } ) {
if ( $field->{ searchable } ) {
push( @searches,
- ( $field->{ name } => { 'like', "%$param{ search }%"
} )
+ ( $field->{ name } => { 'like', "%$params->{ search
}%" } )
);
}
}
@@ -91,8 +91,8 @@
my $schema = $self->get_schema();
my @rows = $USER_GROUP->get_listing(
{
- schema => $schema,
- where => $search,
+ schema => $schema,
+ where => $search,
}
);

@@ -114,7 +114,7 @@
);
}

- if ( $param{ json } ) {
+ if ( $params->{ json } ) {
$self->template_disable( 1 );

my $obj = {
@@ -123,7 +123,7 @@
rows => $retval->{ rows },
};

- my $json = objToJson( $obj, { skipinvalid => 1 } );
+ my $json = to_json( $obj, { allow_blessed => 1 } );
return( $json );
}

@@ -137,7 +137,9 @@
my ( $self, $data ) = @_;

my $selections = $USER_GROUP->get_form_selections(
- { schema => $self->get_schema() }
+ {
+ schema => $self->get_schema(),
+ }
);

return {
=======================================
--- /trunk/samples/lib/Gantry/Samples/GEN/User.pm Thu Apr 26 10:46:04 2007
+++ /trunk/samples/lib/Gantry/Samples/GEN/User.pm Thu Jun 16 08:23:55 2011
@@ -62,17 +62,17 @@

$retval->{ livesearch } = 1;

- my %param = $self->get_param_hash;
+ my $params = $self->params;

my $search = {};
- if ( $param{ search } ) {
+ if ( $params->{ search } ) {
my $form = $self->form();

my @searches;
foreach my $field ( @{ $form->{ fields } } ) {
if ( $field->{ searchable } ) {
push( @searches,
- ( $field->{ name } => { 'like', "%$param{ search }%"
} )
+ ( $field->{ name } => { 'like', "%$params->{ search
}%" } )
);
}
}
@@ -114,8 +114,9 @@
my $schema = $self->get_schema();
my @rows = $USER->get_listing(
{
- schema => $schema,
- where => $search, order_by => 'username',
+ schema => $schema,
+ where => $search,
+ order_by => 'username',
}
);

@@ -139,7 +140,7 @@
);
}

- if ( $param{ json } ) {
+ if ( $params->{ json } ) {
$self->template_disable( 1 );

my $obj = {
@@ -148,7 +149,7 @@
rows => $retval->{ rows },
};

- my $json = objToJson( $obj, { skipinvalid => 1 } );
+ my $json = to_json( $obj, { allow_blessed => 1 } );
return( $json );
}

@@ -162,7 +163,9 @@
my ( $self, $row ) = @_;

my $selections = $USER->get_form_selections(
- { schema => $self->get_schema() }
+ {
+ schema => $self->get_schema(),
+ }
);

return {
=======================================
--- /trunk/samples/lib/Gantry/Samples/GENModel.pm Fri Apr 6 12:40:32 2007
+++ /trunk/samples/lib/Gantry/Samples/GENModel.pm Thu Jun 16 08:23:55 2011
@@ -31,11 +31,11 @@

=head1 AUTHOR

-Phil Crow, E<lt>phil@localdomainE<gt>
+John Weigel, E<lt>jwe...@apple.comE<gt>

=head1 COPYRIGHT AND LICENSE

-Copyright (C) 2007 Phil Crow
+Copyright (C) 2011 John Weigel

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.6 or,
=======================================
--- /trunk/samples/lib/Gantry/Samples/Model/GEN/item.pm Fri Apr 6 12:40:32
2007
+++ /trunk/samples/lib/Gantry/Samples/Model/GEN/item.pm Thu Jun 16 08:23:55
2011
@@ -15,20 +15,11 @@
__PACKAGE__->belongs_to( user_id => 'Gantry::Samples::Model::user' );
__PACKAGE__->base_model( 'Gantry::Samples::Model' );

-sub get_foreign_display_fields {
- return [ qw( ) ];
-}
-
sub get_foreign_tables {
return qw(
Gantry::Samples::Model::user
);
}
-
-sub foreign_display {
- my $self = shift;
-
-}

sub table_name {
return 'item';
=======================================
--- /trunk/samples/lib/Gantry/Samples/Model/GEN/user.pm Fri Mar 30 11:36:33
2007
+++ /trunk/samples/lib/Gantry/Samples/Model/GEN/user.pm Thu Jun 16 08:23:55
2011
@@ -57,8 +57,9 @@

sub active_display {
my $self = shift;
- return $select_map_for{ active }{ $self->active }
- || $self->active;
+ my $active = defined $self->active ? $self->active : '';
+ return $select_map_for{ active }{ $active }
+ || $active;
}


=======================================
--- /trunk/samples/lib/Gantry/Samples/Model/GEN/user_user_group.pm Fri Mar
30 11:36:33 2007
+++ /trunk/samples/lib/Gantry/Samples/Model/GEN/user_user_group.pm Thu Jun
16 08:23:55 2011
@@ -15,19 +15,10 @@
__PACKAGE__->belongs_to( user => 'Gantry::Samples::Model::user' );
__PACKAGE__->belongs_to( user_group
=> 'Gantry::Samples::Model::user_group' );

-sub get_foreign_display_fields {
- return [ qw( ) ];
-}
-
sub get_foreign_tables {
return qw(
);
}
-
-sub foreign_display {
- my $self = shift;
-
-}

sub table_name {
return 'user_user_group';
=======================================
--- /trunk/samples/t/10_run.t Tue May 22 12:02:39 2007
+++ /trunk/samples/t/10_run.t Thu Jun 16 08:23:55 2011
@@ -7,7 +7,7 @@
-Engine=CGI
-TemplateEngine=TT
-PluginNamespace=Gantry::Samples
- AuthCookie
+ AuthCookie Static
};

use Gantry::Server;
@@ -29,7 +29,7 @@
doc_rootp => '/static',
root => 'html:html/templates:../root/moxie:../root',
show_dev_navigation => '1',
- template_wrapper => 'gantry_wrapper.tt',
+ template_wrapper => 'genwrapper.tt',
},
locations => {
'/' => 'Gantry::Samples',

Reply all
Reply to author
Forward
0 new messages