DESCRIPTION

This plugin allows you to add a simple content management system (CMS) to administrate content on your Mojolicious site. This includes a JavaScript web application to edit the content and a REST API to help quickly build your own application.

A base route to add Yancy to. This allows you to customize the URL and add authentication or authorization. Defaults to allowing access to the Yancy web application under /yancy, and the REST API under /yancy/api.

return_to

The URL to use for the "Back to Application" link. Defaults to /.

filters

A hash of name => subref pairs of filters to make available. See "yancy.filter.add" for how to create a filter subroutine.

HELPERS

This plugin adds some helpers for use in routes, templates, and plugins.

yancy.config

my $config = $c->yancy->config;

The current configuration for Yancy. Through this, you can edit the collections configuration as needed.

yancy.backend

my $be = $c->yancy->backend;

Get the currently-configured Yancy backend object. See Yancy::Backend for the methods you can call on a backend object and their purpose.

yancy.route

Get the root route where the Yancy CMS will appear. Useful for adding authentication or authorization checks:

# All people named exactly 'Turanga Leela'
$c->yancy->list( people => { name => 'Turanga Leela' } );
# All people with "Wong" in their name
$c->yancy->list( people => { name => { like => '%Wong%' } } );

This helper will also filter out any password fields in the returned data. To get all the data, use the backend helper to access the backend methods directly.

yancy.get

my $item = $c->yancy->get( $collection, $id );

Get an item from the backend. $collection is the collection name. $id is the ID of the item to get. See "get" in Yancy::Backend.

This helper will filter out password values in the returned data. To get all the data, use the backend helper to access the backend directly.

yancy.set

$c->yancy->set( $collection, $id, $item_data, %opt );

Update an item in the backend. $collection is the collection name. $id is the ID of the item to update. $item_data is a hash of data to update. See "set" in Yancy::Backend. %opt is a list of options with the following keys:

properties - An arrayref of properties to validate, for partial updates

yancy.delete

Delete an item from the backend. $collection is the collection name. $id is the ID of the item to delete. See "delete" in Yancy::Backend.

yancy.validate

my @errors = $c->yancy->validate( $collection, $item, %opt );

Validate the given $item data against the configuration for the $collection. If there are any errors, they are returned as an array of JSON::Validator::Error objects. %opt is a list of options with the following keys:

properties - An arrayref of properties to validate, for partial updates

yancy.openapi

TEMPLATES

This plugin uses the following templates. To override these templates with your own theme, provide a template with the same name. Remember to add your template paths to the beginning of the list of paths to be sure your templates are found first:

This layout template surrounds all other Yancy templates. Like all Mojolicious layout templates, a replacement should use the content helper to display the page content. Additionally, a replacement should use content_for 'head' to add content to the head element.

yancy/index.html.ep

This is the main Yancy web application. You should not override this. If you need to, consider filing a bug report or feature request.

SEE ALSO

AUTHOR

Doug Bell <preaction@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Doug Bell.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Module Install Instructions

To install Mojolicious::Plugin::Yancy, simply copy and paste either of the commands in to your terminal

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.