Yancy

Yancy is a simple content management system (CMS) for administering
content in a database. Yancy accepts a configuration file that describes
the data in the database and builds a website that lists all of the
available data and allows a user to edit data, delete data, and add new
data.

Yancy uses JSON Schema <http://json-schema.org> to define the data in
the database. The schema is added to an OpenAPI specification
<http://openapis.org> which creates a REST API
<https://en.wikipedia.org/wiki/Representational_state_transfer> for your
data.

Yancy can be run in a standalone mode (which can be placed behind a
proxy), or can be embedded as a plugin into any application that uses
the Mojolicious web framework.

Yancy can manage data in multiple databases using different backends
(Yancy::Backend modules). Backends exist for Postgres via Mojo::Pg,
MySQL via Mojo::mysql, and DBIx::Class, a Perl ORM

  Standalone App

To run Yancy as a standalone application, you must create a "yancy.conf"
configuration file that defines how to connect to your database and what
the data inside looks like. See "CONFIGURATION" for details.

NOTE: Yancy does not have authentication or authorization built-in. If
you want to control which users have access to data, you should use an
HTTP proxy with these features.

Once the application is started, you can navigate to
"http://127.0.0.1:3000/admin" to see the Yancy administration app.
Navigate to "http://127.0.0.1:3000/" to see the getting started page.

   Rendering Content

In the standalone app, all paths besides the "/admin" application are
treated as paths to templates.

The templates are found in the "templates" directory. You can change the
root directory that contains the "templates" directory by setting the
"MOJO_HOME" environment variable.

Template names must end with ".format.ep" where "format" is the content
type ("html" is the default). You can render plain text ("txt"), JSON
("json"), XML ("xml"), and others.

Database content can be read by using the database helpers that Yancy
provides.

*   "yancy->list( $collection )" - Get a list of items

*   "yancy->get( $collection, $id )" - Get a single item

*   "yancy->set( $collection, $id, $data )" - Update an item

*   "yancy->delete( $collection, $id )" - Delete an item

*   "yancy->create( $collection, $data )" - Create an item

Some example template code:

    %# Get a list of people
    % my @people = app->yancy->list( 'people' );

    %# Show a list of people names 
    <ul>
        % for my $person ( @people ) {
            <li><%= $person->{name} %></li>
        % }
    </ul>

    %# Get a single person with ID 1
    % my $person = app->yancy->get( 'people', 1 );

    %# Write the person's name to the page
    <p>Hi, my name is <%= $person->{name} %>.</p>

More information about Mojolicious helpers is available at
Mojolicious::Guides::Rendering.

  Mojolicious Plugin

For information on how to use Yancy as a Mojolicious plugin, see
Mojolicious::Plugin::Yancy.

  REST API

This application creates a REST API using the standard OpenAPI
<http://openapis.org> API specification. The API spec document is
located at "/api" in the standalone app, and "/yancy/api" in the
Mojolicious plugin.

INSTALLATION

This is a Perl module distribution. It should be installed with whichever
tool you use to manage your installation of Perl, e.g. any of

  cpanm .
  cpan  .
  cpanp -i .

Consult http://www.cpan.org/modules/INSTALL.html for further instruction.
Should you wish to install this module manually, the procedure is

  perl Makefile.PL
  make
  make test
  make install

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 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.
