/[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 4 by dpavlin, Sun Jun 3 22:49:47 2007 UTC revision 12 by dpavlin, Tue Jun 5 14:21:22 2007 UTC
# Line 6  use warnings; Line 6  use warnings;
6  use Jifty::View::Declare -base;  use Jifty::View::Declare -base;
7    
8  template '/' => page {  template '/' => page {
9            h1 { _("Available code") }
10            div { show 'code_list' }
11    };
12    
13    template '/edit' => page {
14          h1 { _("Enter your code") }          h1 { _("Enter your code") }
15          div { show 'code_editor' }          div { show 'code_editor' }
16  };  };
17    
18    private template 'code_list' => sub {
19            ul {
20                    my $coll = Perly::Model::CodeCollection->new();
21                    $coll->unlimit;
22                    while ( my $code = $coll->next ) {
23                            li {
24                                    a {
25                                            attr { href => '/edit?id=' . $code->id, },
26                                            $code->name,
27                                    },
28                                    small { length( $code->source ), ' bytes ', $code->created_on },
29                                    pre { $code->source },
30                            }
31                    }
32            }
33    };
34    
35  private template 'code_editor' => sub {  private template 'code_editor' => sub {
36            my $content;
37            my $op = 'Create';
38            my $id;
39            if ( $id = get 'id' ) {
40                    my $code = Perly::Model::Code->new();
41                    $code->load( $id ) or die "can't load $id";
42                    $content = $code->source;
43                    warn "loaded ", length( $content ), " bytes";
44                    $op = 'Update';
45            }
46          form {          form {
47                  my $action = new_action( class => 'CreateCode' );                  my $action = new_action( class => $op . 'Code', arguments => { id => $id, source => $content }, );
48                  render_param( $action => 'source', cols => 80, rows => 25 );                  render_param( $action => 'source', cols => 80, rows => 25, language => 'perl', render_as => 'Jifty::Plugin::CodePress::Textarea' );
49                  #render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] );                  #render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] );
50                  form_submit(                  form_submit(
51                          label => _("Save my code"),                          label => _($op),
52                          onclick => [                          onclick => [
53                                  { beforeclick => "CodePress.beforeSubmit();" },                                  { beforeclick => "CodePress.beforeSubmit();" },
54                          ],                          ],
55                  );                  );
56          }          }
57  };  };
58    
59    template '/upload' => page {
60            h1 { _("Upload new file") },
61            form {
62                    my $action = new_action( class => 'Upload' );
63                    render_action( $action => [ 'content', 'file', 'format' ] );
64                    form_submit(
65                            label => _('Upload'),
66                    );
67            }
68    };
69    
70  1;  1;

Legend:
Removed from v.4  
changed lines
  Added in v.12

  ViewVC Help
Powered by ViewVC 1.1.26