[Jifty-commit] r3524 - in jifty/branches/trimclient: examples/Yada/B examples/Yada/lib/Yada share/web/static/js

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Jun 18 04:14:21 EDT 2007


Author: clkao
Date: Mon Jun 18 04:14:20 2007
New Revision: 3524

Modified:
   jifty/branches/trimclient/examples/Yada/B/Deparse.pm
   jifty/branches/trimclient/examples/Yada/lib/Yada/View.pm
   jifty/branches/trimclient/lib/Jifty/View/Declare/Compile.pm
   jifty/branches/trimclient/share/web/static/js/jifty.js

Log:
Make grep work.


Modified: jifty/branches/trimclient/examples/Yada/B/Deparse.pm
==============================================================================
--- jifty/branches/trimclient/examples/Yada/B/Deparse.pm	(original)
+++ jifty/branches/trimclient/examples/Yada/B/Deparse.pm	Mon Jun 18 04:14:20 2007
@@ -1126,7 +1126,7 @@
 	$expr =~ s/;\n?\z//;
 	push @exprs, $expr;
     }
-    if (!$root && $ops[-1]->name ne 'return') {
+    if ($ops[-1]->name ne 'return' && (!$root || $root->next->name eq 'grepwhile')) {
 	$exprs[-1] = "return ($exprs[-1])";
     }
     my $body = join(";\n", grep {length} @exprs);
@@ -3034,9 +3034,6 @@
     if (length $args) {
 	return $kid . "(" . $args . ")"; # parens mandatory
     } else {
-	warn "==> boo $kid";
-
-
 	return $kid.'()';
     }
 }

Modified: jifty/branches/trimclient/examples/Yada/lib/Yada/View.pm
==============================================================================
--- jifty/branches/trimclient/examples/Yada/lib/Yada/View.pm	(original)
+++ jifty/branches/trimclient/examples/Yada/lib/Yada/View.pm	Mon Jun 18 04:14:20 2007
@@ -59,11 +59,8 @@
     my $next = undef;
 #    with ( call => $next ),
     form {
-#	XXX: grep / focus not yet
-#	render_param( $action => 'name' , focus => 1);
-#	render_param( $action => $_ ) for ( grep {$_ ne 'name'} $action->argument_names );
-
-	render_param( $action => $_ ) for $action->argument_names;
+	render_param( $action => 'name' , focus => 1);
+	render_param( $action => $_ ) for ( grep {$_ ne 'name'} $action->argument_names );
 
 	form_return( label => _('Sign up'), submit => $action );
     }

Modified: jifty/branches/trimclient/lib/Jifty/View/Declare/Compile.pm
==============================================================================
--- jifty/branches/trimclient/lib/Jifty/View/Declare/Compile.pm	(original)
+++ jifty/branches/trimclient/lib/Jifty/View/Declare/Compile.pm	Mon Jun 18 04:14:20 2007
@@ -38,6 +38,7 @@
 
 use constant method_invocation => '.';
 
+sub is_scope { goto \&B::Deparse::is_scope }
 sub is_state { goto \&B::Deparse::is_state }
 sub null { goto \&B::Deparse::null }
 
@@ -146,6 +147,29 @@
 }
 
 sub pp_undef { 'null' }
+sub pp_sne { shift->binop(@_, "!=", 14) }
+sub pp_grepwhile { shift->mapop(@_, "grep") }
+
+sub mapop {
+    my $self = shift;
+    my($op, $cx, $name) = @_;
+    return $self->SUPER::mapop(@_) unless $name eq 'grep';
+    my($expr, @exprs);
+    my $kid = $op->first; # this is the (map|grep)start
+    $kid = $kid->first->sibling; # skip a pushmark
+    my $code = $kid->first; # skip a null
+    if (is_scope $code) {
+	$code = "{" . $self->deparse($code, 0) . "} ";
+    } else {
+	$code = $self->deparse($code, 24) . ", ";
+    }
+    $kid = $kid->sibling;
+    for (; !null($kid); $kid = $kid->sibling) {
+	$expr = $self->deparse($kid, 6);
+	push @exprs, $expr if defined $expr;
+    }
+    return "(".join(", ", @exprs).").select(function (\$_) $code)";
+}
 
 sub _anoncode {
     my ($self, $text) = @_;

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	Mon Jun 18 04:14:20 2007
@@ -17,6 +17,7 @@
 var form_return  = function(foo, label, bar, submit) {
     var action_hash = {};
     action_hash[submit.moniker] = 1;
+    // XXX: fix the fabricated refresh-self
     var onclick = 'if(event.ctrlKey||event.metaKey||event.altKey||event.shiftKey) return true; return update('
     + JSON.stringify({'continuation': {},
 		      'actions': action_hash,
@@ -292,7 +293,7 @@
 	if (!this.s_a) {
 	    /* XXX: make REST client accessible */
 	    var Todo = new AsynapseRecord('todo');
-	    this.s_a = $H(Todo.eval_ajax_get('/=/action/Jifty.Plugin.Authentication.Password.Action.Signup.js'));
+	    this.s_a = $H(Todo.eval_ajax_get('/=/action/'+this.actionClass+'.js'));
 	}
 	
 	return this.s_a
@@ -317,6 +318,7 @@
  initialize: function(name, args, action) {
 	this.name = name;
 	this.label = args.label;
+	this.hints = args.hints;
 	this.mandatory = args.mandatory;
 	this.action = action;
 	if (!this.render_mode) this.render_mode = 'update';


More information about the Jifty-commit mailing list