failing test for RT#43840
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / YAML / HTML.pm
CommitLineData
e601adda 1#
2# Catlyst::Action::Serialize::YAML::HTML.pm
be3c588a 3# Created by: Adam Jacob, Marchex, <adam@hjksolutions.com>
e601adda 4# Created on: 10/12/2006 03:00:32 PM PDT
5#
6# $Id$
7
8package Catalyst::Action::Serialize::YAML::HTML;
9
10use strict;
11use warnings;
12
13use base 'Catalyst::Action';
14use YAML::Syck;
15use URI::Find;
16
17sub execute {
18 my $self = shift;
19 my ( $controller, $c ) = @_;
20
faf5c20b 21 my $stash_key = (
22 $controller->config->{'serialize'} ?
23 $controller->config->{'serialize'}->{'stash_key'} :
24 $controller->config->{'stash_key'}
25 ) || 'rest';
e601adda 26 my $app = $c->config->{'name'} || '';
27 my $output = "<html>";
28 $output .= "<title>" . $app . "</title>";
29 $output .= "<body><pre>";
30 my $text = Dump($c->stash->{$stash_key});
31 # Straight from URI::Find
32 my $finder = URI::Find->new(
33 sub {
34 my($uri, $orig_uri) = @_;
a621925a 35 my $newuri;
f7218d54 36 if ($uri =~ /\?/) {
a621925a 37 $newuri = $uri . "&content-type=text/html";
38 } else {
39 $newuri = $uri . "?content-type=text/html";
40 }
41 return qq|<a href="$newuri">$orig_uri</a>|;
e601adda 42 });
43 $finder->find(\$text);
44 $output .= $text;
45 $output .= "</pre>";
46 $output .= "</body>";
47 $output .= "</html>";
48 $c->response->output( $output );
49 return 1;
50}
51
521;