| package Korap; | 
 | use Mojo::Base 'Mojolicious'; | 
 | use Mojo::ByteStream 'b'; | 
 |  | 
 | our $VERSION = '0.07'; | 
 |  | 
 | # Start dev with | 
 | # morbo -w lib -w templates -w public/sass -w public/js -w public/css script/korap | 
 | # morbo -m test -w lib -w templates -w public/sass -w public/js -w public/css script/korap | 
 |  | 
 | # Start the application and register all routes and plugins | 
 | sub startup { | 
 |   my $self = shift; | 
 |  | 
 |   $self->defaults(layout => 'default'); | 
 |  | 
 |   # Set secret for signed cookies | 
 |   $self->secrets(['fmhsfjgfchgsdbfgshfxztsbt32477eb45veu4vubrghfgghbtv']); | 
 |  | 
 |   # Add additional plugin path | 
 |   push(@{$self->plugins->namespaces}, __PACKAGE__ . '::Plugin'); | 
 |  | 
 |   # Load plugins | 
 |   foreach (qw/Config | 
 | 	      CHI | 
 | 	      TagHelpers::Pagination | 
 | 	      Notifications | 
 | 	      Number::Commify | 
 | 	      KorapSearch | 
 | 	      KorapInfo | 
 | 	      KorapTagHelpers | 
 | 	     /) { | 
 |     # Oro::Account | 
 |     # Oro::Account::ConfirmMail | 
 |     $self->plugin($_); | 
 |   }; | 
 |  | 
 |   $self->plugin(AssetPack => { minify => 1 }); | 
 |   $self->plugin('AssetPack::LibSass'); | 
 |   $self->plugin('MailException' => $self->config('MailException')); | 
 |  | 
 |   # Add assets for AssetPack | 
 |   $self->asset( | 
 |     'korap.css' => ( | 
 |       '/sass/style.scss', | 
 |       '/sass/sidebar.scss', | 
 |       '/sass/tutorial.scss', | 
 |       '/sass/hint.scss', | 
 |       '/sass/query.scss', | 
 |       '/sass/matchinfo.scss', | 
 |       '/sass/pagination.scss', | 
 |       '/sass/kwic-4.0.scss', | 
 |       '/css/media.css', | 
 |       '/css/font-awesome.min.css', | 
 |       '/css/highlight.css', | 
 |       '/sass/alertify.scss', | 
 |       $self->notifications->styles | 
 |     ) | 
 |   ); | 
 |  | 
 |   $self->asset( | 
 |     'korap.js' => ( | 
 | #      '/js/d3.v3.min.js', | 
 | #      '/js/dagre-d3.min.js', | 
 |       '/js/jquery-2.0.0.min.js', | 
 |       '/js/tutorialCookie.js', | 
 |       '/js/translateTable.js', | 
 | #      '/js/translateTree.js', | 
 |       '/js/hint.js', | 
 |       '/js/highlight.pack.js', | 
 |       $self->notifications->scripts | 
 |     ) | 
 |   ); | 
 |  | 
 |   $self->helper( | 
 |     date_format => sub { | 
 |       my ($c, $date) = @_; | 
 |       return $date; | 
 |     } | 
 |   ); | 
 |  | 
 |   # Routes | 
 |   my $r = $self->routes; | 
 |  | 
 |   # User account management | 
 |   #  $r->route('/login')->acct('login'); | 
 |   #  $r->route('/login/forgotten')->acct('forgotten'); | 
 |   #  $r->route('/login/remove')->acct('remove'); | 
 |   #  $r->route('/register')->acct('register'); | 
 |   #  $r->route('/logout')->acct('logout'); | 
 |   #  $r->route('/preferences')->acct('preferences'); | 
 |  | 
 |   # Base search route | 
 |   $r->get('/')->to('search#remote')->name('index'); | 
 |  | 
 |   # Tutorial data | 
 |   $r->get('/tutorial')->to('tutorial#page', tutorial => 'index'); | 
 |   $r->get('/tutorial/(*tutorial)')->to('tutorial#page')->name('tutorial'); | 
 |  | 
 |   # Collection data | 
 |   my $collection = $r->bridge('/collection'); | 
 |   $collection->to('info#about_collection'); | 
 |   my $collection_id = $collection->bridge('/:collection_id'); | 
 |   # stats | 
 |   # $collection_id->; | 
 |   $collection_id->search; | 
 |  | 
 |   # Corpus data | 
 |   my $corpus_res = $r->route('/corpus'); | 
 |   my $corpus = $corpus_res->route('/:corpus_id'); | 
 |   # Todo: Stats | 
 |   $corpus->search->name('search_corpus'); | 
 |   my $doc = $corpus->route('/#doc_id'); | 
 |   $doc->search->name('search_document'); | 
 |  | 
 |   # Match data | 
 |   my $match = $doc->route('/:match_id'); | 
 |   $match->route->to('info#about_match')->name('match'); | 
 | #  my $match_foundry = $match->route('/:foundry'); | 
 | #  $match_foundry->route->to('info#about_match'); | 
 | #  $match_foundry->route('/:layer')->to('info#about_match'); | 
 |  | 
 |   # Utilities | 
 |   # $r->get('/util/query')->to('search#query'); | 
 | }; | 
 |  | 
 |  | 
 | 1; |