37 |
} |
} |
38 |
}; |
}; |
39 |
|
|
40 |
|
sub codepress { |
41 |
|
my $codepress = 1; |
42 |
|
$codepress = current_user->user_object->codepress if ( current_user->id ); |
43 |
|
return { render_as => 'Textarea' } unless ( $codepress ); |
44 |
|
return { render_as => 'Jifty::Plugin::CodePress::Textarea' }; |
45 |
|
} |
46 |
|
|
47 |
private template 'code_editor' => sub { |
private template 'code_editor' => sub { |
48 |
my $op = 'Create'; |
my $op = 'Create'; |
49 |
my $code = Perly::Model::Code->new(); |
my $code = Perly::Model::Code->new(); |
52 |
warn "loaded ", length( $code->source ), " bytes"; |
warn "loaded ", length( $code->source ), " bytes"; |
53 |
$op = 'Update'; |
$op = 'Update'; |
54 |
} |
} |
55 |
|
|
56 |
|
warn "## editor: ", dump( codepress ); |
57 |
|
|
58 |
form { |
form { |
59 |
my $action = new_action( class => $op . 'Code', arguments => { $code ? $code->as_hash : undef } ); |
my $action = new_action( class => $op . 'Code', arguments => { $code ? $code->as_hash : undef } ); |
60 |
render_param( $action => 'name' ); |
render_param( $action => 'name' ); |
61 |
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} ); |
62 |
#render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] ); |
#render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] ); |
63 |
form_submit( |
form_submit( label => _($op) ); |
64 |
label => _($op), |
# IE problem http://support.microsoft.com/kb/281197 |
|
onclick => [ |
|
|
{ beforeclick => "CodePress.beforeSubmit();" }, |
|
|
], |
|
|
); |
|
65 |
form_next_page( url => '/run/code=' . $action->argument_value('id') ); |
form_next_page( url => '/run/code=' . $action->argument_value('id') ); |
66 |
} |
} |
67 |
}; |
}; |
78 |
}; |
}; |
79 |
|
|
80 |
template '/run' => page { |
template '/run' => page { |
81 |
my $action = new_action( class => 'Run', arguments => { |
my $action = new_action( class => 'Run' ); |
|
input => get('input'), |
|
|
code => get('code'), |
|
|
} ); |
|
82 |
h1 { _("Run code on some input") }, |
h1 { _("Run code on some input") }, |
83 |
form { |
form { |
84 |
render_action( $action => [ 'input', 'code' ] ); |
render_param( $action => 'input', default_value => get('input') ), |
85 |
|
render_param( $action => 'code', default_value => get('code') ), |
86 |
form_submit( |
form_submit( |
87 |
label => _('Run'), |
label => _('Run'), |
88 |
); |
); |
101 |
} |
} |
102 |
}; |
}; |
103 |
|
|
104 |
|
template '/prefs' => page { |
105 |
|
my $action = new_action( class => 'UpdateUser', arguments => { id => current_user->id } ); |
106 |
|
h1 { _("My preferences") }, |
107 |
|
form { |
108 |
|
render_action( $action => [ 'name', 'email', 'codepress' ] ); |
109 |
|
form_submit( |
110 |
|
label => _('Save changes'), |
111 |
|
); |
112 |
|
}; |
113 |
|
}; |
114 |
|
|
115 |
1; |
1; |