/[Frey]/trunk/lib/Frey/ObjectDesigner.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 /trunk/lib/Frey/ObjectDesigner.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 121 - (show annotations)
Mon Jul 14 21:22:43 2008 UTC (14 years, 2 months ago) by dpavlin
File size: 1545 byte(s)
central page creation [0.11]

- make (optional) development feature in Makefile.PL
- split page generation in Frey::Web->page
- cleanup of html generation code all over
- jump to Carp::REPL on errors (nice, but needs to be in browser)

This is a move to more embedded html. While it does seem evil, we are aming
here at lean framework, so readability is prefered...
1 package Frey::ObjectDesigner;
2 use Moose;
3
4 extends 'Frey';
5 with 'Frey::Web';
6
7 has 'fey_class' => (
8 is => 'rw',
9 isa => 'Str',
10 required => 1,
11 );
12
13 use Data::Dump qw/dump/;
14
15 use Frey::Web::Row;
16 use Frey::Web::Links;
17
18 sub html {
19 my ( $self, $req ) = @_;
20
21 my $f = { $req->params };
22 my $layout = delete( $f->{layout} ) || 'div';
23
24 while ( 1 ) {
25
26 warn "<<< GOT REQUEST ",dump( $f );
27
28 # re-apply (changed?) layout to elements
29 if ( defined $f->{layout} ) {
30 $layout = delete( $f->{layout} );
31 warn "# new layout = $layout\n";
32 }
33
34 my $w = Frey::Web::Row->new( fey_class => $self->fey_class, layout => $layout, render_as => 'edit' );
35
36 my $form = $w->process($f);
37
38 $form = qq|<table>$form</table>| if $layout eq 'table';
39
40 if ( $layout eq 'columns' ) {
41 # add header to table
42 my $header = $w->render_iterator( sub {
43 my ( $name, $field_name, $label, $val ) = @_;
44 return if $name =~ /^_/;
45 return qq|<th>$label</th>|;
46 });
47 $form = qq|<table><tr>$header</tr>$form</table>|;
48 }
49
50 my $layout_picker =
51 qq|<div class="layout">layout: | .
52 Frey::Web::Links->new(
53 name => 'layout',
54 current => $layout,
55 values => [ 'div', 'table', 'columns' ],
56 )->links .
57 qq|</div>|
58 ;
59
60 $self->add_css( 'static/form.css' );
61
62 my $html = $self->page(
63 body => '<h1>' . $self->fey_class . '</h1>'
64 . $layout_picker
65 . qq|<form method="post">$form</form>|
66 );
67
68 warn ">>> $layout ",length( $html ),"\n";
69
70 $req->print( $html );
71 $req->next;
72
73 $f = { $req->params };
74 }
75
76 warn "NO WAY OUT!";
77 };
78
79 1;

  ViewVC Help
Powered by ViewVC 1.1.26