[Jifty-commit] r3374 - in jifty/branches/js-refactor: lib/Jifty
lib/Jifty/View/Static
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Jun 6 21:12:36 EDT 2007
Author: trs
Date: Wed Jun 6 21:12:27 2007
New Revision: 3374
Modified:
jifty/branches/js-refactor/ (props changed)
jifty/branches/js-refactor/lib/Jifty/Plugin.pm
jifty/branches/js-refactor/lib/Jifty/View/Static/Handler.pm
Log:
r21753 at zot: tom | 2007-06-06 21:11:38 -0400
* Use Jifty::Util->share_root for finding plugin share roots so that if Jifty isn't installed it still DTRT
* Only calculate static roots once and report on plugins adding roots (like the mason handler does)
Modified: jifty/branches/js-refactor/lib/Jifty/Plugin.pm
==============================================================================
--- jifty/branches/js-refactor/lib/Jifty/Plugin.pm (original)
+++ jifty/branches/js-refactor/lib/Jifty/Plugin.pm Wed Jun 6 21:12:27 2007
@@ -98,8 +98,7 @@
eval { $self->{share} = module_dir($class) };
}
unless ( $self->{share} ) {
- local $@; # We're just avoiding File::ShareDir's failure behaviour of dying
- eval { $self->{share} = module_dir('Jifty') };
+ $self->{share} = Jifty::Util->share_root;
if ( $self->{'share'} ) {
my $class_to_path = $class;
$class_to_path =~ s|::|/|g;
Modified: jifty/branches/js-refactor/lib/Jifty/View/Static/Handler.pm
==============================================================================
--- jifty/branches/js-refactor/lib/Jifty/View/Static/Handler.pm (original)
+++ jifty/branches/js-refactor/lib/Jifty/View/Static/Handler.pm Wed Jun 6 21:12:27 2007
@@ -50,7 +50,20 @@
=cut
sub new {
my $class = shift;
- my $self = {};
+
+ my @roots = (Jifty->config->framework('Web')->{StaticRoot});
+ for my $plugin ( Jifty->plugins ) {
+ my $root = $plugin->static_root;
+ if ( -d $root and -r $root ) {
+ push @roots, $root;
+ Jifty->log->debug( "Plugin @{[ref($plugin)]} static root added: (@{[$root ||'']})");
+ }
+ }
+ push @roots, (Jifty->config->framework('Web')->{DefaultStaticRoot});
+
+ my $self = {
+ roots => \@roots
+ };
bless $self, $class;
}
@@ -138,14 +151,11 @@
sub file_path {
my $self = shift;
my $file = shift;
- my @options = (Jifty->config->framework('Web')->{StaticRoot});
- 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?
$file =~ s/^\/*?static//;
- foreach my $path (@options) {
+ foreach my $path ( @{$self->{'roots'}} ) {
my $abspath = Jifty::Util->absolute_path( File::Spec->catdir($path,$file ));
# If the user is trying to request something outside our static root,
# decline the request
More information about the Jifty-commit
mailing list