Ado
view release on metacpan or search on metacpan
lib/Ado/Manual/Plugins.pod view on Meta::CPAN
=back
The following plugins are written by me and are distributed separately. You can
install and use them in your application. Please help make them better.
=over
=item * L<Ado::Plugin::Admin> - system (site) administration user interface.
=item * L<Ado::Plugin::Site> - Manage your Sites.
=item * L<Ado::Plugin::Vest> - Messaging services for an Ado system!
=back
Do not hesitate to contact the Ado team and request your plugin to be added
to the above list.
=head1 WRITING A PLUGIN
There is I<almost> nothing special about writing an L<Ado::Plugin>. The only
difference between Ado and Mojolicious plugins is that Ado plugins can
retrieve their settings from their own configuration files.
The configuration file must be named after the respective plugin. A plugin
Ado::Plugin::Hello (when installed) will search its configuration in
C<app-E<gt>home-E<gt>rel_dir('etc/plugins/hello.conf')>. depending on the
current mode (C<$ENV{MOJO_MODE}>). The file
C<app-E<gt>home-E<gt>rel_dir('etc/plugins/hello.$ENV{MOJO_MODE}.conf')> will
also be loaded and will override all settings from
C<app-E<gt>home-E<gt>rel_dir('etc/plugins/hello.conf')>. The file must return
a HASHREF. See the code of the listed plugins below for examples of how and
what can be done in a plugin.
To create your own plugin do the following (Example):
=over
=item * Create one or more tables to be used by your plugin in C<etc/ado.sqlite>
CREATE TABLE blog (
id INTEGER PRIMARY KEY,
title VARCHAR NOT NULL UNIQUE,
body TEXT NOT NULL,
published BOOL DEFAULT '0',
deleted BOOL NOT NULL DEFAULT '0',
user_id INTEGER REFERENCES users(id),
group_id INTEGER REFERENCES groups(id),
permissions VARCHAR(10) DEFAULT '-rwxr-xr-xr'
);
CREATE INDEX blog_published ON blog(published);
CREATE INDEX blog_deleted ON blog(deleted);
=item * Add some dummy records.
INSERT INTO blog(title,body,user_id,group_id)
VALUES('Hey','Hello world',3,3);
INSERT INTO blog(title,body,user_id,group_id)
VALUES('Hey You','Hello Universe',3,3);
=item * Generate the files for the plugin. These are the files which you will edit :).
$ cd ~/opt/public_dev
$ ado generate adoplugin -n Blog --crud -t blog
The above command will generate the needed files for an ado plugin which can
even be uploaded to and subsequently downloaded from
L<CPAN|http://www.cpan.org/>. L<CPAN> is the best open source dependency
management system. You can also use L<Stratopan|https://stratopan.com/> if you
wish.
=back
Ado uses L<Ado::Build> and L<Ado::BuildPlugin> which extend L<Module::Build>.
They were created to add some custom actions and handle the additional
C<templates>,C<log> and C<public> directories in Ado root folder.
The file tree looks like the following:
~/opt/public_dev/Ado-Plugin-Blog$ tree
.
âââ Build.PL
âââ etc
â  âââ plugins
â  âââ blog.conf
âââ lib
â  âââ Ado
â  âââ Control
â  â  âââ Blog.pm
â  âââ Plugin
â  âââ Blog.pm
âââ templates
â  âââ blog
â  âââ create.html.ep
â  âââ delete.html.ep
â  âââ list.html.ep
â  âââ read.html.ep
âââ t
âââ plugin
âââ blog-00.t
No worries, your plugin has everything needed to be installed from CPAN.
L<Ado::Plugin::Vest> was started using this command.
L<Ado> can be stripped down to a bare Mojolicious application by not loading
any plugins. And L<Ado> can be extended I<infinitely> just by adding helpers,
conditions, routes, templates and injecting code into hooks from plugins.
I<This is true for any Mojolicious application.>
=head1 SPONSORS
The original author
=head1 SEE ALSO
L<Mojolicious::Plugins>, L<Mojolicious::Plugin>,
=head1 AUTHOR
( run in 0.927 second using v1.01-cache-2.11-cpan-5837b0d9d2c )