11 |
}; |
}; |
12 |
|
|
13 |
private template 'code_editor' => sub { |
private template 'code_editor' => sub { |
14 |
|
my $content; |
15 |
|
my $op = 'Create'; |
16 |
|
my $id; |
17 |
|
if ( $id = get 'id' ) { |
18 |
|
my $code = Perly::Model::Code->new(); |
19 |
|
$code->load( $id ) or die "can't load $id"; |
20 |
|
$content = $code->source; |
21 |
|
warn "loaded ", length( $content ), " bytes"; |
22 |
|
$op = 'Update'; |
23 |
|
} |
24 |
form { |
form { |
25 |
my $action = new_action( class => 'CreateCode' ); |
my $action = new_action( class => $op . 'Code', arguments => { id => $id, source => $content }, ); |
26 |
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 => 'Jifty::Plugin::CodePress::Textarea' ); |
27 |
#render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] ); |
#render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] ); |
28 |
form_submit( |
form_submit( |
29 |
label => _("Save my code"), |
label => _($op), |
30 |
onclick => [ |
onclick => [ |
31 |
{ beforeclick => "CodePress.beforeSubmit();" }, |
{ beforeclick => "CodePress.beforeSubmit();" }, |
32 |
], |
], |