From 049ea3d136ca73c82f5aa530f328d2596f8e6090 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 27 May 2014 13:34:53 +0800 Subject: Bug 1014374: backport bug 977969 to bmo (concatenate and slightly minify css files) --- .gitignore | 1 - Bugzilla/Constants.pm | 1 + Bugzilla/Install/Filesystem.pm | 31 +++++++++++++++++++++++++++---- Bugzilla/Template.pm | 6 +++--- skins/README | 5 +---- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index d55bf70ad..0370a07e0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,5 @@ /data /localconfig /index.html -/skins/assets /template_cache .DS_Store diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index c2fd52a46..ce5a06286 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -680,6 +680,7 @@ sub _bz_locations { # The script should really generate these graphs directly... 'webdotdir' => "$datadir/webdot", 'extensionsdir' => "$libpath/extensions", + 'assetsdir' => "$datadir/assets", }; } diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm index 5ea0917fa..fc05aaacd 100644 --- a/Bugzilla/Install/Filesystem.pm +++ b/Bugzilla/Install/Filesystem.pm @@ -125,6 +125,7 @@ sub FILESYSTEM { my $localconfig = bz_locations()->{'localconfig'}; my $template_cache = bz_locations()->{'template_cache'}; my $graphsdir = bz_locations()->{'graphsdir'}; + my $assetsdir = bz_locations()->{'assetsdir'}; # We want to set the permissions the same for all localconfig files # across all PROJECTs, so we do something special with $localconfig, @@ -211,7 +212,7 @@ sub FILESYSTEM { dirs => DIR_CGI_WRITE | DIR_ALSO_WS_SERVE }, "$datadir/db" => { files => CGI_WRITE, dirs => DIR_CGI_WRITE }, - "$skinsdir/assets" => { files => WS_SERVE, + $assetsdir => { files => WS_SERVE, dirs => DIR_CGI_OVERWRITE | DIR_ALSO_WS_SERVE }, # Readable directories @@ -275,7 +276,8 @@ sub FILESYSTEM { # The name of each directory that we should actually *create*, # pointing at its default permissions. my %create_dirs = ( - # This is DIR_ALSO_WS_SERVE because it contains $webdotdir. + # This is DIR_ALSO_WS_SERVE because it contains $webdotdir and + # $assetsdir. $datadir => DIR_CGI_OVERWRITE | DIR_ALSO_WS_SERVE, # Directories that are read-only for cgi scripts "$datadir/mining" => DIR_CGI_READ, @@ -286,7 +288,7 @@ sub FILESYSTEM { $attachdir => DIR_CGI_WRITE, $graphsdir => DIR_CGI_WRITE | DIR_ALSO_WS_SERVE, $webdotdir => DIR_CGI_WRITE | DIR_ALSO_WS_SERVE, - "$skinsdir/assets" => DIR_CGI_WRITE | DIR_ALSO_WS_SERVE, + $assetsdir => DIR_CGI_WRITE | DIR_ALSO_WS_SERVE, # Directories that contain content served directly by the web server. "$skinsdir/custom" => DIR_WS_SERVE, "$skinsdir/contrib" => DIR_WS_SERVE, @@ -376,6 +378,18 @@ EOT Deny from all EOT }, + + "$assetsdir/.htaccess" => { perms => WS_SERVE, contents => < + Allow from all + + +# And no directory listings, either. +Deny from all +EOT + }, + ); Bugzilla::Hook::process('install_filesystem', { @@ -534,9 +548,18 @@ sub _convert_single_file_skins { # delete all automatically generated css files to force recreation at the next # request. sub _remove_dynamic_css_files { - foreach my $file (glob(bz_locations()->{skinsdir} . '/assets/*.css')) { + foreach my $file (glob(bz_locations()->{assetsdir} . '/*.css')) { unlink($file); } + + # remove old skins/assets directory + my $old_path = bz_locations()->{skinsdir} . '/assets'; + if (-d $old_path) { + foreach my $file (glob("$old_path/*.css")) { + unlink($file); + } + rmdir($old_path); + } } sub create_htaccess { diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index d36ffd473..b805a5a2c 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -478,13 +478,13 @@ sub _concatenate_css { } @sources; my $cgi_path = bz_locations()->{cgi_path}; - my $skins_path = bz_locations()->{skinsdir}; + my $skins_path = bz_locations()->{assetsdir}; # build minified files my @minified; foreach my $source (@sources) { next unless -e "$cgi_path/$files{$source}"; - my $file = $skins_path . '/assets/' . md5_hex($source) . '.css'; + my $file = $skins_path . '/' . md5_hex($source) . '.css'; if (!-e $file) { my $content = read_file("$cgi_path/$files{$source}"); @@ -502,7 +502,7 @@ sub _concatenate_css { } # concat files - my $file = $skins_path . '/assets/' . md5_hex(join(' ', @sources)) . '.css'; + my $file = $skins_path . '/' . md5_hex(join(' ', @sources)) . '.css'; if (!-e $file) { my $content = ''; foreach my $source (@minified) { diff --git a/skins/README b/skins/README index 1deac48a2..d649350b9 100644 --- a/skins/README +++ b/skins/README @@ -1,4 +1,4 @@ -There are four directories here, standard/, custom/, contrib/, and assets/. +There are three directories here, standard/, custom/, and contrib/. standard/ holds the standard stylesheets. These are used no matter what skin the user selects. If the user selects the "Classic" skin, then *only* the @@ -16,6 +16,3 @@ if you want to override some CSS in skins/standard/global.css, then you should create a file called "global.css" in custom/ and put some CSS in it. The CSS you put into files in custom/ will be used *in addition* to the CSS in skins/standard/ or the CSS in skins/contrib/. It will apply to every skin. - -assets/ holds the minified and concatenated files which are created by -checksetup.pl and Bugzilla::Template. Do not edit the files in this directory. -- cgit v1.2.3-24-g4f1b