/[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

Diff of /lib/Perly/View.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 15 by dpavlin, Tue Jun 5 23:23:30 2007 UTC revision 30 by dpavlin, Wed Jun 6 18:48:51 2007 UTC
# Line 24  private template 'code_list' => sub { Line 24  private template 'code_list' => sub {
24                  while ( my $code = $coll->next ) {                  while ( my $code = $coll->next ) {
25                          li {                          li {
26                                  a {                                  a {
27                                          attr { href => '/edit?id=' . $code->id, },                                          attr { href => '/edit/id=' . $code->id, },
28                                          $code->name,                                          $code->name,
29                                  },                                  },
30                                  small { length( $code->source ), ' bytes ', $code->created_on },                                  small { length( $code->source ), ' bytes ', $code->created_on },
31                                    a {
32                                            attr { href => '/run/code=' . $code->id, }, 'run'
33                                    },
34                                  pre { $code->source },                                  pre { $code->source },
35                          }                          }
36                  }                  }
# Line 35  private template 'code_list' => sub { Line 38  private template 'code_list' => sub {
38  };  };
39    
40  private template 'code_editor' => sub {  private template 'code_editor' => sub {
         my $content;  
41          my $op = 'Create';          my $op = 'Create';
42          my $id;          my $code = Perly::Model::Code->new();
43          if ( $id = get 'id' ) {          if ( my $id = get 'id' ) {
                 my $code = Perly::Model::Code->new();  
44                  $code->load( $id ) or die "can't load $id";                  $code->load( $id ) or die "can't load $id";
45                  $content = $code->source;                  warn "loaded ", length( $code->source ), " bytes";
                 warn "loaded ", length( $content ), " bytes";  
46                  $op = 'Update';                  $op = 'Update';
47          }          }
48          form {          form {
49                  my $action = new_action( class => $op . 'Code', arguments => { id => $id, source => $content }, );                  my $action = new_action( class => $op . 'Code', arguments => { $code ? $code->as_hash : undef } );
50                    render_param( $action => 'name' );
51                  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' );
52                  #render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] );                  #render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] );
53                  form_submit(                  form_submit(
# Line 55  private template 'code_editor' => sub { Line 56  private template 'code_editor' => sub {
56                                  { beforeclick => "CodePress.beforeSubmit();" },                                  { beforeclick => "CodePress.beforeSubmit();" },
57                          ],                          ],
58                  );                  );
59                    form_next_page( url => '/run/code=' . $action->argument_value('id') );
60          }          }
61  };  };
62    
# Line 62  template '/upload' => page { Line 64  template '/upload' => page {
64          h1 { _("Upload new file") },          h1 { _("Upload new file") },
65          form {          form {
66                  my $action = new_action( class => 'Upload' );                  my $action = new_action( class => 'Upload' );
67                  render_action( $action => [ 'content', 'file', 'format' ] );                  render_action( $action => [ 'filename', 'content', 'file', 'format' ] );
68                  form_submit(                  form_submit(
69                          label => _('Upload'),                          label => _('Upload'),
70                  );                  );
# Line 70  template '/upload' => page { Line 72  template '/upload' => page {
72  };  };
73    
74  template '/run' => page {  template '/run' => page {
75          my $action = new_action( class => 'Run' );          my $action = new_action( class => 'Run', arguments => {
76                    input => get('input'),
77                    code => get('code'),
78            } );
79            warn "code = ",get('code'), " input = ", get('input'), dump( $action );
80          h1 { _("Run code on some input") },          h1 { _("Run code on some input") },
81          form {          form {
82                  render_action( $action => [ 'input', 'code' ] );                  render_action( $action => [ 'input', 'code' ] );
# Line 78  template '/run' => page { Line 84  template '/run' => page {
84                          label => _('Run'),                          label => _('Run'),
85                  );                  );
86          };          };
87          if ( $action->result->content ) {  
88                  h1 { _("Output") },          #warn dump( $action->result->content );
89                  pre {  
90                          $action->result->content( 'output' )          if ( my $input = $action->result->content( 'input' ) ) {
91                  }                  h2 { _("Input data") },
92                    pre { $input }
93            }
94    
95            if ( my $output = $action->result->content( 'output' ) ) {
96                    h2 { _("Output result") },
97                    pre { $output }
98          }          }
99  };  };
100    

Legend:
Removed from v.15  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC 1.1.26