[Jifty-commit] r6227 - in jifty/trunk: . lib/Jifty/View/Declare lib/Jifty/View/Mason lib/Jifty/View/Static t/TestApp-Dispatcher/etc
Jifty commits
jifty-commit at lists.jifty.org
Sat Jan 10 20:03:50 EST 2009
Author: alexmv
Date: Sat Jan 10 20:03:49 2009
New Revision: 6227
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Config.pm
jifty/trunk/lib/Jifty/View/Declare/Handler.pm
jifty/trunk/lib/Jifty/View/Mason/Handler.pm
jifty/trunk/lib/Jifty/View/Static/Handler.pm
jifty/trunk/t/TestApp-Dispatcher/etc/config.yml
Log:
r40453 at kohr-ah: chmrr | 2009-01-10 20:03:42 -0500
* Reduce dups and unnecessary views
* Config merging is now slightly smarter for specific listrefs
* Fix a test; though if TD had error handlers already, the fix would not have been needed
Modified: jifty/trunk/lib/Jifty/Config.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Config.pm (original)
+++ jifty/trunk/lib/Jifty/Config.pm Sat Jan 10 20:03:49 2009
@@ -195,7 +195,7 @@
my $self = shift;
# Add the default configuration file locations to the stash
- $self->stash( Hash::Merge::merge( $self->_default_config_files, $self->stash ));
+ $self->merge( $self->_default_config_files );
# Calculate the location of the application etc/config.yml
my $file = $ENV{'JIFTY_CONFIG'} || Jifty::Util->app_root . '/etc/config.yml';
@@ -204,11 +204,8 @@
# Start by loading application configuration file
if ( -f $file and -r $file ) {
- $app = $self->load_file($file);
- $app = Hash::Merge::merge( $self->stash, $app );
-
# Load the $app so we know where to find the vendor config file
- $self->stash($app);
+ $self->merge( $self->load_file($file) );
}
# Load the vendor configuration file
@@ -219,8 +216,7 @@
);
# Merge the app config with vendor config, vendor taking precedent
- my $config = Hash::Merge::merge( $self->stash, $vendor );
- $self->stash($config);
+ $self->merge( $vendor );
# Load the site configuration file
my $site = $self->load_file(
@@ -233,8 +229,7 @@
);
# Merge the app, vendor, and site config, site taking precedent
- $config = Hash::Merge::merge( $self->stash, $site );
- $self->stash($config);
+ $self->merge( $site );
# Load the test configuration file
my $test = $self->load_file(
@@ -244,16 +239,15 @@
);
# Merge the app, vendor, site and test config, test taking precedent
- $config = Hash::Merge::merge( $self->stash, $test );
- $self->stash($config);
+ $self->merge( $test );
# Merge guessed values in for anything we didn't explicitly define
# Whatever's in the stash overrides anything we guess
- $self->stash( Hash::Merge::merge( $self->guess, $self->stash ));
+ $self->merge( $self->stash, $self->guess );
# There are a couple things we want to guess that we don't want
# getting stuck in a default config file for an app
- $self->stash( Hash::Merge::merge( $self->defaults, $self->stash));
+ $self->merge( $self->stash, $self->defaults );
# Bring old configurations up to current expectations
$self->stash($self->update_config($self->stash));
@@ -266,7 +260,7 @@
bless $self, $app_class;
} elsif ( $found ) {
warn "You have $app_class, however it's not an sub-class of Jifty::Config."
- ." Read `perldoc Jifty::Config` about sub classing. Skipping.";
+ ." Read `perldoc Jifty::Config` about subclassing. Skipping.";
}
# post load hook for sub-classes
@@ -276,7 +270,27 @@
# test harness)
$self->$Jifty::Config::postload()
if $Jifty::Config::postload;
+}
+
+=head2 merge NEW, [FALLBACK]
+
+Merges the given C<NEW> hashref into the stash, with values taking
+precedence over pre-existing ones from C<FALLBACK>, which defaults to
+L</stash>. This also deals with special cases (MailerArgs,
+Handlers.View) where array reference contents should be replaced, not
+concatenated.
+
+=cut
+
+sub merge {
+ my $self = shift;
+ my ($new, $fallback) = @_;
+ $fallback ||= $self->stash;
+
+ delete $fallback->{framework}{MailerArgs} if exists $new->{framework}{MailerArgs};
+ delete $fallback->{framework}{View}{Handlers} if exists $new->{framework}{View}{Handlers};
+ $self->stash(Hash::Merge::merge( $fallback, $new ));
}
# Sets up the initial location of the site configuration file
Modified: jifty/trunk/lib/Jifty/View/Declare/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/View/Declare/Handler.pm Sat Jan 10 20:03:49 2009
@@ -46,9 +46,7 @@
for my $plugin ( Jifty->plugins ) {
my $comp_root = $plugin->template_class;
Jifty::Util->require($comp_root);
- unless (defined $comp_root and $comp_root->isa('Template::Declare') ){
- next;
- }
+ next unless (defined $comp_root and $comp_root->isa('Template::Declare') and not Jifty::ClassLoader->autogenerated($comp_root));
$plugin->log->debug( "Plugin @{[ref($plugin)]}::View added as a Template::Declare root");
push @{ $config{roots} }, $comp_root ;
}
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 Sat Jan 10 20:03:49 2009
@@ -101,15 +101,14 @@
);
my $root_serial = 0;
+ my %seen; $seen{$_} = 1 for map Jifty->config->framework('Web')->{$_}, qw/TemplateRoot DefaultTemplateRoot/;
for my $plugin (Jifty->plugins) {
my $comp_root = $plugin->template_root;
- unless ( $comp_root and -d $comp_root) {
- next;
- }
+ next unless ( $comp_root and -d $comp_root and not $seen{$comp_root}++);
$plugin->log->debug( "Plugin @{[ref($plugin)]} mason component root added: (@{[$comp_root ||'']})");
push @{ $config{comp_root} }, [ ref($plugin)."-". $root_serial++ => $comp_root ];
}
- push @{$config{comp_root}}, [jifty => Jifty->config->framework('Web')->{'DefaultTemplateRoot'}];
+ push @{$config{comp_root}}, [jifty => Jifty::Util->absolute_path( Jifty->config->framework('Web')->{'DefaultTemplateRoot'})];
# In developer mode, we want halos, refreshing and all that other good stuff.
if (Jifty->config->framework('DevelMode') ) {
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 Jan 10 20:03:49 2009
@@ -46,14 +46,13 @@
sub new {
my $class = shift;
-
my @roots = (Jifty->config->framework('Web')->{StaticRoot});
+ my %seen; $seen{$_} = 1 for map Jifty->config->framework('Web')->{$_}, qw/StaticRoot DefaultStaticRoot/;
for my $plugin ( Jifty->plugins ) {
my $root = $plugin->static_root;
- if ( -d $root and -r $root ) {
- push @roots, $root;
- $plugin->log->debug( "Plugin @{[ref($plugin)]} static root added: (@{[$root ||'']})");
- }
+ next unless ( -d $root and -r $root and not $seen{$root}++);
+ push @roots, $root;
+ $plugin->log->debug( "Plugin @{[ref($plugin)]} static root added: (@{[$root ||'']})");
}
push @roots, (Jifty->config->framework('Web')->{DefaultStaticRoot});
Modified: jifty/trunk/t/TestApp-Dispatcher/etc/config.yml
==============================================================================
--- jifty/trunk/t/TestApp-Dispatcher/etc/config.yml (original)
+++ jifty/trunk/t/TestApp-Dispatcher/etc/config.yml Sat Jan 10 20:03:49 2009
@@ -22,12 +22,8 @@
LogLevel: DEBUG
Plugins:
- -
- SkeletonApp: {}
-
- -
- CompressedCSSandJS: {}
-
+ - SkeletonApp: {}
+ - CompressedCSSandJS: {}
PubSub:
Backend: Memcached
Enable: ~
@@ -35,6 +31,7 @@
TemplateClass: TestApp::Dispatcher::View
View:
Handlers:
+ - Jifty::View::Mason::Handler
- Jifty::View::Static::Handler
- Jifty::View::Declare::Handler
Web:
More information about the Jifty-commit
mailing list