--- lib/Perly/View.pm 2007/06/06 08:51:15 21 +++ lib/Perly/View.pm 2007/06/07 09:34:01 36 @@ -24,12 +24,12 @@ while ( my $code = $coll->next ) { li { a { - attr { href => '/edit?id=' . $code->id, }, + attr { href => '/edit/id=' . $code->id, }, $code->name, }, small { length( $code->source ), ' bytes ', $code->created_on }, a { - attr { href => '/run?code=' . $code->id, }, 'run' + attr { href => '/run/code=' . $code->id, }, 'run' }, pre { $code->source }, } @@ -37,6 +37,21 @@ } }; +sub codepress { + my $codepress = 1; + $codepress = current_user->user_object->codepress if ( current_user->id ); + return { render_as => 'Textarea' } unless ( $codepress ); + + return { + render_as => 'Jifty::Plugin::CodePress::Textarea', + submit => { + onclick => [ + { beforeclick => 'CodePress.beforeSubmit();' }, + ], + }, + }; +} + private template 'code_editor' => sub { my $op = 'Create'; my $code = Perly::Model::Code->new(); @@ -45,17 +60,17 @@ warn "loaded ", length( $code->source ), " bytes"; $op = 'Update'; } + + warn "## editor: ", dump( codepress ); + form { my $action = new_action( class => $op . 'Code', arguments => { $code ? $code->as_hash : undef } ); render_param( $action => 'name' ); - render_param( $action => 'source', cols => 80, rows => 25, language => 'perl', render_as => 'Jifty::Plugin::CodePress::Textarea' ); + render_param( $action => 'source', cols => 80, rows => 25, language => 'perl', render_as => codepress->{render_as} ); #render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] ); - form_submit( - label => _($op), - onclick => [ - { beforeclick => "CodePress.beforeSubmit();" }, - ], - ); + form_submit( label => _($op), %{ codepress->{submit} } ); + # IE problem http://support.microsoft.com/kb/281197 + form_next_page( url => '/run/code=' . $action->argument_value('id') ); } }; @@ -63,7 +78,7 @@ h1 { _("Upload new file") }, form { my $action = new_action( class => 'Upload' ); - render_action( $action => [ 'content', 'file', 'format' ] ); + render_action( $action => [ 'filename', 'content', 'file', 'format' ] ); form_submit( label => _('Upload'), ); @@ -71,10 +86,11 @@ }; template '/run' => page { - my $action = new_action( class => 'Run', arguments => { input => get('input'), code => get('code') } ); + my $action = new_action( class => 'Run' ); h1 { _("Run code on some input") }, form { - render_action( $action => [ 'input', 'code' ] ); + render_param( $action => 'input', default_value => get('input') ), + render_param( $action => 'code', default_value => get('code') ), form_submit( label => _('Run'), );