1234567891011121314151617181920212223242526272829303132333435
  1. package SugarTrail;
  2. use Dancer ':syntax';
  3. use SugarTrail::Repo;
  4. use helper;
  5. use URL::Encode qw/ url_decode /;
  6. our $VERSION = '0.1';
  7. my $repo_root = '/srv/strail/strepo';
  8. my $repo_vcs = 'git';
  9. my $repo = SugarTrail::Repo->new( root => $repo_root, vcs=> $repo_vcs );
  10. get qr{(/[^\?]*)} => sub {
  11. my ($stm) = split '\?', $ENV{REQUEST_URI}, 2;
  12. $stm = url_decode($stm);
  13. my $m = $repo->load_stm( stm => $stm . '.stm' );
  14. unless ($m) {
  15. return template 'not_found';
  16. }
  17. my $params = params();
  18. my $s = $m->generate_slave($params);
  19. &helper::dmup(params=>$params);
  20. return '<pre>' . $s->source . '</pre>';
  21. };
  22. true;