Silki::JSON;
{
$Silki::JSON::VERSION = '0.29';
}
use strict;
use warnings;
use JSON::XS;
{
my $json = JSON::XS->new();
$json->pretty(1);
$json->utf8(1);
sub Encode { $json->encod
) }
sub Decode { $json->decode( $_[1] ) }
}
1;
# ABSTRACT: A thin wrapper around a JSON::XS object
__END__
=pod
=head1 NAME
Silki::JSON - A thin wrapper around a JSON::XS object
=head1 VER
;
use File::Temp qw( tempdir );
use Path::Class qw( file );
use Silki::I18N qw( loc );
use Silki::JSON;
use Silki::Schema::Wiki;
use Silki::Types qw( Dir HashRef Tarball );
use Moose;
use MooseX::Sem
{
my $self = shift;
$self->_add_to_archive(
$self->_dir()->file('export-metadata.json'), {
silki_version => Silki->VERSION(),
export_format_version =>
e(
$self->_dir()->file('wiki.json'),
$self->_wiki()->serialize(),
);
$self->_add_to_archive(
$self->_dir()->file('permissions.json'),
$self->_wiki()->permissio
'0.29';
}
use strict;
use warnings;
use namespace::autoclean;
use HTTP::Status qw( RC_OK );
use JSON::XS;
use Scalar::Util qw( blessed );
use Silki::Types qw( ErrorForSession URIStr HashRef Bool Str
not available yet?
#requires qw( redirect_and_detach session_object );
my $JSON = JSON::XS->new();
$JSON->pretty(1);
$JSON->utf8(1);
my %spec = (
uri => { isa => URIStr, coerce
hRef, optional => 1 },
force_json => { isa => Bool, default => 0 },
json_content_type => { isa => Str, default => 'application/json' },
);
sub redirect_with_error {
my
uniq );
use Path::Class qw( dir file );
use Silki::Config;
use Silki::I18N qw( loc );
use Silki::JSON;
use Silki::Schema;
use Silki::Schema::Account;
use Silki::Schema::Domain;
use Silki::Schema::Fil
ean;
use autodie;
use Carp qw( croak );
use Silki::Config;
use Silki::I18N qw( loc );
use Silki::JSON;
use Silki::Schema;
use Silki::Schema::File;
use Silki::Web::CSS;
use Silki::Web::Javascript;
us
shift;
my $entity = shift;
$c->response()->content_type('application/json');
$c->response()->body( Silki::JSON->Encode($entity) );
return 1;
}
my %MethodPermission = (
GET =>
use File::Slurp qw( read_file );
use Path::Class qw( dir );
use Silki::I18N qw( loc );
use Silki::JSON;
use Silki::Schema::Domain;
use Silki::Schema::User;
use Silki::Schema::Wiki;
use Silki::Types qw
ki {
my $self = shift;
my $wiki_data = Silki::JSON->Decode(
scalar read_file(
$self->_find_file_in_archive('wiki.json')->stringify()
)
);
if ( Silki::Sche
ult_pages => 1,
);
my $perm_data = Silki::JSON->Decode(
scalar read_file(
$self->_find_file_in_archive('permissions.json')->stringify()
)
);
my %set = map
s qw( encode_entities );
use HTTP::Status qw( RC_NOT_FOUND RC_INTERNAL_SERVER_ERROR );
use Silki::JSON;
# I'd really rather _not_ copy this whole thing in here, but it's the
# only way to override ho
if $user->user_id();
}
$error{error} = $error . '';
$self->log()->error( Silki::JSON->Encode( \%error ) );
}
sub finalize_error {
my $self = shift;
my @errors = @{ $self->e