Plack-Middleware-BasicStyle

 view release on metacpan or  search on metacpan

lib/Plack/Middleware/BasicStyle.pm  view on Meta::CPAN

      font-size:18px;
      color:#444;
      padding:0 10px
    }

    h1,h2,h3 {
      line-height:1.2
    }
  </style>

The middleware takes the following arguments:

=over

=item B<style>

This is the HTML fragment that will be added to unstyled pages.

It defaults to the value of
C<< $Plack::Middleware::BasicStyle::DEFAULT_STYLE >>.

=item B<any_content_type>

If true, don't check whether Content-Type contains C<text/html>.

If false (default), passes the response through unchanged if the
Content-Type header is unset or does not contain the case-insensitive
substring C<text/html>.

=item B<even_if_styled>

If true, don't check whether the response already includes a <style>
or <link ... rel="stylesheet"> element.

If false (default), passes the response through unchanged if the
response includes a <style> or <link ... rel="stylesheet"> element.

=item B<use_link_header>

If false or unset (default), the given HTML fragment will be added
right after the <head> start tag (if this exists), right after the
<html> start tag (if this exists but <head> doesn't), or at the
beginning of the document (if neither <html> nor <head> exists).

If set, its value is interpreted as an URL path. The body of the
response will not be modified, instead a C<Link:> HTTP header will be
added to unstyled pages. Additionally, the middleware will intercept
requests to that exact URL path and return the style (with status 200,
a Content-Type of C<text/css>, a correct Content-Length header, and a
Cache-Control header instructing the browser to cache the style for 30
days).

Setting this makes the module more resilient to bugs and more
efficient at the cost of asking the client to make an extra request.
Therefore setting this argument is B<recommended>.

=back

=head1 CAVEATS

This middleware only works with simple (non-streaming) responses,
where the body is an arrayref.

In other words, responses where the body is an IO::Handle, or
streaming/delayed responses are NOT supported and will be passed
through unchanged by this middleware.

=head1 SEE ALSO

L<http://bettermotherfuckingwebsite.com>

=head1 AUTHOR

Marius Gavrilescu, E<lt>marius@ieval.roE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2016-2017 by Marius Gavrilescu

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.24.0 or,
at your option, any later version of Perl 5 you may have available.


=cut



( run in 0.645 second using v1.01-cache-2.11-cpan-d7f47b0818f )