plack-middleware-autoreloadcss
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Enables CSS Refreshing without Reloading Whole Page
package Plack::Middleware::AutoReloadCSS;
use 5.008;
use strict;
use warnings;

use Plack::Util ();
use Plack::Util::Accessor qw(interval);

use parent qw(Plack::Middleware);
our $VERSION = '0.02';

sub call {
    my($self, $env) = @_;

    $self->response_cb($self->app->($env), sub {
        my $res          = shift;
        my $content_type = Plack::Util::header_get($res->[1], 'Content-Type');

        if (!Plack::Util::status_with_no_entity_body($res->[0]) &&
            (($content_type || '') =~ m{^(?:text/html|application/xhtml\+xml)})) {
            return sub {
                my $chunk = shift;
                return if !defined $chunk;

                $chunk =~ s{}{$self->auto_reload_script . ''}ei;
                $chunk;
            }
        }
    });
}

sub auto_reload_script {
    my $self     = shift;
    my $interval = defined $self->interval ? $self->interval : 1000;

    return <<"SCRIPT";

SCRIPT
}

1;
__END__

=encoding utf8

=head1 NAME

Plack::Middleware::AutoReloadCSS - Enables CSS Refreshing without
Reloading Whole Page

=head1 SYNOPSIS

  # in your app.psgi
  enable 'AutoReloadCSS', interval => 1000;

=head1 DESCRIPTION

Plack::Middleware::AutoReloadCSS automatically inserts some JavaScript
snippets to enable CSS refreshing feature without reloading whole
page.

=head1 AUTHOR

=over 4

=item * Kentaro Kuribayashi Ekentarok@gmail.comE

=item * Nikita Vasilyev

CSS auto-reload is borrowed from
L

=back

=head1 LICENSE

Copyright (C) Kentaro Kuribayashi

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。