blob: 5d2cde068a6873c397984a16403eb0da84094138 [file] [log] [blame]
Nils Diewald5d1ffb42014-05-21 17:45:34 +00001package Korap;
2use Mojo::Base 'Mojolicious';
3
4# This method will run once at server start
5sub startup {
6 my $self = shift;
7
8 $self->plugin('Config');
9 $self->plugin('TagHelpers::Pagination');
10
11 push(@{$self->plugins->namespaces}, __PACKAGE__ . '::Plugin');
12 $self->plugin('KorapSearch');
13 $self->plugin('Notifications' => {
14 use => 'Humane'
15 });
16
17 $self->helper(
18 format_thousands => sub {
19 shift;
20 my ($n, @array) = @_;
21 while ($n =~ /\d\d\d\d/) {
22 $n =~ s/(\d\d\d)$//;
23 unshift @array, $1;
24 };
25 unshift @array, $n;
26 return join ',', @array;
27 }
28 );
29
30
31 # Router
32 my $r = $self->routes;
33
34 $r->add_shortcut(
35 search => sub {
36 shift->get('/search')->to('search#remote')
37 }
38 );
39
40# , resource => [qw/collection corpus/]
41 $r->get('/:resource')->search;
42 $r->get('/:resource/:cid', resource => [qw/collection corpus/])->search;
43 $r->get('/:resource/')->search;
44
45 # /matchInfo?id=...&f=&l=&spans
46}
47
481;