Catalyst-View-ContentNegotiation-XHTML

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    Catalyst::View::ContentNegotiation::XHTML - Adjusts the response
    Content-Type header to application/xhtml+xml if the browser accepts it.

SYNOPSIS
        package Catalyst::View::TT;

        use Moose;
        use namespace::clean -except => 'meta';

        extends qw/Catalyst::View::TT/;
        with qw/Catalyst::View::ContentNegotiation::XHTML/;

README  view on Meta::CPAN

    which do not properly support the "application/xhtml+xml" MIME type.

METHOD MODIFIERS
  after process
    Changes the response "Content-Type" if appropriate (from the requests
    "Accept" header).

METHODS
  pragmatic_accept
    Some browsers (such as Internet Explorer) have a nasty way of sending
    Accept */* and this claiming to support XHTML just as well as HTML.
    Saving to a file on disk or opening with another application does count
    as accepting, but it really should have a lower q value then text/html.
    This sub takes a pragmatic approach and corrects this mistake by
    modifying the Accept header before passing it to content negotiation.

ATTRIBUTES
  variants
    Returns an array ref of 3 part arrays, comprising name, priority, output
    mime-type, which is used for the content negotiation algorithm.

PRIVATE METHODS
  _build_variants
    Returns the default variant attribute contents.

SEE ALSO
    Catalyst::View::TT::XHTML - Trivial Catalyst TT view using this role.
    <http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html> - Content
    negotiation RFC.

BUGS
    Should be split into a base ContentNegotiation role which is consumed by
    ContentNegotiation::XHTML.

AUTHOR
    Maintainer and contributor of various features - David Dorward "<david@dorward.me.uk>"

lib/Catalyst/View/ContentNegotiation/XHTML.pm  view on Meta::CPAN

package Catalyst::View::ContentNegotiation::XHTML;

use Moose::Role;
use MooseX::Types::Moose qw/Num Str ArrayRef/;
use MooseX::Types::Structured qw/Tuple/;
use HTTP::Negotiate qw/choose/;

use namespace::clean -except => 'meta';

# Remember to bump $VERSION in View::TT::XHTML also.
our $VERSION = '1.103';

requires 'process';

has variants => (
    is      => 'ro',
    isa     => ArrayRef[Tuple[Str, Num, Str]],
    lazy    => 1,
    builder => '_build_variants',
);

lib/Catalyst/View/ContentNegotiation/XHTML.pm  view on Meta::CPAN

    }
    return $accept;
}

1;

__END__

=head1 NAME

Catalyst::View::ContentNegotiation::XHTML - Adjusts the response Content-Type
header to application/xhtml+xml if the browser accepts it.

=head1 SYNOPSIS

    package Catalyst::View::TT;

    use Moose;
    use namespace::clean -except => 'meta';

    extends qw/Catalyst::View::TT/;

lib/Catalyst/View/ContentNegotiation/XHTML.pm  view on Meta::CPAN

=head2 after process

Changes the response C<Content-Type> if appropriate (from the requests
C<Accept> header).

=head1 METHODS

=head2 pragmatic_accept

Some browsers (such as Internet Explorer) have a nasty way of sending Accept
*/* and this claiming to support XHTML just as well as HTML. Saving to a file
on disk or opening with another application does count as accepting, but it
really should have a lower q value then text/html. This sub takes a pragmatic
approach and corrects this mistake by modifying the Accept header before
passing it to content negotiation.

=head1 ATTRIBUTES

=head2 variants

Returns an array ref of 3 part arrays, comprising name, priority, output

lib/Catalyst/View/TT/XHTML.pm  view on Meta::CPAN

with qw/Catalyst::View::ContentNegotiation::XHTML/;

our $VERSION = '1.103';

1;

__END__

=head1 NAME

Catalyst::View::TT::XHTML - A sub-class of the standard TT view which serves
application/xhtml+xml content if the browser accepts it.

=head1 SYNOPSIS

    package MyApp::View::XHTML;
    use strict;
    use warnings;
    use base qw/Catalyst::View::TT::XHTML/;

    1;



( run in 1.748 second using v1.01-cache-2.11-cpan-49f99fa48dc )