package Mounter; use Mojo::Base 'Mojolicious'; use FindBin qw($Bin); use File::Spec qw(catfile); # This method will run once at server start sub startup { my $self = shift; push @{$self->commands->namespaces}, 'Lufi::Command'; my $cfile = Mojo::File->new($Bin, '..' , 'lufi.conf'); if (defined $ENV{MOJO_CONFIG}) { $cfile = Mojo::File->new($ENV{MOJO_CONFIG}); unless (-e $cfile->to_abs) { $cfile = Mojo::File->new($Bin, '..', $ENV{MOJO_CONFIG}); } } my $config = $self->plugin('Config' => { file => $cfile, default => { prefix => '/', theme => 'default', dbtype => 'sqlite', } } ); # Helpers $self->plugin('Lufi::Plugin::Helpers'); # Themes handling shift @{$self->static->paths}; if ($config->{theme} ne 'default') { my $theme = $self->home->rel_file('themes/'.$config->{theme}); push @{$self->static->paths}, $theme.'/public' if -d $theme.'/public'; } push @{$self->static->paths}, $self->home->rel_file('themes/default/public'); $self->plugin('Mount' => {$config->{prefix} => File::Spec->catfile($Bin, '..', 'script', 'application')}); } 1;