Bump versions for release
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / YAML / HTML.pm
CommitLineData
e601adda 1package Catalyst::Action::Serialize::YAML::HTML;
2
930013e6 3use Moose;
4use namespace::autoclean;
e601adda 5
930013e6 6extends 'Catalyst::Action';
e601adda 7use YAML::Syck;
8use URI::Find;
9
3bb36dca 10our $VERSION = '0.82';
f465980c 11$VERSION = eval $VERSION;
12
e601adda 13sub execute {
14 my $self = shift;
15 my ( $controller, $c ) = @_;
16
faf5c20b 17 my $stash_key = (
07682cbc 18 $controller->{'serialize'} ?
19 $controller->{'serialize'}->{'stash_key'} :
20 $controller->{'stash_key'}
faf5c20b 21 ) || 'rest';
e601adda 22 my $app = $c->config->{'name'} || '';
23 my $output = "<html>";
24 $output .= "<title>" . $app . "</title>";
25 $output .= "<body><pre>";
26 my $text = Dump($c->stash->{$stash_key});
27 # Straight from URI::Find
28 my $finder = URI::Find->new(
29 sub {
30 my($uri, $orig_uri) = @_;
a621925a 31 my $newuri;
f7218d54 32 if ($uri =~ /\?/) {
a621925a 33 $newuri = $uri . "&content-type=text/html";
34 } else {
35 $newuri = $uri . "?content-type=text/html";
36 }
37 return qq|<a href="$newuri">$orig_uri</a>|;
e601adda 38 });
39 $finder->find(\$text);
40 $output .= $text;
41 $output .= "</pre>";
42 $output .= "</body>";
43 $output .= "</html>";
44 $c->response->output( $output );
45 return 1;
46}
47
481;