/[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 12 - (show annotations)
Tue Jun 5 14:21:22 2007 UTC (17 years ago) by dpavlin
File size: 1565 byte(s)
added filenames, from upload name (if available) or from UUID
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 $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 {
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 {
47 my $action = new_action( class => $op . 'Code', arguments => { id => $id, source => $content }, );
48 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 }, ] );
50 form_submit(
51 label => _($op),
52 onclick => [
53 { 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;

  ViewVC Help
Powered by ViewVC 1.1.26