[Jifty-commit] r3006 - in jifty/trunk: lib/Jifty lib/Jifty/View/Static

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Mar 17 01:45:06 EDT 2007


Author: jesse
Date: Sat Mar 17 01:45:05 2007
New Revision: 3006

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Plugin.pm
   jifty/trunk/lib/Jifty/View/Static/Handler.pm

Log:
 r53564 at pinglin:  jesse | 2007-03-16 23:11:59 -0400
 * Work to make plugins not explode


Modified: jifty/trunk/lib/Jifty/Plugin.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin.pm	Sat Mar 17 01:45:05 2007
@@ -2,6 +2,8 @@
 use warnings;
 
 package Jifty::Plugin;
+use File::ShareDir 'module_dir';
+
 
 =head1 NAME
 
@@ -89,20 +91,22 @@
 
 sub _calculate_share {
     my $self = shift;
-    my $class = ref($self) || $self;
+    my $class = ref($self);
     unless ( $self->{share} ) {
-        local $@; # We're just avoiding File::ShareDir's failure behaviour of dying
-        eval { $self->{share} = File::ShareDir::module_dir($class) };
+        local $@
+            ; # We're just avoiding File::ShareDir's failure behaviour of dying
+        eval { $self->{share} = module_dir($class) };
     }
     unless ( $self->{share} ) {
-        local $@ ; # We're just avoiding File::ShareDir's failure behaviour of dying
-        eval { $self->{share} = File::ShareDir::module_dir('Jifty') };
+        local $@; # We're just avoiding File::ShareDir's failure behaviour of dying
+        eval { $self->{share} = module_dir('Jifty') };
         if ( $self->{'share'} ) {
             my $class_to_path = $class;
             $class_to_path =~ s|::|/|g;
             $self->{share} .= "/plugins/" . $class_to_path;
         }
     }
+    return $self->{share};
 }
 
 
@@ -114,9 +118,9 @@
 
 sub template_root {
     my $self = shift;
-    $self->{share} ||= $self->_calculate_share();
-    return unless $self->{share};
-    return $self->{share}."/web/templates";
+    my $dir =  $self->_calculate_share();
+    return unless $dir;
+    return $dir."/web/templates";
 }
 
 
@@ -141,9 +145,9 @@
 
 sub static_root {
     my $self = shift;
-    $self->{share} ||= $self->_calculate_share();
-    return unless $self->{share};
-    return $self->{share}."/web/static";
+    my $dir =  $self->_calculate_share();
+    return unless $dir;
+    return $dir."/web/static";
 }
 
 =head2 dispatcher

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	Sat Mar 17 01:45:05 2007
@@ -117,7 +117,7 @@
     my $self    = shift;
     my $file    = shift;
     my @options = (Jifty->config->framework('Web')->{StaticRoot});
-    push @options, grep {$_} map {$_->static_root} Jifty->plugins;
+    push @options, grep { -d $_ && -r $_ } map {$_->static_root} Jifty->plugins;
     push @options, (Jifty->config->framework('Web')->{DefaultStaticRoot});
 
     # Chomp a leading "/static" - should this be configurable?


More information about the Jifty-commit mailing list