package MyApp::Controller::Play; use strict; use warnings; use parent 'Catalyst::Controller'; use YAML (); use CGI ":standard"; my $th_style = { -style => "font-family:sans-serif; font-size:13px; text-align:right; border:1px solid black; padding: 1px 3px; margin:1px;background-color:#fef;" }; my $td_style = { -style => "font-family:sans-serif; font-size:12px;border:1px solid black; padding: 1px 3px; margin:1px; background-color:#efe" }; my $td_style2 = { -style => "font-family:sans-serif; font-size:12px;border:1px solid black; padding: 1px 3px; margin:1px; background-color:#eff" }; sub schema : Local { my ( $self, $c ) = @_; my $schema = $c->model("DB")->schema; my @sources = start_html("DB schema"); for my $src ( sort { "$a" cmp "$b" } $schema->sources ) { push @sources, h2($src); push @sources, ''; for my $col ( $schema->source($src)->columns ) { push @sources, ""; push @sources, th($th_style, $col); my $col_info = $schema->source($src)->column_info($col); for my $key ( reverse sort keys %{ $col_info } ) { push @sources, $key ? td($td_style, $key) : td(" "); my $info = ref $col_info->{$key} ? YAML::Dump($col_info->{$key}) : $col_info->{$key}; push @sources, $info ? td($td_style2, $info) : td(" "); } push @sources, ""; } push @sources, "
"; } $c->response->body( join("\n",@sources) ); } sub walk_object : Local Args(2) { my ( $self, $c, $type, $id ) = @_; my $object = $c->model("DB::$type")->find($id) or die "No can do, no $type with id '$id'"; $c->stash( object => $object ); } 1;