[Jifty-commit] r3914 - in jifty/trunk: . lib/Jifty/View/Declare
lib/Jifty/View/Mason share/web/templates
t/TestApp/share/web/templates/_elements t/TestApp/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Aug 16 23:09:09 EDT 2007
Author: sterling
Date: Thu Aug 16 23:09:08 2007
New Revision: 3914
Added:
jifty/trunk/t/TestApp/share/web/templates/_elements/
jifty/trunk/t/TestApp/share/web/templates/_elements/wrapper
jifty/trunk/t/TestApp/t/use_mason_wrapper.t
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/View/Declare/BaseClass.pm
jifty/trunk/lib/Jifty/View/Mason/Handler.pm
jifty/trunk/share/web/templates/autohandler
jifty/trunk/t/TestApp/lib/TestApp/View.pm
Log:
r8695 at dynpc145: andrew | 2007-08-16 22:07:42 -0500
Fixes to use_mason_wrapper():
* Added a test to make sure use_mason_wrapper() works.
* Added $jifty_internal_request to note whether a Mason request is internal or not.
* Altered the autohandler to use $jifty_internal_request when blocking access to /_elements/
* Fixed error handling in the autohandler to redirect to /__jifty/error/requested_private_component rather than /errors/requested_private_component
Modified: jifty/trunk/lib/Jifty/View/Declare/BaseClass.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/BaseClass.pm (original)
+++ jifty/trunk/lib/Jifty/View/Declare/BaseClass.pm Thu Aug 16 23:09:08 2007
@@ -33,7 +33,7 @@
no warnings 'redefine';
*{ $class . '::wrapper' } = sub {
my $code = shift;
- my $args = shift;
+ my $args = shift || {};
# so in td handler, we made jifty::web->out appends to td
# buffer, we need it back for here before we call $code.
# someday we need to finish fixing the output system that is
Modified: jifty/trunk/lib/Jifty/View/Mason/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Mason/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/View/Mason/Handler.pm Thu Aug 16 23:09:08 2007
@@ -189,6 +189,10 @@
my $r = Jifty->handler->apache;
$self->interp->set_global('$r', $r);
+ # XXX FIXME This is a kludge to get use_mason_wrapper to work
+ $self->interp->set_global('$jifty_internal_request', 0);
+ $self->interp->set_global('$jifty_internal_request', 1) if defined $args;
+
my %args = $args ? %$args : $self->request_args($r);
my @result;
Modified: jifty/trunk/share/web/templates/autohandler
==============================================================================
--- jifty/trunk/share/web/templates/autohandler (original)
+++ jifty/trunk/share/web/templates/autohandler Thu Aug 16 23:09:08 2007
@@ -1,9 +1,11 @@
<%init>
$r->content_type('text/html; charset=utf-8');
-if ($m->base_comp->path =~ m|/_elements/|) {
+# XXX FIXME See Jifty::View::Mason::Handler for the source of this puke.
+use vars qw/ $jifty_internal_request /;
+if (!$jifty_internal_request && $m->base_comp->path =~ m|/_elements/|) {
# Requesting an internal component by hand -- naughty
- $m->redirect("/errors/requested_private_component");
+ $m->redirect('/__jifty/error/requested_private_component');
}
$m->comp('/_elements/nav');
$m->call_next();
Modified: jifty/trunk/t/TestApp/lib/TestApp/View.pm
==============================================================================
--- jifty/trunk/t/TestApp/lib/TestApp/View.pm (original)
+++ jifty/trunk/t/TestApp/lib/TestApp/View.pm Thu Aug 16 23:09:08 2007
@@ -4,6 +4,8 @@
use Jifty::View::Declare -base;
+__PACKAGE__->use_mason_wrapper;
+
template 'concrete2.html' => sub {
html {
body {
@@ -103,4 +105,9 @@
h1 { 'redirected ok'};
};
+
+template 'use_mason_wrapper' => page {
+ h1 { 'In a Mason Wrapper?' };
+};
+
1;
Added: jifty/trunk/t/TestApp/share/web/templates/_elements/wrapper
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/share/web/templates/_elements/wrapper Thu Aug 16 23:09:08 2007
@@ -0,0 +1,38 @@
+<body>
+ <div id="headers">
+ <%Jifty->web->link( url => "/", label => _(Jifty->config->framework('ApplicationName')))%>
+ <h1 class="title"><% _($title) %></h1>
+ </div>
+ <& sidebar &>
+ <div id="content">
+ <a name="content"></a>
+% if (Jifty->config->framework('AdminMode') ) {
+<div class="warning admin_mode">
+<%_('Alert')%>: <% Jifty->web->tangent( label => _('Administration mode is enabled.') , url => '/__jifty/admin/')%>
+</div>
+% }
+ <% Jifty->web->render_messages %>
+ <% $m->content |n%>
+ <& /_elements/keybindings &>
+<div id="custom-stuff">Custom Wrapper</div>
+ </div>
+ <div id="jifty-wait-message" style="display: none"><%_('Loading...')%></div>
+% Jifty::Mason::Halo->render_component_tree() if (Jifty->config->framework('DevelMode') );
+%# This is required for jifty server push. If you maintain your own
+%# wrapper, make sure you have this as well.
+% if ( Jifty->config->framework('PubSub')->{'Enable'} && Jifty::Subs->list ) {
+<script>new Jifty.Subs({}).start();</script>
+% }
+</body>
+</html>
+% Jifty->handler->stash->{'in_body'} = 0;
+<%args>
+$title => ""
+</%args>
+<%init>
+# First we set up the header.
+$m->comp( 'header', title => $title);
+# now that we've printed out the header, we're inside the body, so it's safe to print
+# halo markers.
+Jifty->handler->stash->{'in_body'} = 1;
+</%init>
Added: jifty/trunk/t/TestApp/t/use_mason_wrapper.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/use_mason_wrapper.t Thu Aug 16 23:09:08 2007
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+use lib 't/lib';
+use Jifty::SubTest;
+
+use Jifty::Test tests => 6;
+use Jifty::Test::WWW::Mechanize;
+
+my $server = Jifty::Test->make_server;
+my $url = $server->started_ok;
+
+my $mech = Jifty::Test::WWW::Mechanize->new;
+$mech->get_ok( $url . '/use_mason_wrapper', 'grab a page' );
+
+$mech->content_contains( 'In a Mason Wrapper?', 'got the right template' );
+$mech->content_contains( 'Custom Wrapper', 'used the custom wrapper' );
+
+$mech->get_ok( $url . '/_elements/wrapper', 'getting the wrapper directly');
+$mech->content_contains( 'Something went awry', 'and we were not able to');
More information about the Jifty-commit
mailing list