#!/usr/bin/perl
use strict;
use warnings;
use utf8;
my $home = app->home;
my $mode = app->mode;
#This is the default Ado (Mojolicious) application configuration file.
#Application instance is also available here via "app" Mojolicious specific keyword.
#The operating mode for your application, defaults to a value
#from the MOJO_MODE and PLACK_ENV environment variables or 'development'.
#See http://localhost:3000/perldoc/Mojolicious/#mode
#Uncomment the line below to change it to 'production'.
#app->mode('production');
#Fallback to some default secret for this deployment
#See http://localhost:3000/perldoc/Mojolicious#secrets
app->secrets([Mojo::Util::sha1_sum(app->mode . $home),]);
#Application/site specific templates
#See http://localhost:3000/perldoc/Mojolicious/Renderer#paths
unshift @{app->renderer->paths}, $home->rel_dir('site_templates');
#Application specific static files
#See http://localhost:3000/perldoc/Mojolicious/Static
#It is better to leave static files to be served by a server like Apache
#This setting can be used during development.
#unshift @{$app->static->paths}, app->home->rel_dir('path/to/other/public/files');
#Setting the Controller class from which all conthrollers must inherit.
#See http://localhost:3000/perldoc/Mojolicious/#controller_class
#See http://localhost:3000/perldoc/Mojolicious/Guides/Growing#Controller_class
app->controller_class('Ado::Control');
#Namespace(s) to load controllers from
#See http://localhost:3000/perldoc/Mojolicious#routes
#See
app->routes->namespaces(['Ado::Control']);
#Namespaces to load plugins from
#See http://localhost:3000/perldoc/Mojolicious#plugins
#See http://localhost:3000/perldoc/Mojolicious/Plugins#PLUGINS
app->plugins->namespaces(['Mojolicious::Plugin', 'Ado::Plugin',]);
#Ado namespace to load commands from
#See http://localhost:3000/perldoc/Mojolicious/#commands
#See http://localhost:3000/perldoc/Ado/Command
unshift @{app->commands->namespaces}, 'Ado::Command';
# Add custom MIME type
#See http://localhost:3000/perldoc/Mojolicious/#types
#app->types->type(twt => 'text/tweet');
my $config = {
session => {
#Type of the session this application will use
#Possible values are:
# 'file'(Ado::Sessions::File),
# 'database'(Ado::Sessions::Database),
# 'mojo'(Mojolicious::Sessions)
type => 'database',
#Every sessions implementations has its own options
options => {
cookie_name => 'ado',
default_expiration => 86400,
}
},
#Plugins can be Mojolicious and Ado plugins.
# Every Ado::Plugin:: ISA Mojolicious::Plugin
#Plugin order is important. Any plugin depending on another
# must come after the plugin it depends on so it is already loaded.
#A plugin may be loaded twice if it will do different
# things depending on configuration variables.
# See localhost:3000/perldoc/Mojolicious/Plugin/DSC
#If loaded twice Mojolicious::Plugin::DSC can connect to different databases
# and provide different dbix_helper for each connection.
#See http://localhost:3000/perldoc/Ado#load_plugins
plugins => [
{name => 'charset', config => {charset => 'UTF-8'}},
{ name => 'DSC',
config => {
database => (
-e $home->rel_file("etc/ado.$mode.sqlite")
? $home->rel_file("etc/ado.$mode.sqlite")
: $home->rel_file('etc/ado.sqlite')
),
dbh_attributes => {sqlite_unicode => 1},
driver => 'SQLite',
namespace => 'Ado::Model',
onconnect_do => [
#http://www.sqlite.org/pragma.html
'PRAGMA encoding = "UTF-8"',
'PRAGMA foreign_keys = ON',
'PRAGMA temp_store = 2', #MEMORY
#http://www.sqlite.org/lang_vacuum.html
#'VACUUM',
],
DEBUG => 0,
},
},
'ado_helpers',
#see etc/plugins/routes.conf
#{name => 'routes', config => {}},
'routes',
'markdown_renderer',
'auth',
],
#Configuration for commands
#Every Ado::Command:: ISA Mojolicious::Command
commands => {
},
#Routes order is important, so this configuration value is an ARRAYREF
#Routes added by plugins will be created before these routes here.
routes => [
{ route => '/',
via => [qw(GET OPTIONS)],
#Ado::Control::Default::index()
to => 'default#index',
},
# Normal UTF-8 route to template - used to check if app is alive.
#See
#http://localhost:3000/perldoc/Mojolicious/Guides/Routing#More_convenient_routes
#See http:/localhost:3000/perldoc/Ado#load_routes
#Note!: Put your specific routes sharing the same pattern like generic ones
#before the generic ones!
#e.g. /добре/ок before /:controler/:action
{ route => '/добре/ок/:foo',
via => [qw(GET)],
params => {foo => qr/нещо/i,},
to => {template => '/добре/ок'}
},
{ route => '/добре/ок',
via => [qw(GET)],
to => {template => '/добре/ок'}
},
#Automatically dispatching to the special stash values
#'controller' and 'action', trying to match a class and a method
#http://localhost:3000/perldoc/Mojolicious/Guides/Routing#Stash
#http://localhost:3000/perldoc/Mojolicious/Guides/Routing#Special_stash_values
#Back-office (administration and employess) controllers
{ route => '/ado',
via => [qw(GET POST PUT OPTIONS)],
#Ado::Control::Ado::Default
to => 'ado-default#index'
},
#Any front-end controllers
{ route => '/:controller',
via => [qw(GET OPTIONS)],
to => {
#Ado::Control::Default
controller => 'Default',
action => 'index'
}
},
{ route => '/:controller/:action',
via => [qw(GET POST OPTIONS)],
to => {
#Ado::Control::Default
controller => 'Default',
action => 'index'
}
},
{ route => '/:controller/:action/:id',
via => [qw(GET PUT DELETE OPTIONS)],
to => {
#Ado::Control::Default
controller => 'Default',
action => 'form'
}
},
# This route will not be considered at all
{'index' => undef},
], #end routes
};
#Do not remove the line below.
#[CONFIG]
return $config;