pper
ImageCropper Control (widget)
=head2 imageloader
ImageLoader Utility (utility)
=head2 json
JSON Utility (utility)
=head2 layout
Layout Manager (widget)
=head2 logger
Logger Control (tool
;
use POE qw(Component::Client::REST::JSON);
use Moose;
our $VERSION = '0.05';
has rest => (
is => 'ro',
isa => 'POE::Component::Client::REST::JSON',
handles => [qw(shutdown)],
defa
ult => sub {
POE::Component::Client::REST::JSON->new(Alias => "$_[0]-REST")
},
);
has host => (
is => 'ro',
isa => 'Str',
default => 'localhost'
);
has port => (
is
1 VERSION
Version 0.05
=head1 SYNOPSIS
This class makes use of L<POE::Component::Client::REST::JSON> to provide an
asynchronous interface to the CouchDB REST API. All methods use
L<call|/METHODS>
package POE::Component::Client::CouchDB::Database;
use Moose;
use JSON;
our $VERSION = 0.05;
has couch => (
is => 'ro',
isa => 'POE::Component::Client::CouchDB',
required => 1,
);
);
}
sub get_revinfo {
my ($self, $id, @opt) = @_;
$self->call(GET => $id, query => {revs => JSON::true}, @opt);
}
sub create {
my ($self, $doc, @opt) = @_;
$self->call(POST => q(), content
hDB docs.
=over 4
=item call I<method, path, ...>
This is L<call|POE::Component::Client::REST::JSON/METHODS> with the url and
database parts filled in - use a path such as "_all_docs" instead. You
nings;
package CouchDB::View::Document;
use URI::Escape;
use Data::Dump::Streamer;
use JSON::XS;
my $j = JSON::XS->new;
sub new { bless $_[1] => $_[0] }
sub code_to_string {
my ($self, $code) =
$self->code_to_string($self->{views}{$_})
} keys %{ $self->{views} },
},
};
}
sub as_json {
my ($self) = @_;
return $j->encode($self->as_hash);
}
sub uri_id { uri_escape(shift->{_id
ith a hypothetical client
$couchdb_client->put(
'/mydatabase/' . $doc->uri_id,
$doc->as_json,
);
=head1 DESCRIPTION
CouchDB::View::Document provides a Perlish interface to creating L<Cou
e of the nastier details of talking to a REST
service.
use POE qw(Component::Client::REST::JSON);
# simple CouchDB example
POE::Session->create(inline_states => {
_start => sub
poe_kernel->alias_set('foo');
my $rest = $_[HEAP]->{rest} = POE::Component::Client::REST::JSON->new;
$rest->call(GET => 'http://localhost:5984/_all_dbs', callback =>
[$_[SESS
w
one (or the same one, modified). Undefined by default, but see
L<POE::Component::Client::REST::JSON>.
=item response_cooker
Similar to the above, but returns a list of things to be passed to the
use strict;
use warnings;
package CouchDB::View::Server;
use JSON::XS;
use IO::Handle;
my $j = JSON::XS->new;
{
our @d;
sub dmap { push @d, [@_] }
}
sub new { bless $_[1] => $_[0] }
sub in
package WWW::Twittervision;
use 5.008000;
use strict;
use warnings;
use Carp;
use LWP;
use JSON;
use URI::Escape;
use vars qw($VERSION $DEBUG $TVURL);
our $VERSION = '0.02';
$TVURL = 'http://api.tw
eds a screen name');
my $req_url = $self->{url} . '/user/current_status/' . $screen_name . '.json';
my $req = HTTP::Request->new(GET => $req_url);
my $ua = LWP::UserAgent->new;
m
carp('Unable to access ' . $req_url);
return undef;
}
my $json = new JSON;
my $data = $json->decode($res->content);
return $data;
}
sub update_status {
my $self =
our global vars, there is no way to escape them since CGI::Ajax doesnt support structured data ( JSON ?)
#
my $TOPOLOGY_OBJ = undef;
my $LANDMARKS_CONFIG = $SESSION->param("DOMAINS");
###check if
t;
my $form = shift;
my $outserial_key = $self->outserial_key;
my $outserial = 'json';
if($form->{$outserial_key}) {
$outserial = $form->{$outserial_key};
} elsif($u
require YAML;
$obj = YAML::Load($content);
} else {
require JSON;
$obj = JSON::from_json($content);
}
return $obj;
}
1;
__END__
=head1 NAME
Template::Plugin:
a form or just in the url's query_string
- handles many serializations (JSON, Storable, XML::Simple, YAML)
- defaults to JSON
=head1 OVERRIDABLE METHODS
content_cleanup - gets sent a Template::Plu
dering.
The available formatters are:
L<RDF::Server::Formatter::Atom>,
L<RDF::Server::Formatter::JSON>,
L<RDF::Server::Formatter::RDF>.
=for readme stop
=head1 SERVER CONFIGURATION
An RDF::Server
urce handler will pass in a Perl data structure. Rendering
to data serialization formats such as JSON or YAML will probably prefer
a data structure instead of RDF.
=item resource : Str
This return
data {
my($self) = @_;
# we want to return a hashref tree of ourselves
# useful for JSON and other data structure style formats
my $data = XML::Simple::XMLin($self -> fetch, NSExpan
query=new CGI;
my $outputformat=$query->param('outputformat')||'text';
if($outputformat=~/^(text|json)$/){
print $query->header(-type=>'text/plain');
}elsif($outputformat=~/^(xml)$/){
print $quer
my $h=$sbs->dataRequest(request=>join(',', @batchRequest));
$htot{batchsystem}=$h;
}
if(lc($outputformat) eq 'json'){
require JSON;
print JSON::objToJson(\%htot,{pretty => 1, indent => 2});
}
package CGI::JSONRPC::Obj;
use strict;
1;
sub jsonrpc_new {
my($class, $id, $dispatcher) = @_;
return bless { id => $id, dispatcher => $dispatcher }, $class;
}
sub jsonrpc_js_name {
my
my $name = shift || $self->jsonrpc_js_name();
return '';
}
sub jsonrpc_javascript {
my $self = shift;
return $self->js_class
}
=pod
=head1 NAME
CGI::JSONRPC::Obj - Base class for easy
e MyHandler;
use CGI::JSONRPC::Obj;
sub jsonrpc_javascript {
my $js;
# construct javascript object
return
}
sub do_something {
# handler that jsonrpc will call...
}
#!perl
package Apache2::JSONRPC;
use Apache2::Const qw(
TAKE1 OR_ALL OK HTTP_BAD_REQUEST SERVER_ERROR M_GET M_POST
);
use Apache2::RequestRec ();
use Apache2::CmdParms ();
use Apache2::RequestIO
CGI::JSONRPC::Base;
use base qw(CGI::JSONRPC::Base Apache2::Module);
our $VERSION = "0.02";
__PACKAGE__->add([ CookOptions(
[
'JSONRPC_Class',
'Perl class to dispatch JSONRPC c
_POST) {
my $json = $self->apache2_read_post($r) or return HTTP_BAD_REQUEST;
$r->content_type("text/json");
$r->print($self->run_json_request($json));
return O
package Apache2::JSONRPC::Session;
use strict;
use Apache2::JSONRPC;
use CGI::JSONRPC::Dispatcher::Session;
use base qw(Apache2::JSONRPC);
1;
sub new {
my ($class,%args) = @_;
%args = __PACKAG
d1 NAME
Apache2::JSONRPC::Session - Dispatcher class for session aware JSONRPC Objects
=head1 SYNOPSIS
package MyDispatch;
use Apache2::JSONRPC::Session;
use base qw(Apache2::JSONRPC::Session);
#
ession portions of CGI::JSONRPC are unmaintained and may change or
disappear without notice (probably change...)
=head1 DESCRIPTION
Apache2::JSONRPC::Dispatcher receives JSONRPC class method calls a
#!perl
package CGI::JSONRPC::Base;
use strict;
use warnings;
use JSON::Syck;
use JSON::Syck qw(Dump Load);
(our $JAVASCRIPT = __FILE__) =~ s{\.pm$}{.js};
1;
sub new {
my($class, %args) = @_;
, $class;
}
sub default_dispatcher {
'CGI::JSONRPC::Dispatcher'
}
sub run_json_request {
my($self, $json) = @_;
my $data = (JSON::Syck::Load($json))[0];
die "Did not get a hash from RP
a) eq 'HASH');
unless($data->{method}) {
warn "JSONRPC payload did not have a method!";
return $self->return_error($data, "JSONRPC payload did not have a method!");
}
return $self
package CGI::JSONRPC::Session;
use CGI::JSONRPC;
use CGI::JSONRPC::Dispatcher::Session;
use base qw(CGI::JSONRPC);
1;
sub new {
my($class,%args) = @_;
%args = __PACKAGE__->init_session(%ar
eaders_json {
my $self = shift;
$self->{session}->header('Content-Type' => "text/json");
}
sub default_dispatcher {
'CGI::JSONRPC::Dispatcher::Session'
}
=pod
=head1 NAME
CGI::JSONRPC::S
ession - Persistant CGI handler for JSONRPC
=head1 SYNOPSIS
use CGI;
use MyDispatcher
my $cgi = new CGI;
MyDispatcher->handler($cgi);
exit;
package MyDispatcher;
sub init_session
#!perl
package CGI::JSONRPC;
use strict;
use warnings;
use CGI::JSONRPC::Dispatcher;
use CGI::JSONRPC::Base;
use base qw(CGI::JSONRPC::Base);
use CGI;
our $VERSION = "0.11";
return 1;
sub headers
lf = shift;
$self->{cgi}->header("text/javascript");
}
sub headers_json {
my $self = shift;
$self->{cgi}->header("text/json");
}
sub handler {
my($class, $cgi,@args) = @_;
$cgi ||
f($method eq 'POST') {
my $json = $cgi->param('POSTDATA') or die "No POST data was sent!";
print $self->headers_json(), $self->run_json_request($json);
return 1;
} else {
#!perl
package CGI::JSONRPC::Dispatcher;
use strict;
use warnings;
our $AUTOLOAD;
use Attribute::Handlers;
use attributes;
our %Protected;
return 1;
sub UNIVERSAL::DontDispatch :ATTR(CODE) {
my
($package, $symbol) = @_;
$CGI::JSONRPC::Dispatcher::Protected{$package}{*{$symbol}{NAME}}++;
return 1;
}
sub DISPATCH_OBJECT {
my($class, $to) = @_;
}
sub AUTOLOAD {
my($class, $id, $to) =
$to\::$method_name may not be dispatched\n" if $Protected{$to}{$method_name};
my $object = $to->jsonrpc_new($id, $class);
if(my $method = $object->can($method_name)) {
return $method->($object