Skip to content

Instantly share code, notes, and snippets.

Created September 18, 2017 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/73417fc11d1e270189a0d24e8c64adeb to your computer and use it in GitHub Desktop.
Save anonymous/73417fc11d1e270189a0d24e8c64adeb to your computer and use it in GitHub Desktop.
use v6;
use Bailador;
use HTTP::Server::Simple;
my $latest = 0; # latest post num
my @titles = []; # post titles
# scan for new posts
sub scan {
if !dir.contains('posts') { exit; say "Where's the 'posts' directory?";$
$latest = Int(+dir 'posts');
return if $latest == 0;
@titles = [];
loop (my $i = $latest; $i > 0; $i--) {
@titles[$latest - $i] = "posts/$i.html".IO.lines[0];
}
}
scan();
Supply.interval(360).tap: { scan(); }
get '/me' => sub {
template 'index.tm', @titles
}
get '/gnupg' => sub {
template 'gnupg.tm'
}
get / ^ '/blog/' (.+) $ / => sub ($post) {
template 'blog.tm',{ post => $post }
}
baile(8080);
** OUTPUT **
Cannot resolve caller AUTOGEN(Bailador::App: Int); none of these signatures match:
(Bailador::App $: *%_)
(Bailador::App $: Str $command, *@args, *%_)
in sub baile at /home/benji/.perl6/install/share/perl6/site/sources/6F33C03589936F3E254B5C14BC95945C77196A75 (Bailador) line 157
in block <unit> at app.pm6 line 33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment