123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package SugarTrail;
- use Dancer2 ':syntax';
-
- use strict;
- use warnings;
-
- use SugarTrail::Repo;
- use Template;
- use helper;
-
- our $VERSION = '0.1';
-
- my $r = SugarTrail::Repo->new(
- root => config->{repo_root} // "t/data/strepo",
- vcs => config->{repo_vcs} // "git"
- );
-
-
- get qr|^/st/([^\?]*)(.*)$| => sub {
-
- my $params = request->params('query');
-
- &helper::dmup (ENV => \%ENV);
- &helper::dmup (real_params => $params);
-
- my ($stpath, $query) = splat;
- my $format = $params->{__format} // 'plain';
- header('Content-Type' => (
- $format eq 'html' ? 'text/html' : 'text/plain'
- ));
-
- my $m = $r->load_master( source => "/$stpath.stm" )
- or return template 'not_found';
- my $s = $m->generate_slave($params);
-
- &helper::dmup(m=>$m);
- &helper::dmup(s=>$s);
- my $w = $s->warnings();
- &helper::dmup(w=>$w);
-
- template $format, {
- head => $s->head(),
- body => $s->body(),
- warnings => $s->warnings(),
- Name => $m->{meta}->{Name},
- Owner => $m->{meta}->{Owner},
- Master => $s->{meta}->{Master},
- MasterRevision => $s->{meta}->{'Master Revision'},
- Params => $s->{meta}->{Params}
- }, { layout => $format };
- };
-
- get '/' => sub {
- template 'index';
- };
-
- true;
|