1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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 $p = params();
-
- &helper::dmup (ENV => \%ENV);
- &helper::dmup (params => scalar params);
- &helper::dmup (config => config);
-
- 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(scalar params);
-
- template 'st', {
- st_headers => $s->head(),
- content => $s->body(),
- warnings => $s->warnings()
- }, { layout => $format };
- };
-
- get '/' => sub {
- template 'index';
- };
-
- true;
|