[Catalyst-commits] r9181 - in
Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role: .
lib/Catalyst/View/ContentNegotiation lib/Catalyst/View/TT t
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Tue Feb 3 21:16:16 GMT 2009
Author: t0m
Date: 2009-02-03 21:16:16 +0000 (Tue, 03 Feb 2009)
New Revision: 9181
Modified:
Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/Changes
Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/Makefile.PL
Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/README
Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/lib/Catalyst/View/ContentNegotiation/XHTML.pm
Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/lib/Catalyst/View/TT/XHTML.pm
Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/t/podspelling.t
Log:
Add docs for the new role
Modified: Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/Changes
===================================================================
--- Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/Changes 2009-02-03 18:05:06 UTC (rev 9180)
+++ Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/Changes 2009-02-03 21:16:16 UTC (rev 9181)
@@ -1,16 +1,19 @@
+1.100
+ - Refactor into a Moose Role for use with alternate views. (rafl)
+ - Additional documentation (t0m)
1.004
- Nick the OSX fragment out of the Catalyst::Runtime Makefile.PL to
- beat my Mac into generating a correct dist.
+ beat my Mac into generating a correct dist. (t0m)
1.003
- Fixes an tests to be fully Internet Explorer compatible (David Dorward)
- Change to MRO::Compat for perl 5.10 (t0m)
1.002 2008-12-13
- Add 'use Class::C3' so that the module works on the currently
- released Catalyst version.
+ released Catalyst version. (t0m)
1.001 2008-12-12
- Add tests for other Accept header cases where the current code
will get it wrong. (David Dorward)
- Fix all of these tests. (t0m)
1.000 2008-12-12
- First working version of the module extracted from the quick hack
- I have in every Catalyst application I've ever written.
+ I have in every Catalyst application I've ever written. (t0m)
Modified: Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/Makefile.PL
===================================================================
--- Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/Makefile.PL 2009-02-03 18:05:06 UTC (rev 9180)
+++ Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/Makefile.PL 2009-02-03 21:16:16 UTC (rev 9181)
@@ -1,7 +1,7 @@
use inc::Module::Install;
-name 'Catalyst-View-TT-XHTML';
-all_from 'lib/Catalyst/View/TT/XHTML.pm';
+name 'Catalyst-View-ContentNegotiation-XHTML';
+all_from 'lib/Catalyst/View/ContentNegotiation/XHTML.pm';
requires 'Catalyst::Runtime';
requires 'Catalyst::View::TT';
@@ -11,9 +11,9 @@
requires 'MooseX::Types::Structured';
requires 'namespace::clean';
-build_requires 'Catalyst::Action::RenderView';
-build_requires 'Test::WWW::Mechanize::Catalyst';
-build_requires 'Test::More';
+test_requires 'Catalyst::Action::RenderView';
+test_requires 'Test::WWW::Mechanize::Catalyst';
+test_requires 'Test::More';
resources repository => 'http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-View-TT-XHTML';
Modified: Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/README
===================================================================
--- Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/README 2009-02-03 18:05:06 UTC (rev 9180)
+++ Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/README 2009-02-03 21:16:16 UTC (rev 9181)
@@ -1,49 +1,73 @@
NAME
- Catalyst::View::TT::XHTML - A sub-class of the standard TT view which
- serves application/xhtml+xml content if the browser accepts it.
+ Catalyst::View::ContentNegotiation::XHTML - A Moose Role to apply to
+ Catalyst views adjusts the response Content-Type header to
+ application/xhtml+xml content if the browser accepts it.
SYNOPSIS
- package MyApp::View::XHTML;
- use strict;
- use warnings;
- use base qw/Catalyst::View::TT::XHTML MyApp::View::TT/;
-
+ package Catalyst::View::TT;
+
+ use Moose;
+ use namespace::clean -except => 'meta';
+
+ extends qw/Catalyst::View::TT/;
+ with qw/Catalyst::View::ContentNegotiation::XHTML/;
+
1;
-
+
DESCRIPTION
- This is a very simple sub-class of Catalyst::View::TT, which sets the
- response "Content-Type" to be "application/xhtml+xml" if the user's
- browser sends an "Accept" header indicating that it is willing to
- process that MIME type.
+ This is a very simple Role which uses a method modifier to run after the
+ "process" method, and sets the response "Content-Type" to be
+ "application/xhtml+xml" if the users browser sends an "Accept" header
+ indicating that it is willing to process that MIME type.
Changing the "Content-Type" causes browsers to interpret the page as
- strict XHTML, meaning that the markup must be well formed.
+ XML, meaning that the markup must be well formed.
This is useful when you're developing your application, as you know that
- all pages you view are rendered strictly, so any markup errors will show
- up at once.
+ all pages you view are parsed as XML, so any errors caused by your
+ markup not being well-formed will show up at once.
+METHOD MODIFIERS
+ after process
+ Changes the response "Content-Type" if appropriate (from the requests
+ "Accept" header).
+
METHODS
- process
- Overrides the standard process method, delegating to Catalyst::View::TT
- to render the template, and then changing the response "Content-Type" if
- appropriate (from the requests "Accept" header).
+ 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
- There should be a more elegant way to inherit the config of your normal
- TT view.
+ Will only work with Views which implement a process method.
- Configuration (as loaded by Catalyst::Plugin::ConfigLoader) for the TT
- view is not used.
+ Should be split into a base ContentNegotiation role which is consumed by
+ ContentNegotiation::XHTML.
- No helper to generate the view file needed (just copy the code in the
- SYNOPSIS).
-
AUTHOR
- Tomas Doran "<bobtfish at bobtfish.net>"
+ Tomas Doran (t0m) "<bobtfish at bobtfish.net>"
CONTRIBUTORS
- David Dorward - test patches
+ David Dorward - test patches and */* pragmatism.
+ Florian Ragwitz (rafl) "<rafl at debian.org>" - Conversion into a Moose
+ Role
COPYRIGHT
This module itself is copyright (c) 2008 Tomas Doran and is licensed
Modified: Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/lib/Catalyst/View/ContentNegotiation/XHTML.pm
===================================================================
--- Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/lib/Catalyst/View/ContentNegotiation/XHTML.pm 2009-02-03 18:05:06 UTC (rev 9180)
+++ Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/lib/Catalyst/View/ContentNegotiation/XHTML.pm 2009-02-03 21:16:16 UTC (rev 9181)
@@ -7,7 +7,7 @@
use namespace::clean -except => 'meta';
-our $VERSION = '1.004';
+our $VERSION = '1.100';
has variants => (
is => 'ro',
@@ -46,3 +46,103 @@
}
1;
+
+__END__
+
+=head1 NAME
+
+Catalyst::View::ContentNegotiation::XHTML - A Moose Role to apply to
+Catalyst views adjusts the response Content-Type header to
+application/xhtml+xml content if the browser accepts it.
+
+=head1 SYNOPSIS
+
+ package Catalyst::View::TT;
+
+ use Moose;
+ use namespace::clean -except => 'meta';
+
+ extends qw/Catalyst::View::TT/;
+ with qw/Catalyst::View::ContentNegotiation::XHTML/;
+
+ 1;
+
+=head1 DESCRIPTION
+
+This is a very simple Role which uses a method modifier to run after the
+C<process> method, and sets the response C<Content-Type> to be
+C<application/xhtml+xml> if the users browser sends an C<Accept> header
+indicating that it is willing to process that MIME type.
+
+Changing the C<Content-Type> causes browsers to interpret the page as
+XML, meaning that the markup must be well formed.
+
+This is useful when you're developing your application, as you know that
+all pages you view are parsed as XML, so any errors caused by your markup
+not being well-formed will show up at once.
+
+=head1 METHOD MODIFIERS
+
+=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
+mime-type, which is used for the content negotiation algorithm.
+
+=head1 PRIVATE METHODS
+
+=head2 _build_variants
+
+Returns the default variant attribute contents.
+
+=head1 SEE ALSO
+
+=over
+
+=item L<Catalyst::View::TT::XHTML> - Trivial Catalyst TT view using this role.
+
+=item L<http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html> - Content negotiation RFC.
+
+=back
+
+=head1 BUGS
+
+Will only work with Views which implement a process method.
+
+Should be split into a base ContentNegotiation role which is consumed by ContentNegotiation::XHTML.
+
+=head1 AUTHOR
+
+Tomas Doran (t0m) C<< <bobtfish at bobtfish.net> >>
+
+=head1 CONTRIBUTORS
+
+=over
+
+=item David Dorward - test patches and */* pragmatism.
+
+=item Florian Ragwitz (rafl) C<< <rafl at debian.org> >> - Conversion into a Moose Role
+
+=back
+
+=head1 COPYRIGHT
+
+This module itself is copyright (c) 2008 Tomas Doran and is licensed under the same terms as Perl itself.
+
+=cut
Modified: Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/lib/Catalyst/View/TT/XHTML.pm
===================================================================
--- Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/lib/Catalyst/View/TT/XHTML.pm 2009-02-03 18:05:06 UTC (rev 9180)
+++ Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/lib/Catalyst/View/TT/XHTML.pm 2009-02-03 21:16:16 UTC (rev 9181)
@@ -6,8 +6,8 @@
extends qw/Catalyst::View::TT/;
with qw/Catalyst::View::ContentNegotiation::XHTML/;
-our $VERSION = '1.004';
-
+our $VERSION = '1.100';
+
1;
__END__
@@ -22,7 +22,7 @@
package MyApp::View::XHTML;
use strict;
use warnings;
- use base qw/Catalyst::View::TT::XHTML MyApp::View::TT/;
+ use base qw/Catalyst::View::TT::XHTML/;
1;
@@ -40,46 +40,18 @@
all pages you view are parsed as XML, so any errors caused by your markup
not being well-formed will show up at once.
-=head1 METHODS
+=head1 NOTE
-=head2 process
+This module is a very simple demonstration of a consumer of the
+L<Catalyst::View::ContentNegotiation::XHTML> role.
-Overrides the standard process method, delegating to L<Catalyst::View::TT>
-to render the template, and then changing the response C<Content-Type> if
-appropriate (from the requests C<Accept> header).
+If your needs are not trivial, then it is recommended that you consume
+that role yourself.
-=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 BUGS
-
-There should be a more elegant way to inherit the config of your normal
-TT view.
-
-Configuration (as loaded by L<Catalyst::Plugin::ConfigLoader>) for the TT
-view is not used.
-
-No helper to generate the view file needed (just copy the code in the
-SYNOPSIS).
-
=head1 AUTHOR
-Tomas Doran C<< <bobtfish at bobtfish.net> >>
+Tomas Doran (t0m) C<< <bobtfish at bobtfish.net> >>
-=head1 CONTRIBUTORS
-
-=over
-
-=item David Dorward - test patches and */* pragmatism.
-
-=back
-
=head1 COPYRIGHT
This module itself is copyright (c) 2008 Tomas Doran and is licensed under the same terms as Perl itself.
Modified: Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/t/podspelling.t
===================================================================
--- Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/t/podspelling.t 2009-02-03 18:05:06 UTC (rev 9180)
+++ Catalyst-View-TT-XHTML/1.000/branches/refactor-into-role/t/podspelling.t 2009-02-03 21:16:16 UTC (rev 9181)
@@ -18,3 +18,6 @@
TT
Doran
Dorward
+rafl
+ContentNegotiation
+Ragwitz
More information about the Catalyst-commits
mailing list