From 10f4954b4530a67d88c66ba8e397ee81487f4752 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Tue, 20 Jul 2010 20:34:41 -0700 Subject: Bug 428313: Properly expire the browser's CSS and JS cache when there are new versions of those files. This also eliminates single-file skins and should also allow Extensions to have skins. r=glob, a=mkanat --- Bugzilla/Install/Filesystem.pm | 59 ++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 20 deletions(-) (limited to 'Bugzilla/Install/Filesystem.pm') diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm index db55576a4..20bd021ef 100644 --- a/Bugzilla/Install/Filesystem.pm +++ b/Bugzilla/Install/Filesystem.pm @@ -284,20 +284,6 @@ sub FILESYSTEM { contents => '' }, ); - # Each standard stylesheet has an associated custom stylesheet that - # we create. Also, we create placeholders for standard stylesheets - # for contrib skins which don't provide them themselves. - foreach my $skin_dir ("$skinsdir/custom", <$skinsdir/contrib/*>) { - next if basename($skin_dir) =~ /^cvs$/i; - foreach my $base_css (<$skinsdir/standard/*.css>) { - _add_custom_css($skin_dir, basename($base_css), \%create_files); - } - foreach my $dir_css (<$skinsdir/standard/*/*.css>) { - $dir_css =~ s{.+?([^/]+/[^/]+)$}{$1}; - _add_custom_css($skin_dir, $dir_css, \%create_files); - } - } - # Because checksetup controls the creation of index.html separately # from all other files, it gets its very own hash. my %index_html = ( @@ -455,20 +441,53 @@ EOT print "Removing duplicates directory...\n"; rmtree("$datadir/duplicates"); } + + _remove_empty_css_files(); + _convert_single_file_skins(); } -# A simple helper for creating "empty" CSS files. -sub _add_custom_css { - my ($skin_dir, $path, $create_files) = @_; - $create_files->{"$skin_dir/$path"} = { perms => WS_SERVE, contents => <{'skinsdir'}; + foreach my $css_file (glob("$skinsdir/custom/*.css"), + glob("$skinsdir/contrib/*/*.css")) + { + _remove_empty_css($css_file); + } +} + +# A simple helper for the update code that removes "empty" CSS files. +sub _remove_empty_css { + my ($file) = @_; + my $basename = basename($file); + my $empty_contents = <; } + if ($file_contents eq $empty_contents) { + print install_string('file_remove', { name => $file }), "\n"; + unlink $file or warn "$file: $!"; + } }; } +# We used to allow a single css file in the skins/contrib/ directory +# to be a whole skin. +sub _convert_single_file_skins { + my $skinsdir = bz_locations()->{'skinsdir'}; + foreach my $skin_file (glob "$skinsdir/contrib/*.css") { + my $dir_name = $skin_file; + $dir_name =~ s/\.css$//; + mkdir $dir_name or warn "$dir_name: $!"; + _rename_file($skin_file, "$dir_name/global.css"); + } +} + sub create_htaccess { _create_files(%{FILESYSTEM()->{htaccess}}); @@ -492,7 +511,7 @@ sub create_htaccess { sub _rename_file { my ($from, $to) = @_; - print "Renaming $from to $to...\n"; + print install_string('file_rename', { from => $from, to => $to }), "\n"; if (-e $to) { warn "$to already exists, not moving\n"; } -- cgit v1.2.3-24-g4f1b