remove hardcoded version strings
[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
cc188065 10# VERSION
f465980c 11
e601adda 12sub execute {
13 my $self = shift;
14 my ( $controller, $c ) = @_;
15
faf5c20b 16 my $stash_key = (
07682cbc 17 $controller->{'serialize'} ?
18 $controller->{'serialize'}->{'stash_key'} :
19 $controller->{'stash_key'}
faf5c20b 20 ) || 'rest';
e601adda 21 my $app = $c->config->{'name'} || '';
22 my $output = "<html>";
23 $output .= "<title>" . $app . "</title>";
24 $output .= "<body><pre>";
8aa1a2ee 25 my $text = HTML::Entities::encode(Dump($c->stash->{$stash_key}));
e601adda 26 # Straight from URI::Find
27 my $finder = URI::Find->new(
28 sub {
29 my($uri, $orig_uri) = @_;
a621925a 30 my $newuri;
f7218d54 31 if ($uri =~ /\?/) {
a621925a 32 $newuri = $uri . "&content-type=text/html";
33 } else {
34 $newuri = $uri . "?content-type=text/html";
35 }
36 return qq|<a href="$newuri">$orig_uri</a>|;
e601adda 37 });
38 $finder->find(\$text);
39 $output .= $text;
40 $output .= "</pre>";
41 $output .= "</body>";
42 $output .= "</html>";
43 $c->response->output( $output );
44 return 1;
45}
46
24748286 47__PACKAGE__->meta->make_immutable;
48
e601adda 491;