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 --- template/en/default/global/header.html.tmpl | 201 ++++++++++------------------ template/en/default/setup/strings.txt.pl | 2 + 2 files changed, 75 insertions(+), 128 deletions(-) (limited to 'template') diff --git a/template/en/default/global/header.html.tmpl b/template/en/default/global/header.html.tmpl index 721afd7af..549fd538f 100644 --- a/template/en/default/global/header.html.tmpl +++ b/template/en/default/global/header.html.tmpl @@ -64,6 +64,14 @@ datatable => ['json', 'connection', 'datasource', 'element'], } %] +[%# These are JS URLs that are *always* on the page and come before + # every other JS URL. + #%] +[% SET starting_js_urls = [ + "js/yui/yahoo-dom-event/yahoo-dom-event.js", + "js/yui/cookie/cookie-min.js", +] %] + [%# We should be able to set the default value of the header variable # to the value of the title variable using the DEFAULT directive, @@ -87,118 +95,33 @@ [% PROCESS 'global/setting-descs.none.tmpl' %] - [%# Set up the skin CSS cascade: - # 0. YUI CSS - # 1. Standard Bugzilla stylesheet set (persistent) - # 2. Standard Bugzilla stylesheet set (selectable) - # 3. All third-party "skin" stylesheet sets (selectable) - # 4. Page-specific styles - # 5. 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. - #%] - [% IF user.settings.skin.value != 'standard' %] - [% user_skin = user.settings.skin.value %] - [% END %] - [% style_urls.unshift('skins/standard/global.css') %] - - [%# YUI dependency resolution %] - [%# We have to do this in a separate array, because modifying the - # existing array by unshift'ing dependencies confuses FOREACH. - #%] - [% SET yui_resolved = [] %] - [% FOREACH yui_name = yui %] - [% FOREACH yui_dep = yui_deps.${yui_name}.reverse %] - [% yui_resolved.push(yui_dep) IF NOT yui_resolved.contains(yui_dep) %] - [% END %] - [% yui_resolved.push(yui_name) IF NOT yui_resolved.contains(yui_name) %] - [% END %] - [% SET yui = yui_resolved %] - - [%# YUI CSS %] - [% FOREACH yui_name = yui %] - [% IF yui_css.$yui_name %] - - [% END %] - [% END %] + [% SET yui = yui_resolve_deps(yui, yui_deps) %] + [% SET css_sets = css_files(style_urls, yui, yui_css) %] [%# CSS cascade, part 1: Standard Bugzilla stylesheet set (persistent). # Always present. #%] - [% FOREACH style_url = style_urls %] - + [%# This allows people to switch back to the "Classic" skin if they + # are in another skin. + #%] + + [% FOREACH style_url = css_sets.standard %] + [% PROCESS format_css_link css_set_name = 'standard' %] [% END %] - - [%# CSS cascade, part 2: Standard Bugzilla stylesheet set (selectable) - # Present if skin selection is enabled. + [%# CSS cascade, part 2 & 3: Third-party stylesheet set (selected and + # selectable). All third-party skins are present as alternate + # stylesheets, even if they are not currently in use. #%] - [% IF user.settings.skin.is_enabled %] - [% FOREACH style_url = style_urls %] - - [% END %] - + [% FOREACH style_url = css_sets.skin %] + [% PROCESS format_css_link css_set_name = user.settings.skin.value %] [% END %] - [%# CSS cascade, part 3: Third-party stylesheet set (selectable). - # All third-party skins are present if skin selection is enabled. - # The admin-selected skin is always present. - #%] - [% FOREACH contrib_skin = user.settings.skin.legal_values %] - [% NEXT IF contrib_skin == 'standard' %] - [% NEXT UNLESS contrib_skin == user_skin - OR user.settings.skin.is_enabled %] - [% contrib_skin = contrib_skin FILTER url_quote %] - [% IF contrib_skin.match('\.css$') %] - [%# 1st skin variant: single-file stylesheet %] - - [% ELSE %] - [%# 2nd skin variant: stylesheet set %] - [% FOREACH style_url = style_urls %] - [% IF style_url.match('^skins/standard/') %] - - [% END %] - [% END %] - + [% FOREACH alternate_skin = css_sets.alternate.keys %] + [% FOREACH style_url = css_sets.alternate.$alternate_skin %] + [% PROCESS format_css_link css_set_name = alternate_skin %] [% END %] [% END %] @@ -214,33 +137,19 @@ # Always present. Site administrators may override all other style # definitions, including skins, using custom stylesheets. #%] - [% FOREACH style_url = style_urls %] - [% IF style_url.match('^skins/standard/') %] - - [% END %] + [% FOREACH style_url = css_sets.custom %] + [% PROCESS format_css_link css_set_name = 'standard' %] [% END %] - [%# YUI Scripts %] - - [% FOREACH yui_name = yui %] - + [% starting_js_urls.push("js/yui/$yui_name/${yui_name}.js") %] [% END %] + [% starting_js_urls.push('js/global.js') %] - + [% FOREACH javascript_url = starting_js_urls %] + [% PROCESS format_js_link %] + [% END %] - [% IF javascript_urls %] - [% FOREACH javascript_url = javascript_urls %] - - [% END %] + [% FOREACH javascript_url = javascript_urls %] + [% PROCESS format_js_link %] [% END %] [%# this puts the live bookmark up on firefox for the Atom feed %] @@ -380,3 +287,41 @@ [% IF message %]
[% message %]
[% END %] + +[% BLOCK format_css_link %] + [% IF style_url.match('/IE-fixes\.css') %] + ' IF style_url.match('/IE-fixes\.css') %] +[% END %] + +[% BLOCK format_js_link %] + +[% END %] diff --git a/template/en/default/setup/strings.txt.pl b/template/en/default/setup/strings.txt.pl index 7e590cb3e..62b645672 100644 --- a/template/en/default/setup/strings.txt.pl +++ b/template/en/default/setup/strings.txt.pl @@ -71,6 +71,8 @@ END feature_updates => 'Automatic Update Notifications', feature_xmlrpc => 'XML-RPC Interface', + file_remove => 'Removing ##name##...', + file_rename => 'Renaming ##from## to ##to##...', header => "* This is Bugzilla ##bz_ver## on perl ##perl_ver##\n" . "* Running on ##os_name## ##os_ver##", install_all => <