NAME
Slovo - В началѣ бѣ Слово
SYNOPSIS
Mojolicious::Commands->start_app('Slovo');
DESCRIPTION
This is a very early pre-pre-release! Slovo is a simple, installable and extensible Mojolicious CMS.
INSTALL
All you need is a one-liner, it takes less than a minute.
$ curl -L https://cpanmin.us | perl - -M https://cpan.metacpan.org -n -l ~/opt/slovo Slovo
We recommend the use of a Perlbrew environment.
If you already downloaded it and you have cpanm.
$ cpanm -l ~/opt/slovo Slovo-XXXX.XX.XX.tar.gz
Or even if you don't have cpanm
.
tar zxf Slovo-XXXX.XX.XX.tar.gz
cd Slovo-XXXX.XX.XX
perl Makefile.PL INSTALL_BASE=~/opt/slovo && make && make test && make install
USAGE
cd /path/to/installed/slovo
# see various options
./bin/slovo
CONFIGURATION, PATHS and UPGRADING
Slovo is a Mojolicious application which means that everything applying to Mojolicious applies to it too. Slovo main configuration file is in lib/Slovo/resourses/etc/slovo.conf
. You can use your own by setting $ENV{MOJO_CONFIG}
. New routes can be described in routes.conf
. See Mojolicious::Plugin::RoutesConfig for details and examples.
$ENV{MOJO_HOME}
(where you installed Slovo) is automatically detected and used. All paths, used in the application, then are expected to be its children. You can add your own templates in $ENV{MOJO_HOME}/templates
and they will be loaded and used with priority. You can theme your own instance of Slovo by just copying $ENV{MOJO_HOME}/lib/Slovo/resources/templates
to $ENV{MOJO_HOME}/templates
and modify them. You can add your own static files to $ENV{MOJO_HOME}/public
. Last but not least, you can add your own classes into $ENV{MOJO_HOME}/site/lib
and (why not) replace classes form Slovo.
With all the above, you can upgrade Slovo by just installing new versions over it and your files will not be touched. And of course, we know that you are using versioning just in case anything goes wrong.
ATTRIBUTES
Slovo inherits all attributes from Mojolicious and implements the following new ones.
resources
push @{$app->static->paths}, $app->resources->child('public');
Returns a Mojo::File instance for path "resources" in Slovo next to where Slovo.pm
is installed.
validator
my $validator = $app->validator;
$app = $app->validator(Slovo::Validator->new);
Validate values, defaults to a Slovo::Validator object.
# Add validation check
$app->validator->add_check(foo => sub {
my ($v, $name, $value) = @_;
return $value ne 'foo';
});
# Add validation filter
$app->validator->add_filter(quotemeta => sub {
my ($v, $name, $value) = @_;
return quotemeta $value;
});
METHODS
Slovo inherits all methods from Mojolicious and implements the following new ones.
load_class
A convenient wrapper with check for "load_class" in Mojo::Loader. Loads a class and croaks if something is wrong. This could be a helper.
startup
my $app = Slovo->new->startup;
Starts the application, sets defaults, reads configuration file(s) and returns the application instance.
HOOKS
Slovo adds custom code to the following hooks.
before_dispatch
On each request we check if we have logged in user and set the current user to guest
if we don't. This way every part of the application (including newly developped plugins) can count on having a current user. The user is available as $c->user
.
HELPERS
Slovo implements the following helpers.
is_user_authenticated
We replaced the implementation of this helper, provided otherwise by "is_user_authenticated" in Mojolicious::Plugin::Authentication. Now we check if the user is not guest
instead of checking if we have a loaded user all over the place. This was needed because we wanted to always have a default user. See "before_dispatch". Now we have default user properties even if there is not a logged in user. This will be the guest
user.
Once again: Now this helper returns true if the current user is not Guest, false otherwise.
%# in a template
Hello <%= $c->user->{first_name} %>,
% if($c->is_user_authenticated) {
You can go and <%= link_to manage => url_for('under_management')%> some pages.
% else {
You may want to <%=link_to 'sign in' => url_for('sign_in') %>.
% }
BUGS
Please open issues at https://github.com/kberov/Slovo/issues.
SUPPORT
Please open issues at https://github.com/kberov/Slovo/issues.
AUTHOR
Красимир Беров
CPAN ID: BEROV
berov ат cpan точка org
http://i-can.eu
COPYRIGHT
This program is free software licensed under the Artistic License 2.0.
The full text of the license can be found in the LICENSE file included with this module.
TODO
Implement the site part – the one visible by the visitors of the siste, made with „Слово”.
Add simplemde-markdown-editor to the distro and use it to prepare markdown as html in the browser. (https://github.com/sparksuite/simplemde-markdown-editor) (https://github.com/Inscryb/inscryb-markdown-editor)
Consider addding also ContentTools as the default WYSIWIG html editor (https://github.com/GetmeUK/ContentTools)
Consider (preferred) using Mithril as frontend framework for building UI. (https://github.com/MithrilJS/mithril.js)
Consider using DataTables jQuery plugin for the administrative panel.