[Jifty-commit] r5253 - in jifty/branches/jquery: . lib/Jifty/Action lib/Jifty/Plugin/Chart lib/Jifty/Plugin/REST lib/Jifty/View/Declare lib/Jifty/Web lib/Jifty/Web/Form plugins/AuthzLDAP/lib/Jifty/Plugin share/web/static/js t t/TestApp-Plugin-Comments/lib/TestApp/Plugin/Comments
Jifty commits
jifty-commit at lists.jifty.org
Wed Apr 2 04:39:32 EDT 2008
Author: sartak
Date: Wed Apr 2 04:39:31 2008
New Revision: 5253
Modified:
jifty/branches/jquery/ (props changed)
jifty/branches/jquery/Makefile.PL
jifty/branches/jquery/lib/Jifty/Action/Record.pm
jifty/branches/jquery/lib/Jifty/Plugin/Chart/View.pm
jifty/branches/jquery/lib/Jifty/Plugin/REST/Dispatcher.pm
jifty/branches/jquery/lib/Jifty/View/Declare/Helpers.pm
jifty/branches/jquery/lib/Jifty/Web/Form/Element.pm
jifty/branches/jquery/lib/Jifty/Web/Form/Field.pm
jifty/branches/jquery/lib/Jifty/Web/PageRegion.pm
jifty/branches/jquery/plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP.pm
jifty/branches/jquery/plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Model/LDAPFilter.pm
jifty/branches/jquery/share/web/static/js/jifty.js
jifty/branches/jquery/t/06-forms.t
jifty/branches/jquery/t/TestApp-Plugin-Comments/lib/TestApp/Plugin/Comments/View.pm
Log:
r53141 at onn (orig r5241): sterling | 2008-03-27 12:49:09 -0400
r15585 at andrew-mac: andrew | 2008-03-09 21:19:43 -0500
Fix the comment view test page.
r53142 at onn (orig r5242): sterling | 2008-03-27 12:52:43 -0400
r15759 at andrew-mac: andrew | 2008-03-27 11:48:03 -0500
Updating the REST plugin to use PUTDATA added in CGI.pm 3.30.
r53143 at onn (orig r5243): alexmv | 2008-03-27 19:25:54 -0400
r28914 at kohr-ah: chmrr | 2008-03-27 19:25:42 -0400
* Lazy pageregions can't be done using behavior, as the JS which
defined the region might not have been run yet if it itself came
from a region load (for fragments responses, behavior is applied
immediately, scripts are run after some settle time).
Thus, put the region-updating code into the page directly.
r53144 at onn (orig r5244): sunnavy | 2008-03-27 21:38:42 -0400
tiny fix, sometimes options are undef
r53145 at onn (orig r5245): alexmv | 2008-03-29 00:58:35 -0400
r28924 at kohr-ah: chmrr | 2008-03-29 00:58:27 -0400
* When doing new region creation, make sure we get the new value of
the element that we're applying Behavior, etc, to.
r53243 at onn (orig r5246): yves | 2008-03-31 04:09:23 -0400
* bugfix for 'new' classloader
* chg name column filter by ldapfilter
r53254 at onn (orig r5247): alexmv | 2008-03-31 17:23:38 -0400
r28928 at kohr-ah: chmrr | 2008-03-31 17:19:39 -0400
* Don't output an empty label element
r53255 at onn (orig r5248): alexmv | 2008-03-31 17:23:45 -0400
r28929 at kohr-ah: chmrr | 2008-03-31 17:23:25 -0400
* Allow onclick, etc, handlers on arbitrary elements
r53256 at onn (orig r5249): alexmv | 2008-03-31 21:03:41 -0400
r28947 at kohr-ah: chmrr | 2008-03-31 21:03:36 -0400
* Update test for the new world order where empty labels are not output
r53259 at onn (orig r5252): alexmv | 2008-04-01 14:33:47 -0400
r28953 at kohr-ah: chmrr | 2008-04-01 14:33:38 -0400
* Skip ajax canonicalization on checkboxes
* Perltidy
Modified: jifty/branches/jquery/Makefile.PL
==============================================================================
--- jifty/branches/jquery/Makefile.PL (original)
+++ jifty/branches/jquery/Makefile.PL Wed Apr 2 04:39:31 2008
@@ -10,7 +10,7 @@
requires('Class::Data::Inheritable');
requires('Class::Trigger' => '0.12');
requires('Clone' => '0.27');
-requires('CGI' => '3.19');
+requires('CGI' => '3.30');
requires('CGI::Cookie::Splitter');
requires('Class::Inspector' => 1.20); # For File::ShareDir on Win32
requires('Crypt::CBC');
Modified: jifty/branches/jquery/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Action/Record.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Action/Record.pm Wed Apr 2 04:39:31 2008
@@ -357,28 +357,30 @@
sub _argument_canonicalizer {
- my $self = shift;
+ my $self = shift;
my $column = shift;
- my $field = $column->name;
+ my $field = $column->name;
my $method;
my $do_ajax = 0;
+ # Add a canonicalizer for the column if the record provides one
+ if ( $self->record->has_canonicalizer_for_column($field) ) {
+ $do_ajax = 1 unless lc($column->render_as) eq 'checkbox';
+ $method ||= sub {
+ my ( $self, $value ) = @_;
+ return $self->record->run_canonicalization_for_column(
+ column => $field,
+ value => $value
+ );
+ };
+ }
- # Add a canonicalizer for the column if the record provides one
- if ( $self->record->has_canonicalizer_for_column($field) ) {
- $do_ajax = 1;
- $method ||= sub {
- my ( $self, $value ) = @_;
- return $self->record->run_canonicalization_for_column(column => $field, value => $value);
- };
- }
-
- # Otherwise, if it's a date, we have a built-in canonicalizer for that
- elsif ( lc($column->render_as) eq 'date') {
- $do_ajax = 1;
- }
- return ($method, $do_ajax);
+ # Otherwise, if it's a date, we have a built-in canonicalizer for that
+ elsif ( lc( $column->render_as ) eq 'date' ) {
+ $do_ajax = 1;
}
+ return ( $method, $do_ajax );
+}
sub _argument_autocompleter {
my $self = shift;
Modified: jifty/branches/jquery/lib/Jifty/Plugin/Chart/View.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Plugin/Chart/View.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Plugin/Chart/View.pm Wed Apr 2 04:39:31 2008
@@ -102,7 +102,7 @@
axis_ticks => { major_color => '808080' },
legend_label => { size => '11' },
chart_value => { position => 'cursor', size => '11', color => '666666' },
- %{ $args->{options} },
+ %{ $args->{options} || {} },
chart_data => {
row => [
{
Modified: jifty/branches/jquery/lib/Jifty/Plugin/REST/Dispatcher.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Plugin/REST/Dispatcher.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Plugin/REST/Dispatcher.pm Wed Apr 2 04:39:31 2008
@@ -737,19 +737,15 @@
if defined $rec->id;
}
- # CGI.pm doesn't handle form encoded data in PUT requests (in fact,
- # it doesn't really handle PUT requests properly at all), so we have
- # to read the request body ourselves and have CGI.pm parse it
+ # CGI.pm doesn't handle form encoded data in PUT requests, so we have
+ # to read the request body from PUTDATA and have CGI.pm parse it
if ( $ENV{'REQUEST_METHOD'} eq 'PUT'
and ( $ENV{'CONTENT_TYPE'} =~ m|^application/x-www-form-urlencoded$|
or $ENV{'CONTENT_TYPE'} =~ m|^multipart/form-data$| ) )
{
my $cgi = Jifty->handler->cgi;
my $length = defined $ENV{'CONTENT_LENGTH'} ? $ENV{'CONTENT_LENGTH'} : 0;
- my $data;
-
- $cgi->read_from_client( \$data, $length, 0 )
- if $length > 0;
+ my $data = $cgi->param('PUTDATA');
if ( defined $data ) {
my @params = $cgi->all_parameters;
Modified: jifty/branches/jquery/lib/Jifty/View/Declare/Helpers.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/View/Declare/Helpers.pm (original)
+++ jifty/branches/jquery/lib/Jifty/View/Declare/Helpers.pm Wed Apr 2 04:39:31 2008
@@ -9,7 +9,7 @@
qw(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),
+ render_action render_region js_handlers),
@Template::Declare::Tags::EXPORT,
@Template::Declare::Tags::TagSubs, # Backward compatibility only
@Template::Declare::Tags::TAG_SUB_LIST,
@@ -367,7 +367,26 @@
}
}
+=head2 js_handlers
+Allows you to put javascript handlers, a la
+L<Jifty::Web::Form::Element>, onto arbitrary HTML elements:
+
+ div {
+ js_handlers {
+ onclick => { path => "/some/region/path" }
+ }
+ }
+
+=cut
+
+sub js_handlers(&;@) {
+ my $code = shift;
+ my $element = Jifty::Web::Form::Element->new({$code->()});
+ my %js = $element->javascript_attrs;
+ Template::Declare::Tags::append_attr($_ => $js{$_}) for keys %js;
+ return @_;
+}
1;
Modified: jifty/branches/jquery/lib/Jifty/Web/Form/Element.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Web/Form/Element.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Web/Form/Element.pm Wed Apr 2 04:39:31 2008
@@ -357,13 +357,28 @@
=head2 javascript
-Returns the javascript necessary to make the events happen.
+Returns the javascript necessary to make the events happen, as a
+string of HTML attributes.
=cut
+
sub javascript {
my $self = shift;
+ my %response = $self->javascript_attrs;
+ return join "", map {qq| $_="| . Jifty->web->escape($response{$_}).qq|"|} sort keys %response;
+}
+
+=head2 javascript_attrs
+
+Returns the javascript necessary to make the events happen, as a
+hash of attribute-name and value.
+
+=cut
+
+sub javascript_attrs {
+ my $self = shift;
- my $response = "";
+ my %response;
HANDLER:
for my $trigger ( $self->handlers ) {
@@ -471,7 +486,7 @@
my $string = join ";", (grep {not ref $_} (ref $value eq "ARRAY" ? @{$value} : ($value)));
if ( @fragments or ( !$actions || %$actions ) ) {
- my $update = Jifty->web->escape(
+ my $update =
"Jifty.update( "
. Jifty::JSON::objToJson(
{ actions => $actions,
@@ -480,8 +495,7 @@
continuation => $self->continuation
},
{ singlequote => 1 }
- ) . ", this );"
- );
+ ) . ", this );";
$string
.= 'if(event.ctrlKey||event.metaKey||event.altKey||event.shiftKey) return true; '
if ( $trigger eq 'onclick' );
@@ -490,14 +504,14 @@
: "$update; return true;";
}
if ($confirm) {
- $string = Jifty->web->escape("if(!confirm(" . Jifty::JSON::objToJson($confirm, {singlequote => 1}) . ")) { Event.stop(event); return false }") . $string;
+ $string = "if(!confirm(" . Jifty::JSON::objToJson($confirm, {singlequote => 1}) . ")) { Event.stop(event); return false }" . $string;
}
if ($beforeclick) {
- $string = Jifty->web->escape($beforeclick) . $string;
+ $string = $beforeclick . $string;
}
- $response .= qq| $trigger="$string"|;
+ $response{$trigger} = $string;
}
- return $response;
+ return %response;
}
=head2 javascript_preempt
Modified: jifty/branches/jquery/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Web/Form/Field.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Web/Form/Field.pm Wed Apr 2 04:39:31 2008
@@ -478,6 +478,7 @@
sub render_label {
my $self = shift;
+ return '' unless defined $self->label and length $self->label;
if ( $self->render_mode eq 'update' ) {
Jifty->web->out(
qq!<label class="label @{[$self->classes]}" for="@{[$self->element_id ]}">@{[_($self->label) ]}</label>\n!
Modified: jifty/branches/jquery/lib/Jifty/Web/PageRegion.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Web/PageRegion.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Web/PageRegion.pm Wed Apr 2 04:39:31 2008
@@ -290,9 +290,12 @@
. qq|);\n|
. qq|</script>|;
if ($self->lazy) {
- return $result . qq|<div id="region-| . $self->qualified_name . qq|" class="jifty-region-lazy"></div>|;
+ $result .= qq|<script type="text/javascript">|
+ . qq|Jifty.update( { 'fragments': [{'region': '|.$self->qualified_name.qq|', 'mode': 'Replace'}], 'actions': {}}, document.getElementById('region-|.$self->qualified_name.qq|'))|
+ . qq|</script>|;
}
$result .= qq|<div id="region-| . $self->qualified_name . qq|" class="jifty-region">|;
+ return $result . qq|</div>| if $self->lazy;
}
$self->render_as_subrequest(\$result, \%arguments);
Modified: jifty/branches/jquery/plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP.pm
==============================================================================
--- jifty/branches/jquery/plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP.pm (original)
+++ jifty/branches/jquery/plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP.pm Wed Apr 2 04:39:31 2008
@@ -63,6 +63,9 @@
package Jifty::Plugin::AuthzLDAP;
use base qw/Jifty::Plugin/;
+
+our $VERSION = '0.02';
+
use Net::LDAP;
use Cache::MemoryCache;
@@ -74,7 +77,7 @@
my %args = @_;
my $appname = Jifty->config->framework('ApplicationName');
- $LDAPFilterClass = "${appname}::Model::LDAPFilter";
+ $LDAPFilterClass = "Jifty::Plugin::AuthzLDAP::Model::LDAPFilter";
$params{'Hostname'} = $args{LDAPhost};
$params{'base'} = $args{LDAPbase};
@@ -158,7 +161,7 @@
# (?) allow use of writing filter in filtername
# TODO: filtername must be cleanned
# my $filter = ($record->filter)?$record->filter:$filtername;
- my $filter = $record->filter;
+ my $filter = $record->ldapfilter;
$user = $self->UID().'='.$user.','.$self->BASE();
Modified: jifty/branches/jquery/plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Model/LDAPFilter.pm
==============================================================================
--- jifty/branches/jquery/plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Model/LDAPFilter.pm (original)
+++ jifty/branches/jquery/plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Model/LDAPFilter.pm Wed Apr 2 04:39:31 2008
@@ -10,7 +10,7 @@
is distinct;
column
- filter => type is 'text',
+ ldapfilter => type is 'text',
label is 'Filter',
is mandatory;
Modified: jifty/branches/jquery/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/jquery/share/web/static/js/jifty.js (original)
+++ jifty/branches/jquery/share/web/static/js/jifty.js Wed Apr 2 04:39:31 2008
@@ -624,7 +624,7 @@
getForm: function (element) {
element = Jifty.$(element);
- if (element == null)
+ if (!element)
return null;
if (element.virtualform)
@@ -777,10 +777,6 @@
},
'.form_field .error, .form_field .warning, .form_field .canonicalization_note': function(e) {
if ( e.innerHTML == "" ) jQuery(e).hide();
- },
- '.jifty-region-lazy': function(e) {
- var region = e.getAttribute("id").replace(/^region-/,"");
- Jifty.update( { 'fragments': [{'region': region, 'mode': 'Replace'}]}, e);
}
});
@@ -1040,6 +1036,30 @@
}
Behaviour.apply(element);
}
+ new_dom_args.set(fragment_bit.getAttribute("name"), textContent);
+ },
+ content: function(fragment_bit) {
+ var textContent = '';
+ if (fragment_bit.textContent) {
+ textContent = fragment_bit.textContent;
+ } else if (fragment_bit.firstChild) {
+ textContent = fragment_bit.firstChild.nodeValue;
+ }
+
+ // Once we find it, do the insertion
+ if (f['mode'] && (f['mode'] != 'Replace')) {
+ var insertion = eval('Insertion.'+f['mode']);
+ new insertion(element, textContent.stripScripts());
+ element = document.getElementById('region-' + f['region']);
+ } else {
+ Element.update(element, textContent.stripScripts());
+ }
+ // 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);
}
);
dom_fragment.setArgs(new_dom_args);
Modified: jifty/branches/jquery/t/06-forms.t
==============================================================================
--- jifty/branches/jquery/t/06-forms.t (original)
+++ jifty/branches/jquery/t/06-forms.t Wed Apr 2 04:39:31 2008
@@ -104,13 +104,13 @@
is $out, qq{<span class="preamble text blah argument-agentz">}.
qq{preamble's here!</span>\n};
- # Test empty labels:
+ # Test empty labels are not output
$field->name('yichun');
$field->label('');
$field->class('');
$out = '';
$field->render_label;
- is $out, qq{<label class="label text argument-yichun" for="search_keys-32"></label>\n};
+ is $out, qq{};
# Test default labels:
$field->name('yichun');
Modified: jifty/branches/jquery/t/TestApp-Plugin-Comments/lib/TestApp/Plugin/Comments/View.pm
==============================================================================
--- jifty/branches/jquery/t/TestApp-Plugin-Comments/lib/TestApp/Plugin/Comments/View.pm (original)
+++ jifty/branches/jquery/t/TestApp-Plugin-Comments/lib/TestApp/Plugin/Comments/View.pm Wed Apr 2 04:39:31 2008
@@ -27,7 +27,7 @@
render_region
name => 'comments',
- path => '/comment/list',
+ path => '/__comment/list',
arguments => {
collapsed => 1,
parent_class => Jifty->app_class('Model', 'BlogPost'),
More information about the Jifty-commit
mailing list