[Jifty-commit] r3176 - in jifty/trunk: lib/Jifty
lib/Jifty/View/Static
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Apr 30 09:40:02 EDT 2007
Author: jesse
Date: Mon Apr 30 09:40:02 2007
New Revision: 3176
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Dispatcher.pm
jifty/trunk/lib/Jifty/Handler.pm
jifty/trunk/lib/Jifty/Util.pm
jifty/trunk/lib/Jifty/View/Static/Handler.pm
Log:
r56150 at pinglin: jesse | 2007-04-30 09:23:11 -0400
* More refactoring in support of adding new view handlers.
Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm Mon Apr 30 09:40:02 2007
@@ -1127,7 +1127,7 @@
my $self = shift;
my $template = shift;
- foreach my $handler ( Jifty->handler->template_handlers) {
+ foreach my $handler ( Jifty->handler->view_handlers) {
if ( Jifty->handler->view($handler)->template_exists($template) ) {
return 1;
}
@@ -1150,14 +1150,14 @@
my $template = shift;
my $showed = 0;
eval {
- foreach my $handler ( Jifty->handler->template_handlers ) {
+ foreach my $handler ( Jifty->handler->view_handlers ) {
if ( Jifty->handler->view($handler)->template_exists($template) ) {
$showed = 1;
Jifty->handler->view($handler)->show($template);
last;
}
}
- if ( not $showed and my $fallback_handler = Jifty->handler->_fallback_template_handler ) {
+ if ( not $showed and my $fallback_handler = Jifty->handler->fallback_view_handler ) {
$fallback_handler->show($template);
}
Modified: jifty/trunk/lib/Jifty/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/Handler.pm Mon Apr 30 09:40:02 2007
@@ -48,11 +48,19 @@
-__PACKAGE__->mk_accessors(qw(dispatcher view_handlers cgi apache stash));
+__PACKAGE__->mk_accessors(qw(dispatcher _view_handlers cgi apache stash));
+
+=head2 mason
+
+
+Returns the Jifty c<HTML::Mason> handler. While this "should" be just another template handler,
+we still rely on it for little bits of Jifty infrastructure. Patches welcome.
+
+=cut
sub mason {
my $self = shift;
- return $self->view_handlers()->{'Jifty::View::Mason::Handler'};
+ return $self->view('Jifty::View::Mason::Handler');
}
@@ -78,32 +86,57 @@
return $self;
}
-sub template_handlers { qw(Jifty::View::Static::Handler Jifty::View::Declare::Handler Jifty::View::Mason::Handler)}
-sub _fallback_template_handler { my $self = shift; return $self->mason; }
+
+=head2 view_handlers
+
+Returns a list of modules implementing view for your Jifty application.
+
+XXX TODO: this should take pluggable views
+
+=cut
+
+
+sub view_handlers { qw(Jifty::View::Static::Handler Jifty::View::Declare::Handler Jifty::View::Mason::Handler)}
+
+
+=head2 fallback_view_handler
+
+Returns the object for our "last-resort" view handler. By default, this is the L<HTML::Mason> handler.
+
+=cut
+
+
+
+sub fallback_view_handler { my $self = shift; return $self->view('Jifty::View::Mason::Handler') }
=head2 setup_view_handlers
Initialize all of our view handlers.
-XXX TODO: this should take pluggable views
=cut
sub setup_view_handlers {
my $self = shift;
- $self->view_handlers({});
- foreach my $class ($self->template_handlers()) {
- $self->view_handlers->{$class} = $class->new();
+ $self->_view_handlers({});
+ foreach my $class ($self->view_handlers()) {
+ $self->_view_handlers->{$class} = $class->new();
}
}
+=head2 view ClassName
+
+
+Returns the Jifty view handler for C<ClassName>.
+
+=cut
+
sub view {
my $self = shift;
my $class = shift;
-
- return $self->view_handlers->{$class};
+ return $self->_view_handlers->{$class};
}
Modified: jifty/trunk/lib/Jifty/Util.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Util.pm (original)
+++ jifty/trunk/lib/Jifty/Util.pm Mon Apr 30 09:40:02 2007
@@ -201,7 +201,7 @@
=head2 make_path PATH
When handed a directory, creates that directory, starting as far up the
-chain as necessary. (This is what 'mkdir -p' does in your shell)
+chain as necessary. (This is what 'mkdir -p' does in your shell).
=cut
Modified: jifty/trunk/lib/Jifty/View/Static/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Static/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/View/Static/Handler.pm Mon Apr 30 09:40:02 2007
@@ -55,13 +55,21 @@
}
-=head2 handle_request $path
+=head2 show $path
Handle a request for C<$path>. If we can't find a static file of that name, return undef.
=cut
+=head2 handle_request $path
+
+
+An alias for L</show>
+
+=cut
+
+
sub show {
shift->handle_request(@_);
}
@@ -117,6 +125,12 @@
=cut
+=head2 template_exists $path
+
+An alias for L</file_path>.
+
+=cut
+
sub template_exists {
shift->file_path(@_);
}
More information about the Jifty-commit
mailing list