#!/usr/bin/perl -w use lib qw(/home/rendler/www/public /home/rendler/scripts /home/rendler/perl5/lib /home/rendler/perl5/lib/perl5); use Mojolicious::Lite -signatures; use Path::Iterator::Rule; use WWWDBI; use Tools; app->config( hypnotoad => { listen => [ 'http://127.0.0.1:8082/' ], proxy => 1, }, ); helper listFiles => sub { my $location = "public"; my $rule = Path::Iterator::Rule->new->not_dir->name(qr/(pm|pl|js|css)$/); my @files = $rule->all($location); return (sort {fc($a) cmp fc($b)} @files); }; get '/' => sub ($c) { $c->render(template => 'index'); }; get '/source' => sub ($c) { if ($c->param('f') =~ /^public\//) { my $text = source($c->param('f')); $c->render(text => $text, format => 'txt'); } else { $c->render(text => "Fuck off.", format => 'txt'); } }; get '/age' => sub ($c) { my $dob = WWWDBI->new()->dob(); my @andrea = howOld($dob->{andrea}->{dob}); my @nicky = howOld($dob->{nicky}->{dob}); $c->render( json => { andrea => $andrea[0], andreas => $andrea[1], nicky => $nicky[0], nickys => $nicky[1], }); }; get '/copy' => sub ($c) { my @msgs= WWWDBI->new()->getPasted(); $c->stash(messages => \@msgs); $c->render(template => 'copy'); }; post '/copy' => sub ($c) { my $text = $c->param('paste'); return unless $text =~ /^[\w:\/\.\s]{1,250}$/; my $db = WWWDBI->new(); $db->paste($text); $db->pushOver($text); my @msgs = $db->getPasted(); $c->stash(messages => \@msgs); $c->render(template => 'copy'); }; get 'this.is.totally.not.sus' => sub ($c) { $c->render(template => 'sus'); }; app->start;