package Apache::Voodoo::View::JSON;
$VERSION = "3.0200";
use strict;
use warnings;
use JSON::DWIW;
use base("Apache::Voodoo::View");
sub init {
my $self = shift;
my $config = shift;
$self->
content_type('application/javascript');
$self->{json} = JSON::DWIW->new({
'bad_char_policy' => 'convert',
'pretty' => ($config->{dynamic_loading})?1:0
});
}
sub params {
my $self = shift;
i
or'} = 1;
$self->{data} = $d;
}
sub output {
my $self = shift;
return scalar($self->{json}->to_json($self->{data}));
}
sub finish {
my $self = shift;
$self->{data} = {};
}
sub _stack_trac
::Debug::Handler;
$VERSION = "3.0200";
use strict;
use warnings;
use DBI;
use Time::HiRes;
use JSON::DWIW;
use Apache::Voodoo::MP;
use Apache::Voodoo::Constants;
sub new {
my $class = shift;
my
"image/png",
"trace.png" => "image/png",
"warn.png" => "image/png"
};
$self->{json} = JSON::DWIW->new({bad_char_policy => 'convert', pretty => 1});;
return $self;
}
sub handler {
m
if (ref($return) eq "HASH") {
$self->{mp}->content_type("application/json");
$self->{mp}->print($self->{json}->to_json($return));
}
else {
$self->{mp}->content_type("text/plain");
$s
e idea for JSON. What website these days doesn't use even
# a little AJAX?
unless (defined($self->{'views'}->{'JSON'})) {
require Apache::Voodoo::View::JSON;
$self->{'views'}->{'JSON'} = Apache
::Voodoo::View::JSON->new();
}
# models get the config and every model except themselves
# to prevent accidental circular references
foreach my $key (keys %{$self->{'models'}}) {
my %m = map {
pache::Voodoo::Debug::Common");
use Apache::Voodoo::Constants;
use DBI;
use HTML::Template;
use JSON::DWIW;
sub new {
my $class = shift;
my $id = shift;
my $conf = shift;
my $self = {};
bl
m(
debug_root => $ac->debug_path(),
app_id => $self->{id}->{app_id}
);
$self->{json} = JSON::DWIW->new({bad_char_policy => 'convert', pretty => 1});
$self->{db_info} = $ac->debug_dbd
e {
my $self = shift;
my $j;
if (scalar(@_) > 1) {
$j = $self->{json}->to_json(\@_);
}
else {
$j = $self->{json}->to_json($_[0]);
}
return $j;
}
sub _write {
my $self = shift;
my $dat
rict;
use warnings;
no warnings 'uninitialized';
use base("Apache::Voodoo::Debug::Common");
use JSON::DWIW;
use constant {
DEBUG => 'LOG',
INFO => 'INFO',
WARN => 'WARN',
ERROR
stant WF_VERSION => "2.00";
use constant WF_PROTOCOL => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2';
use constant WF_PLUGIN => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Librar
hift;
my $id = shift;
my $conf = shift;
my $self = {};
bless $self,$class;
$self->{json} = JSON::DWIW->new({bad_char_policy => 'convert'});
$self->{setHeader} = sub { return; };
$self->{
nteraction away from the user's code
=item * MVC (default views for HTML via HTML::Template, and JSON)
=item * Dynamic reloading of modules upon change (bypass-able for production sites)
=item * Au