[Jifty-commit] r3330 - in jifty/trunk/lib/Jifty: Plugin

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Jun 3 16:33:42 EDT 2007


Author: clkao
Date: Sun Jun  3 16:33:42 2007
New Revision: 3330

Modified:
   jifty/trunk/lib/Jifty/Plugin/SinglePage.pm
   jifty/trunk/lib/Jifty/View/Declare/Helpers.pm

Log:
Make SinglePage plugin configurable.


Modified: jifty/trunk/lib/Jifty/Plugin/SinglePage.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/SinglePage.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/SinglePage.pm	Sun Jun  3 16:33:42 2007
@@ -2,21 +2,34 @@
 use warnings;
 
 package Jifty::Plugin::SinglePage;
-use base qw/Jifty::Plugin/;
+use base qw/Jifty::Plugin Class::Accessor/;
+
+__PACKAGE__->mk_accessors(qw(region_name));
 
 sub init {
     my $self = shift;
-    Jifty::Web::Form::Clickable->add_trigger( before_new => \&_sp_link);
+    Jifty::Web::Form::Clickable->add_trigger( before_new => _sp_link($self));
+    my %opt = @_;
+    $self->region_name($opt{region_name} || '__page');
 }
 
 sub _sp_link {
-    my ($self, $args) = @_;
-    if (my $url = delete $args->{'url'}) {
-	# XXX mind the existing onclick
-	warn 'ooops got original onclick'. Dumper($args->{onclick}) if $args->{onclick};
-	$args->{onclick}=  { region       => "__page", replace_with => $url,
-			     args => delete $args->{parameters} };
-    }
+    my $self = shift;
+    return sub {
+        my ( $clickable, $args ) = @_;
+	return if $args->{url} && $args->{url} =~ m/^#/;
+        if ( my $url = delete $args->{'url'} ) {
+            # XXX mind the existing onclick
+            use Data::Dumper;
+            warn 'ooops got original onclick' . Dumper( $args->{onclick} )
+                if $args->{onclick};
+            $args->{onclick} = {
+                region       => $self->region_name,
+                replace_with => $url,
+                args         => delete $args->{parameters}
+            };
+        }
+        }
 }
 
 

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 16:33:42 2007
@@ -319,9 +319,13 @@
     my ($spa) = Jifty->find_plugin('Jifty::Plugin::SinglePage');
     if( $spa && !Jifty->web->current_region) {
 	&$render_header unless ($done_header);
+	# XXX: move this to the plugin so it can be called from other
+	# view handlers
 	body {
-	    render_region('__page', path => Jifty->web->request->path);
+	    render_region($spa->region_name, path => Jifty->web->request->path);
 	}
+
+
 	    outs_raw('</html>');
 	Template::Declare->buffer->data( $done_header . Template::Declare->buffer->data );
 	return;


More information about the Jifty-commit mailing list