/[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 12 - (hide annotations)
Tue Jun 5 14:21:22 2007 UTC (16 years, 11 months ago) by dpavlin
File size: 1565 byte(s)
added filenames, from upload name (if available) or from UUID
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 dpavlin 12 $code->name,
27     },
28     small { length( $code->source ), ' bytes ', $code->created_on },
29 dpavlin 11 pre { $code->source },
30     }
31     }
32     }
33     };
34    
35 dpavlin 3 private template 'code_editor' => sub {
36 dpavlin 10 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 dpavlin 3 form {
47 dpavlin 10 my $action = new_action( class => $op . 'Code', arguments => { id => $id, source => $content }, );
48 dpavlin 6 render_param( $action => 'source', cols => 80, rows => 25, language => 'perl', render_as => 'Jifty::Plugin::CodePress::Textarea' );
49 dpavlin 3 #render_action( $action => [ 'source' => { cols => 80, rows => 30 }, ] );
50 dpavlin 4 form_submit(
51 dpavlin 10 label => _($op),
52 dpavlin 4 onclick => [
53     { beforeclick => "CodePress.beforeSubmit();" },
54     ],
55     );
56 dpavlin 3 }
57     };
58    
59 dpavlin 8 template '/upload' => page {
60     h1 { _("Upload new file") },
61     form {
62     my $action = new_action( class => 'Upload' );
63 dpavlin 9 render_action( $action => [ 'content', 'file', 'format' ] );
64 dpavlin 8 form_submit(
65     label => _('Upload'),
66     );
67     }
68     };
69    
70 dpavlin 3 1;

  ViewVC Help
Powered by ViewVC 1.1.26