[Rt-commit] rt branch, no-prototype, updated. rt-3.8.8-193-g6d992ed
? sunnavy
sunnavy at bestpractical.com
Fri Jul 30 20:30:32 EDT 2010
The branch, no-prototype has been updated
via 6d992edc268a969bdd480b6b9adea5640e662924 (commit)
via 6ba4716ce62a9d8325336c333d787738caaa2899 (commit)
from bfa9b90bbead91d3a7b3b2069b84a8b29feac64a (commit)
Summary of changes:
etc/RT_Config.pm.in | 15 ++++++-
share/html/Elements/HeaderJavascript | 9 +---
share/html/NoAuth/js/dhandler | 76 +++++++++++++--------------------
3 files changed, 46 insertions(+), 54 deletions(-)
- Log -----------------------------------------------------------------
commit 6ba4716ce62a9d8325336c333d787738caaa2899
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Jul 31 08:29:17 2010 +0800
jsmin after concatenate js files
diff --git a/share/html/NoAuth/js/dhandler b/share/html/NoAuth/js/dhandler
index cdcaef1..a65dc8a 100644
--- a/share/html/NoAuth/js/dhandler
+++ b/share/html/NoAuth/js/dhandler
@@ -55,66 +55,52 @@ my $path;
if ( $arg =~ m{squished\.js$} ) {
$path = $m->current_comp->dir_path;
unless ( $content ) {
- my $has_jsmin;
- my $jsmin = RT->Config->Get( 'JSMinPath' );
-
- if ( $jsmin && -x $jsmin ) {
- $has_jsmin = 1;
- }
-
require File::Spec;
my @js =
qw/jquery-1.4.2.min.js jquery_noconflict.js jquery.autocomplete-min.js jquery-ui-1.7.3.custom.min.js jquery.timepickr.js titlebox-state.js util.js/;
- my $has_jsmin_module;
-
for my $js (@js) {
my $file = File::Spec->catfile( $path, $js );
my $input = $m->scomp($file);
+ $content .= $input;
+ }
- if ($has_jsmin) {
- my ( $output, $error );
+ my $minified;
+ my $jsmin = RT->Config->Get( 'JSMinPath' );
+ if ( $jsmin && -x $jsmin ) {
+ my $input = $content;
+ my ( $output, $error );
- my $stdout = IO::Handle->new;
- $stdout->fdopen( 1, 'w' );
- local *STDOUT = $stdout;
+ my $stdout = IO::Handle->new;
+ $stdout->fdopen( 1, 'w' );
+ local *STDOUT = $stdout;
- my $stderr = IO::Handle->new;
- $stderr->fdopen( 2, 'w' );
- local *STDERR = $stderr;
+ my $stderr = IO::Handle->new;
+ $stderr->fdopen( 2, 'w' );
+ local *STDERR = $stderr;
- local $SIG{'CHLD'} = 'DEFAULT';
- require IPC::Run;
- IPC::Run::run( [$jsmin], \$input, \$output, \$error );
- if ( $? >> 8 ) {
- $RT::Logger->warning("failed to jsmin $file: $error ");
- }
- else {
- $content .= $output;
- next;
- }
+ local $SIG{'CHLD'} = 'DEFAULT';
+ require IPC::Run;
+ IPC::Run::run( [$jsmin], \$input, \$output, \$error );
+ if ( $? >> 8 ) {
+ $RT::Logger->warning("failed to jsmin: $error ");
}
-
- unless ( defined $has_jsmin_module ) {
- eval { require JavaScript::Minifier };
- if ($@) {
- $RT::Logger->debug("can't load JavaScript::Minifier: $@");
- $has_jsmin_module = 0; # don't try again
- }
- else {
- $has_jsmin_module = 1;
- }
+ else {
+ $content = $output;
+ $minified = 1;
}
+ }
- if ($has_jsmin_module) {
- $content .= JavaScript::Minifier::minify( input => $input );
- next;
+ unless ($minified) {
+ eval { require JavaScript::Minifier };
+ if ($@) {
+ $RT::Logger->debug("can't load JavaScript::Minifier: $@");
+ }
+ else {
+ $content = JavaScript::Minifier::minify( input => $content );
}
-
- $content .= $input;
}
}
-
$m->out( $content );
}
else {
commit 6d992edc268a969bdd480b6b9adea5640e662924
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Jul 31 08:32:07 2010 +0800
add JSFilesInHead config so we can have a better place to customize
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 13752f1..d96b39d 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1805,12 +1805,25 @@ C<Set(@Plugins, (qw(Extension::QuickDelete RT::FM)));>
Set(@Plugins, ());
+=item C<@JSFilesInHead>
+
+a list of js files to be included in head
+
+Example:
+
+C<Set(@JSFilesInHead, qw/jquery-1.4.2.min.js jquery_noconflict.js jquery.autocomplete-min.js jquery-ui-1.7.3.custom.min.js jquery.timepickr.js titlebox-state.js util.js/ )>;
+
+=cut
+
+Set(@JSFilesInHead, qw/jquery-1.4.2.min.js jquery_noconflict.js jquery.autocomplete-min.js jquery-ui-1.7.3.custom.min.js jquery.timepickr.js titlebox-state.js util.js/);
+
+
=item C<$JSMinPath>
Path to jsmin binary.
You can go to http://www.crockford.com/javascript/jsmin.html to get one.
-If specified, it'll be used to minify javascript files.
+If specified, it'll be used to minify C<JSFilesInHead>.
If fails, RT will then try module L<JavaScript::Minifier>.
If that still fails, RT will simply concatenate js files.
diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index cc4f1b4..f115487 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -51,13 +51,8 @@ $onload => undef
</%args>
% if ( RT->Config->Get('DevelMode' ) ) {
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/jquery-1.4.2.min.js"></script>
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/jquery_noconflict.js"></script>
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/jquery.autocomplete-min.js"></script>
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/jquery-ui-1.7.3.custom.min.js"></script>
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/jquery.timepickr.js"></script>
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/util.js"></script>
-<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/titlebox-state.js"></script>
+% for my $jsfile ( RT->Config->Get('JSFilesInHead') ) {
+<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/<% $jsfile %>"></script>
% }
% else {
<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/squished.js"></script>
diff --git a/share/html/NoAuth/js/dhandler b/share/html/NoAuth/js/dhandler
index a65dc8a..11f1f2fc 100644
--- a/share/html/NoAuth/js/dhandler
+++ b/share/html/NoAuth/js/dhandler
@@ -56,10 +56,8 @@ if ( $arg =~ m{squished\.js$} ) {
$path = $m->current_comp->dir_path;
unless ( $content ) {
require File::Spec;
- my @js =
- qw/jquery-1.4.2.min.js jquery_noconflict.js jquery.autocomplete-min.js jquery-ui-1.7.3.custom.min.js jquery.timepickr.js titlebox-state.js util.js/;
- for my $js (@js) {
+ for my $js ( RT->Config->Get('JSFilesInHead') ) {
my $file = File::Spec->catfile( $path, $js );
my $input = $m->scomp($file);
$content .= $input;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list