Articulate
view release on metacpan or search on metacpan
examples/plain-speaking/public/css/blog.css
examples/plain-speaking/public/dispatch.cgi
examples/plain-speaking/public/dispatch.fcgi
examples/plain-speaking/public/javascripts/plain-speaking-forms.js
examples/plain-speaking/views/article_result.tt
examples/plain-speaking/views/article.tt
examples/plain-speaking/views/error.tt
examples/plain-speaking/views/form/create.tt
examples/plain-speaking/views/form/edit.tt
examples/plain-speaking/views/form/login.tt
examples/plain-speaking/views/form/upload.tt
examples/plain-speaking/views/layouts/main.tt
examples/plain-speaking/views/list.tt
examples/plain-speaking/views/success.tt
.gitignore
lib/Articulate/Augmentation/Interpreter/Markdown.pm
lib/Articulate/Augmentation/Interpreter.pm
lib/Articulate/Augmentation.pm
lib/Articulate/Authentication/Internal.pm
lib/Articulate/Authentication.pm
lib/Articulate/Authentication/Preconfigured.pm
examples/plain-speaking/config.yml view on Meta::CPAN
- plain-speaking-forms
nav_links:
- href: /
text: Home
- href: http://github.com/pdl/Articulate
text: About Articulate
- href: /login
text: Log In
- href: /create
text: New Post
- href: /upload
text: New File
- Articulate::Serialisation::StatusSetter
- Articulate::Serialisation::Asset
- Articulate::Serialisation::TemplateToolkit
framework: Articulate::FrameworkAdapter::Dancer1
caching: Articulate::Caching::Native
examples/plain-speaking/lib/PlainSpeaking/Routes/BlogContent.pm view on Meta::CPAN
my $self = shift;
my $request = shift;
my $article_id = $request->params->{'article_id'};
$self->service->process_request(
edit_form => {
location => "zone/$zone_id/article/$article_id",
}
);
};
get '/upload' => sub {
my $self = shift;
my $request = shift;
$self->service->process_request(
upload_form => {
location => "assets/images",
}
);
};
post '/upload' => sub {
my $self = shift;
my $request = shift;
my $image_id = $request->params->{'image_id'};
my $title = $request->params->{'title'};
my $content = $self->framework->upload('image');
return $self->service->process_request(
error => {
simple_message => 'Parameter image_id is required'
}
) unless defined $image_id and $image_id ne '';
my $location = "assets/images/image/$image_id";
my $response = $self->service->process_request(
create => {
location => $location,
content => $content,
lib/Articulate/File.pm view on Meta::CPAN
use overload '""' => sub { shift->_to_string };
=head1 NAME
Articulate::File - represent a file
=cut
=head1 DESCRIPTION
This represents a binary blob of content which is uploaded as a file
and should ideally be moved straight into the database rather than
loaded into memory.
It may also in future be used to represent files on the way out. The
interface is currently unstable as it is largely copied from Dancer's
file handling and is written to 'what works'.
=head1 ATTRIBUTES
=cut
lib/Articulate/Service/SimpleForms.pm view on Meta::CPAN
location => new_location $location, # as string or arrayref?
},
};
}
else {
throw_error Forbidden => $permission->reason;
}
}
sub handle_upload_form {
my $self = shift;
my $request = shift;
my $user = $request->user_id;
my $location = new_location $request->data->{location};
my $permission = $self->authorisation->permitted( $user, write => $location );
if ($permission) {
return new_response 'form/upload', {
form => {
location => new_location $location, # as string or arrayref?
},
};
}
else {
throw_error Forbidden => $permission->reason;
}
}
lib/Articulate/Storage/Local.pm view on Meta::CPAN
}
=head3 set_content
$storage->set_content('zone/public/article/hello-world', $blob);
Places content at that location.
=cut
sub _is_upload {
my $content = shift;
return ( blessed $content and $content->isa('Articulate::File') )
; # todo: have this wrapped by an articulate class which interfaces with the FrameworkAdapter
}
sub _write_data {
my ( $content, $fn ) = @_;
open my $fh, '>', $fn
or throw_error Internal => "Cannot open file $fn to write";
print $fh $content;
close $fh;
}
sub _copy_upload {
my ( $content, $fn ) = @_;
my $content_fh = $content->io;
local $/;
open my $fh, '>', $fn
or throw_error Internal => "Cannot open file $fn to write";
binmode $fh, ':raw';
print $fn while <$content_fh>;
close $fh;
}
sub _write_content {
my ( $content, $fn ) = @_;
$content //= '';
if ( _is_upload($content) ) {
_copy_upload( $content, $fn );
}
else {
_write_data( $content, $fn );
}
}
sub set_content {
my $self = shift;
my $item = shift;
my $location = $item->location;
lib/Articulate/Syntax/Routes.pm view on Meta::CPAN
use strict;
use warnings;
# use Dancer qw(:syntax);
use Exporter::Declare;
use Articulate::Service;
default_exports qw(
any get post patch del put options
);
# request upload uploads captures param params splat
# config var session template
# redirect forward halt pass send_error status
# ); # the first line will stay, everything else will find its way into framework
no warnings 'redefine';
sub on_enable {
my $code = shift;
my ($pkg) = caller(2);
my $routes = "${pkg}::__routes";
( run in 4.088 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )