123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package SugarTrail;
- use Dancer ':syntax';
-
- use strict;
- use warnings;
-
- use SugarTrail::Repo;
- 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 (params => scalar params);
- &helper::dmup (config => config);
- &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);
-
- template 'st', {
- st_headers => $s->head(),
- content => $s->body(),
- warnings => $s->warnings()
- }, { layout => $format };
- };
-
- get '/' => sub {
- template 'index';
- };
-
- true;
|