[Jifty-commit] r3328 - in jifty/trunk/lib/Jifty: Plugin View/Declare

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Jun 3 15:24:32 EDT 2007


Author: clkao
Date: Sun Jun  3 15:24:32 2007
New Revision: 3328

Added:
   jifty/trunk/lib/Jifty/Plugin/SinglePage.pm
Modified:
   jifty/trunk/lib/Jifty/View/Declare/Helpers.pm
   jifty/trunk/lib/Jifty/Web/Form/Clickable.pm

Log:
First draft of SinglePage plugin.

Added: jifty/trunk/lib/Jifty/Plugin/SinglePage.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/SinglePage.pm	Sun Jun  3 15:24:32 2007
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::SinglePage;
+use base qw/Jifty::Plugin/;
+
+sub init {
+    my $self = shift;
+    Jifty::Web::Form::Clickable->add_trigger( before_new => \&_sp_link);
+}
+
+sub _sp_link {
+    my ($self, $args) = @_;
+    if (my $url = delete $args->{'url'}) {
+	$args->{onclick}=  { region       => "__page", replace_with => $url };
+    }
+}
+
+
+1;

Modified: jifty/trunk/lib/Jifty/View/Declare/Helpers.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/Helpers.pm	(original)
+++ jifty/trunk/lib/Jifty/View/Declare/Helpers.pm	Sun Jun  3 15:24:32 2007
@@ -316,6 +316,17 @@
         return '';
     };
 
+    my ($spa) = Jifty->find_plugin('Jifty::Plugin::SinglePage');
+    if( $spa && !Jifty->web->current_region) {
+	&$render_header unless ($done_header);
+	body {
+	    render_region('__page', path => Jifty->web->request->path);
+	}
+	    outs_raw('</html>');
+	Template::Declare->buffer->data( $done_header . Template::Declare->buffer->data );
+	return;
+    }
+
     body {
         div {
             div {

Modified: jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Clickable.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Clickable.pm	Sun Jun  3 15:24:32 2007
@@ -2,6 +2,7 @@
 use strict;
 
 package Jifty::Web::Form::Clickable;
+use Class::Trigger;
 
 =head1 NAME
 
@@ -143,6 +144,8 @@
         @_,
     );
 
+    $class->call_trigger('before_new', \%args);
+
     $args{render_as_button} = delete $args{as_button};
     $args{render_as_link}   = delete $args{as_link};
 


More information about the Jifty-commit mailing list