summaryrefslogtreecommitdiffstats
path: root/lib/Narwhal.pm
blob: 333ba893149040e1c7999795a427893248913c0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package Narwhal;
use OX;
use Narwhal::RouteBuilder::HTTPMethod;

with 'OX::Role::WithAppRoot';

config kioku_dsn => 'dbi:SQLite:narwhal.db';
config kioku_extra_args => sub { { create => 1 } };
config template_root => sub {
    shift->param('app_root')->subdir('root', 'templates')
}, (app_root => depends_on('/app_root'));

component Redirect => 'Narwhal::Component::Redirect';

component WikiPage => 'Narwhal::Component::Wiki::Page', (
    kioku => depends_on('/Component/Kioku'),
    tt    => depends_on('/Component/TT'),
);

component WikiEdit => 'Narwhal::Component::Wiki::Edit', (
    kioku => depends_on('/Component/Kioku'),
    tt    => depends_on('/Component/TT'),
);

# turn these two into specialized classes later
component TT => 'OX::View::TT', (
    template_root => depends_on('/Config/template_root'),
);

component Kioku => 'KiokuX::Model', (
    dsn        => depends_on('/Config/kioku_dsn'),
    extra_args => depends_on('/Config/kioku_extra_args'),
);

router as {
    route '/' => 'redirect.permanent', (
        to => '/page/main',
    );
    route '/page/:page_name' => 'page', (
        page_name => { isa => 'Str' },
    );
    route '/edit/:page_name' => 'edit', (
        page_name => { isa => 'Str' },
    );
}, (
    redirect => depends_on('/Component/Redirect'),
    page     => depends_on('/Component/WikiPage'),
    edit     => depends_on('/Component/WikiEdit'),
);

no OX;
1;