[Rt-commit] rt branch, 4.0/sanity-check-stylesheets, updated. rt-4.0.2-64-gacf143f
Alex Vandiver
alexmv at bestpractical.com
Thu Oct 20 19:15:28 EDT 2011
The branch, 4.0/sanity-check-stylesheets has been updated
via acf143f42f033efe051d5449c41785372ae26491 (commit)
via 9ae510476fe1e6b8fac2ef1fd61f2ce2db38b8e2 (commit)
from 143c21c27c51dcc5982d6a09611913ebf314ce5e (commit)
Summary of changes:
etc/upgrade/sanity-check-stylesheets.pl | 6 +-----
lib/RT/Config.pm | 6 +-----
lib/RT/Interface/Web.pm | 17 +++++++++++++++++
lib/RT/Interface/Web/Handler.pm | 6 ++----
lib/RT/Interface/Web/Request.pm | 6 +-----
lib/RT/User.pm | 3 +--
share/html/Admin/Tools/Configuration.html | 2 +-
share/html/Elements/Header | 7 +------
t/00-mason-syntax.t | 2 +-
9 files changed, 26 insertions(+), 29 deletions(-)
- Log -----------------------------------------------------------------
commit 9ae510476fe1e6b8fac2ef1fd61f2ce2db38b8e2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Oct 20 18:47:35 2011 -0400
Refactor component root determination to one centralized place
Multiple codepaths attempted to compute the set of Mason component
roots, either from examining the HTML::Mason object, or from first
principles. Centralize the logic to one place.
diff --git a/etc/upgrade/sanity-check-stylesheets.pl b/etc/upgrade/sanity-check-stylesheets.pl
index 1bdafed..7295d5f 100644
--- a/etc/upgrade/sanity-check-stylesheets.pl
+++ b/etc/upgrade/sanity-check-stylesheets.pl
@@ -59,11 +59,7 @@ use RT::Users;
my $users = RT::Users->new( $RT::SystemUser );
$users->UnLimit();
-my @comp_roots = (
- $RT::MasonLocalComponentRoot,
- (map { $_->ComponentRoot} @{RT->Plugins}),
- $RT::MasonComponentRoot,
-);
+my @comp_roots = RT::Interface::Web->ComponentRoots;
my %comp_root_check_cache;
sub stylesheet_exists {
my $stylesheet = shift;
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index ca6d91d..548ba19 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -202,11 +202,7 @@ our %META = (
my $self = shift;
my $value = $self->Get('WebDefaultStylesheet');
- my @comp_roots = (
- $RT::MasonLocalComponentRoot,
- (map { $_->ComponentRoot } @{RT->Plugins}),
- $RT::MasonComponentRoot,
- );
+ my @comp_roots = RT::Interface::Web->ComponentRoots;
for my $comp_root (@comp_roots) {
return if -d $comp_root.'/NoAuth/css/'.$value;
}
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 801d2d1..1352e1f 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1098,6 +1098,27 @@ sub ValidateWebConfig {
}
}
+sub ComponentRoots {
+ my $self = shift;
+ my %args = ( Names => 0, @_ );
+ my @roots;
+ if (defined $HTML::Mason::Commands::m) {
+ my $m = $HTML::Mason::Commands::m;
+ @roots =
+ $HTML::Mason::VERSION <= 1.28
+ ? $m->interp->resolver->comp_root_array
+ : $m->interp->comp_root_array;
+ } else {
+ @roots = (
+ [ local => $RT::MasonLocalComponentRoot ],
+ (map {[ "plugin-".$_->Name => $_->ComponentRoot ]} @{RT->Plugins}),
+ [ standard => $RT::MasonComponentRoot ]
+ );
+ }
+ @roots = map { $_->[1] } @roots unless $args{Names};
+ return @roots;
+}
+
package HTML::Mason::Commands;
use vars qw/$r $m %session/;
diff --git a/lib/RT/Interface/Web/Handler.pm b/lib/RT/Interface/Web/Handler.pm
index 5e8caa0..e7c8739 100644
--- a/lib/RT/Interface/Web/Handler.pm
+++ b/lib/RT/Interface/Web/Handler.pm
@@ -65,10 +65,8 @@ use File::Glob qw( bsd_glob );
use File::Spec::Unix;
sub DefaultHandlerArgs { (
- comp_root => [
- [ local => $RT::MasonLocalComponentRoot ],
- (map {[ "plugin-".$_->Name => $_->ComponentRoot ]} @{RT->Plugins}),
- [ standard => $RT::MasonComponentRoot ]
+ comp_root => [
+ RT::Interface::Web->ComponentRoots( Names => 1 ),
],
default_escape_flags => 'h',
data_dir => "$RT::MasonDataDir",
diff --git a/lib/RT/Interface/Web/Request.pm b/lib/RT/Interface/Web/Request.pm
index f08228b..e17c472 100644
--- a/lib/RT/Interface/Web/Request.pm
+++ b/lib/RT/Interface/Web/Request.pm
@@ -118,11 +118,7 @@ sub callback {
unless ( $callbacks ) {
$callbacks = [];
my $path = "/Callbacks/*$page/$name";
- my @roots = map $_->[1],
- $HTML::Mason::VERSION <= 1.28
- ? $self->interp->resolver->comp_root_array
- : $self->interp->comp_root_array;
-
+ my @roots = RT::Interface::Web->ComponentRoots;
my %seen;
@$callbacks = (
grep defined && length,
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index 9eac350..8664dc2 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -1328,12 +1328,11 @@ Returns a list of valid stylesheets take from preferences.
sub Stylesheet {
my $self = shift;
- my @roots = @_;
my $style = RT->Config->Get('WebDefaultStylesheet', $self->CurrentUser);
- my @css_paths = map { $_ . '/NoAuth/css' } @roots;
+ my @css_paths = map { $_ . '/NoAuth/css' } RT::Interface::Web->ComponentRoots;
for my $css_path (@css_paths) {
if (-d "$css_path/$style") {
diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index a8ac55f..9240882 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -173,7 +173,7 @@ for my $type (qw/Tickets Queues Transactions Groups PrivilegedUsers Unprivileged
<&|/Widgets/TitleBox, title => loc("Mason template search order") &>
<ol>
-% foreach my $path ( map { $_->[1] } $m->interp->comp_root_array ) {
+% foreach my $path ( RT::Interface::Web->ComponentRoots ) {
<li><% $path %></li>
% }
</ol>
diff --git a/share/html/Elements/Header b/share/html/Elements/Header
index 235740a..58e85b9 100755
--- a/share/html/Elements/Header
+++ b/share/html/Elements/Header
@@ -120,13 +120,8 @@ $id =~ s|index$||g
if $id ne 'index';
$id =~ s|-$||g;
-my @roots = map $_->[1],
- $HTML::Mason::VERSION <= 1.28
- ? $m->interp->resolver->comp_root_array
- : $m->interp->comp_root_array;
-
my $style = $session{'CurrentUser'}
- ? $session{'CurrentUser'}->Stylesheet(@roots)
+ ? $session{'CurrentUser'}->Stylesheet
: RT->Config->Get('WebDefaultStylesheet');
my @css_files;
commit acf143f42f033efe051d5449c41785372ae26491
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Oct 20 18:55:57 2011 -0400
Remove Mason VERSION checks, as we depend on a newer version than they check
445401c (and 71d2ed5 as a typo fix) bumped the minimum version of
HTML::Mason to 1.36, rendering these two checks (which existed in the
code at the time, via 113a1bc and 34da2dd) unnecessary. Simply the code
by removing them.
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 1352e1f..353473f 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1103,11 +1103,7 @@ sub ComponentRoots {
my %args = ( Names => 0, @_ );
my @roots;
if (defined $HTML::Mason::Commands::m) {
- my $m = $HTML::Mason::Commands::m;
- @roots =
- $HTML::Mason::VERSION <= 1.28
- ? $m->interp->resolver->comp_root_array
- : $m->interp->comp_root_array;
+ @roots = $HTML::Mason::Commands::m->interp->comp_root_array;
} else {
@roots = (
[ local => $RT::MasonLocalComponentRoot ],
diff --git a/t/00-mason-syntax.t b/t/00-mason-syntax.t
index 256c56e..1221b7d 100644
--- a/t/00-mason-syntax.t
+++ b/t/00-mason-syntax.t
@@ -33,7 +33,7 @@ sub compile_file {
$compiler->compile(
comp_source => $text,
name => 'my',
- $HTML::Mason::VERSION >= 1.36? (comp_path => 'my'): (),
+ comp_path => 'my',
);
return 1;
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list