summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Install
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-05-17 22:19:36 +0200
committerDylan William Hardison <dylan@hardison.net>2017-05-17 23:07:31 +0200
commit3a372a916f3545d37390f692f24f7e1c4d5351b5 (patch)
tree2e0cd93ee1a897e196e86eedfa1233a37cbb2dae /Bugzilla/Install
parent38b13ae3f1885faa0da1d0040a0dda87dc786515 (diff)
downloadbugzilla-3a372a916f3545d37390f692f24f7e1c4d5351b5.tar.gz
bugzilla-3a372a916f3545d37390f692f24f7e1c4d5351b5.tar.xz
Bug 1363803 - Consolidate YUI js and css into one js and one css file
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r--Bugzilla/Install/Filesystem.pm77
1 files changed, 76 insertions, 1 deletions
diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm
index 7cfda8304..79eeca98e 100644
--- a/Bugzilla/Install/Filesystem.pm
+++ b/Bugzilla/Install/Filesystem.pm
@@ -30,6 +30,8 @@ use File::Find;
use File::Path;
use File::Basename;
use File::Copy qw(move);
+use File::Spec;
+use Cwd ();
use File::Slurp;
use IO::File;
use POSIX ();
@@ -350,6 +352,36 @@ sub FILESYSTEM {
"$skinsdir/contrib" => DIR_WS_SERVE,
);
+ my $yui_all_css = sub {
+ return join("\n",
+ map {
+ my $css = read_file($_);
+ _css_url_fix($css, $_, "skins/yui.css.list")
+ } read_file("skins/yui.css.list", { chomp => 1 })
+ );
+ };
+
+ my $yui_all_js = sub {
+ return join("\n",
+ map { scalar read_file($_) } read_file("js/yui.js.list", { chomp => 1 })
+ );
+ };
+
+ my $yui3_all_css = sub {
+ return join("\n",
+ map {
+ my $css = read_file($_);
+ _css_url_fix($css, $_, "skins/yui3.css.list")
+ } read_file("skins/yui3.css.list", { chomp => 1 })
+ );
+ };
+
+ my $yui3_all_js = sub {
+ return join("\n",
+ map { scalar read_file($_) } read_file("js/yui3.js.list", { chomp => 1 })
+ );
+ };
+
# The name of each file, pointing at its default permissions and
# default contents.
my %create_files = (
@@ -361,6 +393,18 @@ sub FILESYSTEM {
# or something else is not running as the webserver or root.
"$datadir/mailer.testfile" => { perms => CGI_WRITE,
contents => '' },
+ "js/yui.js" => { perms => CGI_READ,
+ overwrite => 1,
+ contents => $yui_all_js },
+ "skins/yui.css" => { perms => CGI_READ,
+ overwrite => 1,
+ contents => $yui_all_css },
+ "js/yui3.js" => { perms => CGI_READ,
+ overwrite => 1,
+ contents => $yui3_all_js },
+ "skins/yui3.css" => { perms => CGI_READ,
+ overwrite => 1,
+ contents => $yui3_all_css },
);
# Because checksetup controls the creation of index.html separately
@@ -520,6 +564,31 @@ sub update_filesystem {
_remove_dynamic_assets();
}
+sub _css_url_fix {
+ my ($content, $from, $to) = @_;
+ my $from_dir = dirname(File::Spec->rel2abs($from, bz_locations()->{libpath}));
+ my $to_dir = dirname(File::Spec->rel2abs($to, bz_locations()->{libpath}));
+
+ return css_url_rewrite(
+ $content,
+ sub {
+ my ($url) = @_;
+ if ( $url =~ m{^(?:/|data:)} ) {
+ return sprintf 'url(%s)', $url;
+ }
+ else {
+ my $new_url = File::Spec->abs2rel(
+ Cwd::realpath(
+ File::Spec->rel2abs( $url, $from_dir )
+ ),
+ $to_dir
+ );
+ return sprintf "url(%s)", $new_url;
+ }
+ }
+ );
+}
+
sub _remove_empty_css_files {
my $skinsdir = bz_locations()->{'skinsdir'};
foreach my $css_file (glob("$skinsdir/custom/*.css"),
@@ -623,7 +692,13 @@ sub _create_files {
print "Creating $file...\n";
my $fh = IO::File->new( $file, O_WRONLY | O_CREAT, $info->{perms} )
or die "unable to write $file: $!";
- print $fh $info->{contents} if exists $info->{contents};
+ my $contents = $info->{contents};
+ if (defined $contents && ref($contents) eq 'CODE') {
+ print $fh $contents->();
+ }
+ elsif (defined $contents) {
+ print $fh $contents;
+ }
$fh->close;
}
}