r49@latte: adam | 2006-12-03 12:30:40 -0800
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / YAML / HTML.pm
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
8 package Catalyst::Action::Serialize::YAML::HTML;
9
10 use strict;
11 use warnings;
12
13 use base 'Catalyst::Action';
14 use YAML::Syck;
15 use URI::Find;
16
17 sub 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
42 1;