Mounter.pm 937 Bytes
Newer Older
Luc Didry's avatar
Luc Didry committed
1 2 3 4 5 6 7 8 9
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;

Luc Didry's avatar
Luc Didry committed
10 11
    push @{$self->commands->namespaces}, 'Lstu::Command';

Luc Didry's avatar
Luc Didry committed
12 13 14 15
    my $config = $self->plugin('Config' =>
        {
            file    => File::Spec->catfile($Bin, '..' ,'lstu.conf'),
            default => {
Luc Didry's avatar
Luc Didry committed
16 17
                prefix => '/',
                theme  => 'default',
Luc Didry's avatar
Luc Didry committed
18 19 20 21
            }
        }
    );

Luc Didry's avatar
Luc Didry committed
22 23 24 25 26 27 28 29
    # Themes handling
    shift @{$self->static->paths};
    if ($config->{theme} ne 'default') {
        my $theme = $self->home->rel_dir('themes/'.$config->{theme});
        push @{$self->static->paths}, $theme.'/public' if -d $theme.'/public';
    }
    push @{$self->static->paths}, $self->home->rel_dir('themes/default/public');

Luc Didry's avatar
Luc Didry committed
30 31 32 33
    $self->plugin('Mount' => {$config->{prefix} => File::Spec->catfile($Bin, '..', 'script', 'application')});
}

1;