| 1 | # | ||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||
| 3 | # | ||
| 4 | # vim: set ts=2 sw=2 tw=0: | ||
| 5 | # vim: set expandtab: | ||
| 6 | |||
| 7 | package Rex::Repositorio::Server::Yum; | ||
| 8 | |||
| 9 | use Mojo::Base 'Mojolicious'; | ||
| 10 | use Data::Dumper; | ||
| 11 | use JSON::XS; | ||
| 12 | use File::Spec; | ||
| 13 | use Params::Validate qw(:all); | ||
| 14 | use File::Basename 'dirname'; | ||
| 15 | use File::Spec::Functions 'catdir'; | ||
| 16 | |||
| 17 | our $VERSION = '1.2.1'; # VERSION | ||
| 18 | |||
| 19 | # This method will run once at server start | ||
| 20 | sub startup { | ||
| 21 | my $self = shift; | ||
| 22 | |||
| 23 | $self->plugin("Rex::Repositorio::Server::Helper::Common"); | ||
| 24 | $self->plugin("Rex::Repositorio::Server::Helper::Proxy"); | ||
| 25 | |||
| 26 | $self->app->log( | ||
| 27 | Mojo::Log->new( | ||
| 28 | level => 'debug', | ||
| 29 | ) | ||
| 30 | ); | ||
| 31 | |||
| 32 | $self->plugin("Rex::Repositorio::Server::Helper::RenderFile"); | ||
| 33 | |||
| 34 | my $r = $self->routes; | ||
| 35 | $r->get('/')->to('file#index'); | ||
| 36 | $r->get('/:tag')->to('file#index'); | ||
| 37 | $r->get('/:tag/:repo/errata')->to('errata#query'); | ||
| 38 | $r->get('/*')->to('file#serve'); | ||
| 39 | |||
| 40 | # Switch to installable home directory | ||
| 41 | $self->home->parse( catdir( dirname(__FILE__), 'Yum' ) ); | ||
| 42 | |||
| 43 | # Switch to installable "public" directory | ||
| 44 | $self->static->paths->[0] = $self->home->rel_dir('public'); | ||
| 45 | |||
| 46 | # Switch to installable "templates" directory | ||
| 47 | $self->renderer->paths->[0] = $self->home->rel_dir('templates'); | ||
| 48 | } | ||
| 49 | |||
| 50 | 1; |