r55@latte: adam | 2006-12-03 16:09:26 -0800
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / YAML / HTML.pm
CommitLineData
e601adda 1#
2# Catlyst::Action::Serialize::YAML::HTML.pm
3# Created by: Adam Jacob, Marchex, <adam@marchex.com>
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
21 my $stash_key = $controller->config->{'serialize'}->{'stash_key'} || 'rest';
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) = @_;
31 return qq|<a href="$uri">$orig_uri</a>|;
32 });
33 $finder->find(\$text);
34 $output .= $text;
35 $output .= "</pre>";
36 $output .= "</body>";
37 $output .= "</html>";
38 $c->response->output( $output );
39 return 1;
40}
41
421;