Commit ce0bbc11 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 829709: Do not load CSS files from all skins by default

r=dkl a=LpSolit
parent e0d91b4a
...@@ -419,13 +419,10 @@ sub mtime_filter { ...@@ -419,13 +419,10 @@ sub mtime_filter {
# #
# 1. YUI CSS # 1. YUI CSS
# 2. Standard Bugzilla stylesheet set (persistent) # 2. Standard Bugzilla stylesheet set (persistent)
# 3. Standard Bugzilla stylesheet set (selectable) # 3. Third-party "skin" stylesheet set, per user prefs (persistent)
# 4. All third-party "skin" stylesheet sets (selectable) # 4. Page-specific styles
# 5. Page-specific styles # 5. Custom Bugzilla stylesheet set (persistent)
# 6. Custom Bugzilla stylesheet set (persistent)
#
# "Selectable" skin file sets may be either preferred or alternate.
# Exactly one is preferred, determined by the "skin" user preference.
sub css_files { sub css_files {
my ($style_urls, $yui, $yui_css) = @_; my ($style_urls, $yui, $yui_css) = @_;
...@@ -442,18 +439,10 @@ sub css_files { ...@@ -442,18 +439,10 @@ sub css_files {
my @css_sets = map { _css_link_set($_) } @requested_css; my @css_sets = map { _css_link_set($_) } @requested_css;
my %by_type = (standard => [], alternate => {}, skin => [], custom => []); my %by_type = (standard => [], skin => [], custom => []);
foreach my $set (@css_sets) { foreach my $set (@css_sets) {
foreach my $key (keys %$set) { foreach my $key (keys %$set) {
if ($key eq 'alternate') { push(@{ $by_type{$key} }, $set->{$key});
foreach my $alternate_skin (keys %{ $set->{alternate} }) {
my $files = $by_type{alternate}->{$alternate_skin} ||= [];
push(@$files, $set->{alternate}->{$alternate_skin});
}
}
else {
push(@{ $by_type{$key} }, $set->{$key});
}
} }
} }
...@@ -470,27 +459,15 @@ sub _css_link_set { ...@@ -470,27 +459,15 @@ sub _css_link_set {
if ($file_name !~ m{(^|/)skins/standard/}) { if ($file_name !~ m{(^|/)skins/standard/}) {
return \%set; return \%set;
} }
my $skin_user_prefs = Bugzilla->user->settings->{skin}; my $skin = Bugzilla->user->settings->{skin}->{value};
my $cgi_path = bz_locations()->{'cgi_path'}; my $cgi_path = bz_locations()->{'cgi_path'};
# If the DB is not accessible, user settings are not available. my $skin_file_name = $file_name;
my $all_skins = $skin_user_prefs ? $skin_user_prefs->legal_values : []; $skin_file_name =~ s{(^|/)skins/standard/}{skins/contrib/$skin/};
my %skin_urls; if (my $mtime = _mtime("$cgi_path/$skin_file_name")) {
foreach my $option (@$all_skins) { $set{skin} = mtime_filter($skin_file_name, $mtime);
next if $option eq 'standard';
my $skin_file_name = $file_name;
$skin_file_name =~ s{(^|/)skins/standard/}{skins/contrib/$option/};
if (my $mtime = _mtime("$cgi_path/$skin_file_name")) {
$skin_urls{$option} = mtime_filter($skin_file_name, $mtime);
}
}
$set{alternate} = \%skin_urls;
my $skin = $skin_user_prefs->{'value'};
if ($skin ne 'standard' and defined $set{alternate}->{$skin}) {
$set{skin} = delete $set{alternate}->{$skin};
} }
my $custom_file_name = $file_name; my $custom_file_name = $file_name;
$custom_file_name =~ s{(^|/)skins/standard/}{skins/custom/}; $custom_file_name =~ s{(^|/)skins/standard/}{skins/custom/};
if (my $custom_mtime = _mtime("$cgi_path/$custom_file_name")) { if (my $custom_mtime = _mtime("$cgi_path/$custom_file_name")) {
......
...@@ -22,10 +22,6 @@ ...@@ -22,10 +22,6 @@
# atomlink: Atom link URL, May contain HTML # atomlink: Atom link URL, May contain HTML
#%] #%]
[% IF message %]
[% PROCESS global/messages.html.tmpl %]
[% END %]
[% DEFAULT [% DEFAULT
subheader = "" subheader = ""
header_addl_info = "" header_addl_info = ""
...@@ -95,12 +91,8 @@ ...@@ -95,12 +91,8 @@
[% SET yui = yui_resolve_deps(yui, yui_deps) %] [% SET yui = yui_resolve_deps(yui, yui_deps) %]
[% SET css_sets = css_files(style_urls, yui, yui_css) %] [% SET css_sets = css_files(style_urls, yui, yui_css) %]
[%# CSS cascade, part 1: Standard Bugzilla stylesheet set (persistent). [%# CSS cascade, parts 1 & 2: YUI & Standard Bugzilla stylesheet set (persistent).
# Always present. # Always present. %]
#%]
[%# This allows people to switch back to the "Classic" skin if they
# are in another skin.
#%]
<link href="[% 'skins/standard/global.css' FILTER mtime FILTER html %]" <link href="[% 'skins/standard/global.css' FILTER mtime FILTER html %]"
rel="alternate stylesheet" rel="alternate stylesheet"
title="[% setting_descs.standard FILTER html %]"> title="[% setting_descs.standard FILTER html %]">
...@@ -108,22 +100,12 @@ ...@@ -108,22 +100,12 @@
[% PROCESS format_css_link css_set_name = 'standard' %] [% PROCESS format_css_link css_set_name = 'standard' %]
[% END %] [% END %]
[%# CSS cascade, part 2 & 3: Third-party stylesheet set (selected and [%# CSS cascade, part 3: Third-party stylesheet set, per user prefs. %]
# selectable). All third-party skins are present as alternate
# stylesheets, even if they are not currently in use.
#%]
[% FOREACH style_url = css_sets.skin %] [% FOREACH style_url = css_sets.skin %]
[% PROCESS format_css_link css_set_name = user.settings.skin.value %] [% PROCESS format_css_link css_set_name = user.settings.skin.value %]
[% END %] [% END %]
[% FOREACH alternate_skin = css_sets.alternate.keys %] [%# CSS cascade, part 4: page-specific styles. %]
[% FOREACH style_url = css_sets.alternate.$alternate_skin %]
[% PROCESS format_css_link css_set_name = alternate_skin %]
[% END %]
[% END %]
[%# CSS cascade, part 4: page-specific styles.
#%]
[% IF style %] [% IF style %]
<style type="text/css"> <style type="text/css">
[% style %] [% style %]
...@@ -296,7 +278,8 @@ ...@@ -296,7 +278,8 @@
[% END %] [% END %]
[% IF message %] [% IF message %]
<div id="message">[% message %]</div> [% PROCESS global/messages.html.tmpl %]
<div id="message">[% message %]</div>
[% END %] [% END %]
[% BLOCK format_css_link %] [% BLOCK format_css_link %]
...@@ -308,26 +291,15 @@ ...@@ -308,26 +291,15 @@
#%] #%]
[% END %] [% END %]
[% IF css_set_name == 'standard'
OR css_set_name == user.settings.skin.value
%]
[% SET css_rel = 'stylesheet' %]
[% SET css_set_display_name = setting_descs.${user.settings.skin.value}
|| user.settings.skin.value %]
[% ELSE %]
[% SET css_rel = 'alternate stylesheet' %]
[% SET css_set_display_name = setting_descs.$css_set_name || css_set_name %]
[% END %]
[% IF css_set_name == 'standard' %] [% IF css_set_name == 'standard' %]
[% SET css_title_link = '' %] [% SET css_title_link = '' %]
[% ELSE %] [% ELSE %]
[% css_title_link = BLOCK ~%] [% css_title_link = BLOCK ~%]
title="[% css_set_display_name FILTER html %]" title="[% setting_descs.${user.settings.skin.value} || user.settings.skin.value FILTER html %]"
[% END %] [% END %]
[% END %] [% END %]
<link href="[% style_url FILTER html %]" rel="[% css_rel FILTER none %]" <link href="[% style_url FILTER html %]" rel="stylesheet"
type="text/css" [% css_title_link FILTER none %]> type="text/css" [% css_title_link FILTER none %]>
[% '<![endif]-->' IF style_url.match('/IE-fixes\.css') %] [% '<![endif]-->' IF style_url.match('/IE-fixes\.css') %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment