package RapidApp::JSONFunc;
use strict;
use warnings;
use Moose;
# This object allows returning functions within JSON. To prevent the function from being
# quoted (i.e. turned into a string), thi
be encoded with RapidApp::JSON::MixedEncoder
# which extends JSON::PP and modifies the behavior to return TO_JSON_RAW as-is
use RapidApp::Util qw(:all);
use RapidApp::JSON::MixedEncoder;
has 'func'
=> 'ro', default => 0 );
has 'json' => ( is => 'ro', lazy_build => 1 );
sub _build_json {
my $self = shift;
return RapidApp::JSON::MixedEncoder->new;
}
sub TO_JSON {
my $self = shift;
return $
;
use AnySan::Receive;
use HTTP::Request::Common;
use AnyEvent::HTTP;
use AnyEvent::SlackRTM;
use JSON;
use Encode;
sub slack {
my(%config) = @_;
my $self = __PACKAGE__->new(
client
= map { $_ => $req->header($_), } $req->headers->header_field_names;
my $jd = $self->{json_driver} ||= JSON->new->utf8;
my $r;
$r = http_post $req->uri, $req->content, headers => \%headers
es) . '">' . $html_out . '</div>';
}
sub xtemplate {
my $self = shift;
return RapidApp::JSONFunc->new(
#func => 'new Ext.XTemplate',
func => 'Ext.ux.RapidApp.newXTemplate',
parm
lf = shift;
return {
compiled => \1,
disableFormats => \1,
renderField => RapidApp::JSONFunc->new( raw => 1, func =>
'function(name,values,renderer) {' .
#'var record = { d
y $cnf = {
url => $self->suburl('printview'),
params => $params
};
my $json = $self->json->encode($cnf);
return {
xtype => 'button',
text => 'Print View',
ic
# make sure config_params is a string of JSON
if (ref $c->stash->{config_params}) {
$c->stash->{config_params}= RapidApp::JSON::MixedEncoder::encode_json($c->stash->{config_params});
}
return
mport::Into;
use Time::HiRes qw(gettimeofday tv_interval);
use HTTP::Request::Common;
use JSON qw(decode_json);
use Catalyst::Utils;
use RapidApp::Test::Client;
my $target;
my $app_class;
sub impor
local $| = 1;
use strict;
use JSON;
use SelectPdf;
print "This is SelectPdf-$SelectPdf::VERSION\n";
my $test_url = "https://selectpdf.com/demo/files/selectpdf.pdf";
my $test_pdf = "Input.p
::UsageClient($apiKey);
my $usage = $usageClient->getUsage(0);
print("Usage: " . encode_json($usage) . "\n");
print("Conversions remained this month: ". $usage->{"available"});
};
i
per::Concise 'Dumper';
use RapidApp::RootModule;
use Clone qw(clone);
use RapidApp::JSON::MixedEncoder qw(encode_json);
use Try::Tiny;
use Time::HiRes qw(gettimeofday tv_interval);
sub scream {
loca
out => undef,
newline => 0,
list_args => 0,
list_out => 0,
dump_maxdepth => 3,
use_json => 0,
stack => 0,
instance => 0,
color => GREEN,
ret_color => RED.BOLD,
arg_igno
eturn Dumper(@_) unless ($opt{use_json});
#return RapidApp::JSON::MixedEncoder->new->allow_blessed->convert_blessed->allow_nonref->encode(\@_);
return encode_json(\@_);
} unless ($opt{dump_func})
rm::ANSIColor qw(:constants);
use RapidApp::JSON::MixedEncoder qw(
encode_json decode_json encode_json_utf8 decode_json_utf8 encode_json_ascii decode_json_ascii
);
use RapidApp::Util::Hash::Merge q
finally
gettimeofday tv_interval
Dumper
encode_json decode_json encode_json_utf8 decode_json_utf8 encode_json_ascii decode_json_ascii
merge
);
push @EXPORT_OK, @{$Term::ANSIColor
use RapidApp::Responder::InfoStatus;
use RapidApp::JSONFunc;
use RapidApp::JSON::MixedEncoder;
use RapidApp::JSON::RawJavascript;
use RapidApp::JSON::ScriptWithData;
use RapidApp::HTML::RawHtml;
use
s::Standard qw(:all);
use Scalar::Util qw(blessed);
use RapidApp::Util::MetaKeys::FK;
use JSON qw( from_json -support_by_pp );
use Path::Class qw( file dir );
use Try::Tiny;
sub load {
my ($self,
from_string {
my ($self, $string) = @_;
my $data = scalar(
# Assume JSON as the first format
try{ from_json($string, {allow_singlequote => 1, allow_barekey => 1}) } ||
# free-f
r::InfoStatus';
calleruse 'RapidApp::JSONFunc';
calleruse 'RapidApp::JSON::MixedEncoder';
calleruse 'RapidApp::JSON::RawJavascript';
calleruse 'RapidApp::JSON::ScriptWithData';
calleruse 'RapidAp
="display:none;">',
#'<div class="template-name">', $template, '</div>',
encode_json_ascii({
name => $template,
format => $self->Access->get_template_format($t
# make sure config_params is a string of JSON
if (ref $c->stash->{config_params}) {
$c->stash->{config_params}= RapidApp::JSON::MixedEncoder::encode_json($c->stash->{config_params});
}
if (
ref $c->stash->{panel_cfg}) {
$c->stash->{panel_cfg}= RapidApp::JSON::MixedEncoder::encode_json($c->stash->{panel_cfg});
}
return $self->next::method($c);
}
sub _get_asset_controller_urls {
plate . '</div>',
#'<div class="template-format">' . $format . '</div>',
encode_json_ascii($meta),
'</div>',
(
$exists ?
'<div title="Edit \''
="display:none;">',
#'<div class="template-name">', $template, '</div>',
encode_json_ascii({
name => $template,
format => $self->Access->get_template_format($t
dule' controller does:
$content_type = 'text/javascript; charset=utf-8';
$output = encode_json_ascii($cnf);
}
else {
# This is a direct browser call:
my $html = $self->_render
bodyStyle => 'border: 1px solid #D0D0D0;',
baseParams => {
resultset_condition => $self->json->encode({ 'me.' . $cond_data->{foreign} => $Row->get_column($cond_data->{self}) })
},
sto
1,
fields => $fields,
store => $self->getStore_func,
nameWidth => 250,
sm => RapidApp::JSONFunc->new( func => 'new Ext.grid.RowSelectionModel', parm => {
listeners => {
# Disable row
hat disableSelection doesn't work in propertygrid with 'source')
beforerowselect => RapidApp::JSONFunc->new( raw => 1, func => 'function() { return false; }' )
}
}),
plugins => [ 'titlecoll
lient($apiKey);
my $usage = $usageClient->getUsage(0);
print("Usage: " . encode_json($usage) . "\n");
print("Conversions remained this month: ". $usage->{"available"});
if ($@) {
print "An error occurred: $@\n";
}
Extract text from PDF
use JSON;
use SelectPdf;
print "This is SelectPdf-$SelectPdf::VERSION.\n";
my $test_url
lient($apiKey);
my $usage = $usageClient->getUsage(0);
print("Usage: " . encode_json($usage) . "\n");
print("Conversions remained this month: ". $usage->{"available"});
p::View::Printview' => 'View::RapidApp::Printview' ],
['RapidApp::View::JSON' => 'View::RapidApp::JSON' ],
['RapidApp::View::Template' => 'View::RapidApp::Template'
rn) eq 'HASH' &&
defined $warn->{msg}
);
$c->res->header( 'X-RapidApp-Warning' => encode_json_ascii($warn) );
}
around 'finalize_error' => sub {
my ($orig, $c, @args) = @_;
if($c->is_ra
t);
my $tp = $c->request->header('X-RapidApp-RequestContentType') or return 0;
return $tp eq 'JSON' ? 1 : 0;
}
# Some some housework on the config for normalization/consistency:
sub _normalize_ca
lf->AppDV->get_column($name) or return '';
$self->FieldCmp->{$Column->name} = $self->AppDV->json->encode($Column->get_field_config);
return '<div class="' . $Column->name . '">{' .
_column($name) or return '';
$self->AppDV->FieldCmp->{$Column->name} = $self->AppDV->json->encode($Column->get_field_config);
return $self->div_edit_field($Column->name,$display);
_column($name) or return '';
$self->AppDV->FieldCmp->{$Column->name} = $self->AppDV->json->encode($Column->get_field_config);
return $self->div_bigfield($Column->name,$display);
-Authenticated' => 0);
if ($self->auto_prompt && $self->c->stash->{requestContentType} ne 'JSON') {
my $authPath= $self->auth_module_path;
my $authModule;
defined $authPath && lengt
',''
);
1;
__END__
use Exporter qw( import );
use Data::Dumper;
use RapidApp::JSON::MixedEncoder;
use RapidApp::JSON::RawJavascript;
use RapidApp::HTML::RawHtml;
use RapidApp::Responder::UserError;
ORT = qw(
asjson rawjs mixedjs ashtml rawhtml usererr userexception
jsfunc blessed merge infostatus clone
);
# Module shortcuts
#
# JSON shortcuts
#
# encode the object into JSON text, with a
b asjson {
scalar(@_) == 1 or die "Expected single argument";
return RapidApp::JSON::MixedEncoder::encode_json($_[0]);
}
# Bless a string as RawJavascript so that it doesn't get encoded as JSON dat