/[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 11 - (hide annotations)
Tue Jun 5 13:13:02 2007 UTC (16 years, 11 months ago) by dpavlin
File size: 1516 byte(s)
added code_list
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 dpavlin 11 h1 { _("Available code") }
10     div { show 'code_list' }
11     };
12    
13     template '/edit' => page {
14 dpavlin 3 h1 { _("Enter your code") }
15     div { show 'code_editor' }
16     };
17    
18 dpavlin 11 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     length( $code->source ), ' bytes'
27     }
28     pre { $code->source },
29     }
30     }
31     }
32     };
33    
34 dpavlin 3 private template 'code_editor' => sub {
35 dpavlin 10 my $content;
36     my $op = 'Create';
37     my $id;
38     if ( $id = get 'id' ) {
39     my $code = Perly::Model::Code->new();
40     $code->load( $id ) or die "can't load $id";
41     $content = $code->source;
42     warn "loaded ", length( $content ), " bytes";
43     $op = 'Update';
44     }
45 dpavlin 3 form {
46 dpavlin 10 my $action = new_action( class => $op . 'Code', arguments => { id => $id, source => $content }, );
47 dpavlin 6 render_param( $action => 'source', cols => 80, rows => 25, language => 'perl', render_as => 'Jifty::Plugin::CodePress::Textarea' );
48 dpavlin 3 #render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] );
49 dpavlin 4 form_submit(
50 dpavlin 10 label => _($op),
51 dpavlin 4 onclick => [
52     { beforeclick => "CodePress.beforeSubmit();" },
53     ],
54     );
55 dpavlin 3 }
56     };
57    
58 dpavlin 8 template '/upload' => page {
59     h1 { _("Upload new file") },
60     form {
61     my $action = new_action( class => 'Upload' );
62 dpavlin 9 render_action( $action => [ 'content', 'file', 'format' ] );
63 dpavlin 8 form_submit(
64     label => _('Upload'),
65     );
66     }
67     };
68    
69 dpavlin 3 1;

  ViewVC Help
Powered by ViewVC 1.1.26