3 use Plack
::App
::Directory
;
10 my $client_id = $env->{'REMOTE_ADDR'};
14 [ 'Content-Type' => 'text/plain' ],
15 [ "Your IP address is ${client_id}." ], # or IO::Handle-like object
19 my $debug_hider = sub {
23 Plack
::Util
::response_cb
($app->($env), sub {
25 my $headers = Plack
::Util
::headers
($res->[1]);
26 if ( ! Plack
::Util
::status_with_no_entity_body
($res->[0])
27 && ($headers->get('Content-Type') || '') =~ m!^(?:text/html|application/xhtml\+xml)!) {
31 /* Only show Debug middleware on the "middleware-debug" slide. */
32 slideshow.on('showSlide', function (slide) {
33 if (slide.properties.name === 'middleware-debug') {
34 document.getElementById('plDebug').style.display = 'block';
37 slideshow
.on
('hideSlide', function
(slide
) {
38 document
.getElementById
('plDebug').style
.display
= 'none';
40 document
.getElementById
('plDebug').style
.display
= 'none';
46 return unless defined $chunk;
47 $chunk =~ s!(?=</body>)!$content!i;
59 mount
'/myip' => $sample_app;
61 mount
'/css' => Plack
::App
::Directory-
>new(root
=> 'css')->to_app;
62 mount
'/img' => Plack
::App
::Directory-
>new(root
=> 'img')->to_app;
63 mount
'/js' => Plack
::App
::Directory-
>new(root
=> 'js')->to_app;
64 mount
'/remark.min.js' => Plack
::App
::File-
>new(file
=> 'remark.min.js')->to_app;
65 mount
'/' => Plack
::App
::File-
>new(file
=> 'slides-offline.html')->to_app;