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

Contents of /lib/Perly/View.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26