8 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
9 |
use Carp qw/confess/; |
use Carp qw/confess/; |
10 |
|
|
11 |
|
use Frey::ClassLoader; |
12 |
|
|
13 |
|
warn "# ",dump( Frey::ClassLoader->new->load_all_classes() ); |
14 |
|
|
15 |
|
|
16 |
sub markup { |
sub markup { |
17 |
my ($self, $c) = @_; |
my ($self, $c) = @_; |
18 |
|
|
19 |
warn "# ", dump( $c->match->captures ); |
warn "# ", dump( $c->match->captures ); |
20 |
|
|
|
# Response object |
|
|
my $res = $c->res; |
|
|
$res->code(200); |
|
|
$res->headers->content_type('text/html'); |
|
|
|
|
21 |
my $params = $c->request->params->to_hash; |
my $params = $c->request->params->to_hash; |
22 |
warn "# params ", dump( $params ); |
warn "# params ", dump( $params ); |
23 |
|
|
27 |
my $o = $class->new( %$params ); |
my $o = $class->new( %$params ); |
28 |
$o->depends if $o->can('depends'); |
$o->depends if $o->can('depends'); |
29 |
|
|
30 |
$res->body( $o->markup ); |
my $html; |
31 |
|
if ( $o->can('markup') ) { |
32 |
|
$html = eval { $o->markup }; |
33 |
|
if ( $@ ) { |
34 |
|
warn $@; |
35 |
|
$html .= qq{<code>$@</code>}; |
36 |
|
} |
37 |
|
} else { |
38 |
|
warn "SKIP: $class can't markup"; |
39 |
|
} |
40 |
|
|
41 |
|
eval { |
42 |
|
# FIXME am I paranoid? |
43 |
|
package Mock::Web; |
44 |
|
use Moose; |
45 |
|
extends 'Frey'; |
46 |
|
with 'Frey::Web'; |
47 |
|
|
48 |
|
$html = Mock::Web->new->page( |
49 |
|
title => $class, |
50 |
|
body => $html, |
51 |
|
); |
52 |
|
}; |
53 |
|
|
54 |
|
# Response objec |
55 |
|
my $res = $c->res; |
56 |
|
$res->code(200); |
57 |
|
$res->headers->content_type('text/html'); |
58 |
|
$res->body( $html ); |
59 |
} |
} |
60 |
|
|
61 |
1; |
1; |