/[Perly]/lib/Perly/View.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /lib/Perly/View.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide annotations)
Tue Jun 5 12:52:40 2007 UTC (16 years, 11 months ago) by dpavlin
File size: 1130 byte(s)
code_editor can now create or update (if given id)
1 dpavlin 3 package Perly::View;
2    
3     use strict;
4     use warnings;
5    
6     use Jifty::View::Declare -base;
7    
8     template '/' => page {
9     h1 { _("Enter your code") }
10     div { show 'code_editor' }
11     };
12    
13     private template 'code_editor' => sub {
14 dpavlin 10 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 dpavlin 3 form {
25 dpavlin 10 my $action = new_action( class => $op . 'Code', arguments => { id => $id, source => $content }, );
26 dpavlin 6 render_param( $action => 'source', cols => 80, rows => 25, language => 'perl', render_as => 'Jifty::Plugin::CodePress::Textarea' );
27 dpavlin 3 #render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] );
28 dpavlin 4 form_submit(
29 dpavlin 10 label => _($op),
30 dpavlin 4 onclick => [
31     { beforeclick => "CodePress.beforeSubmit();" },
32     ],
33     );
34 dpavlin 3 }
35     };
36    
37 dpavlin 8 template '/upload' => page {
38     h1 { _("Upload new file") },
39     form {
40     my $action = new_action( class => 'Upload' );
41 dpavlin 9 render_action( $action => [ 'content', 'file', 'format' ] );
42 dpavlin 8 form_submit(
43     label => _('Upload'),
44     );
45     }
46     };
47    
48 dpavlin 3 1;

  ViewVC Help
Powered by ViewVC 1.1.26