Skip to content

Commit 23de40b

Browse files
committed
Update outdated-page's style and warning with a link to a support article. (Fixes #170)
1 parent 2109e89 commit 23de40b

4 files changed

Lines changed: 140 additions & 66 deletions

File tree

helper.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import json
88
import markdown
99
import re
10+
11+
import product_details
1012
import settings
1113
import sys
1214
import translate
@@ -470,6 +472,33 @@ def get_form_assembly_localization_url(ctx):
470472
return "https://mozillafoundation.tfaforms.net/wForms/3.11/js/localization-{locale}.js?v=75513df1680ccc55e2c889a1b1dff356256982a6".format(locale=fa_locale)
471473

472474

475+
@jinja2.pass_context
476+
def get_outdated_versions(ctx):
477+
""" Get a JSON str of versions and dates of the last released minor version for outdated versions. """
478+
versions = product_details.thunderbird_desktop.list_releases()
479+
last_stable_release = {}
480+
last_safe_release = float(settings.LAST_SAFE_VERSION)
481+
482+
for version in versions:
483+
# major is a float, minor is a string
484+
major_version = version[0]
485+
minor_versions = version[1]['minor']
486+
487+
if len(minor_versions) > 0:
488+
last_version = minor_versions[-1]
489+
else:
490+
last_version = str(major_version)
491+
492+
# Don't include safe versions
493+
if major_version >= last_safe_release:
494+
continue
495+
496+
release_date = product_details.thunderbird_desktop.get_release_date(last_version)
497+
last_stable_release[major_version] = release_date
498+
499+
return json.dumps(last_stable_release)
500+
501+
473502
def is_calendarific_free_tier():
474503
"""Returns if we're expecting to use the Calendarific free tier"""
475504
try:

settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
'privacy.notices.websites': 'https://www.mozilla.org/privacy/websites/#data-tools',
171171
'privacy.notices.thunderbird': 'https://www.mozilla.org/privacy/thunderbird/',
172172
'support': 'https://support.mozilla.org/products/thunderbird/',
173+
'support.old-version-upgrade': 'https://support.mozilla.org/kb/upgrading-older-version-thunderbird',
173174
'thunderbird.about': '/about',
174175
'thunderbird.about.our-mission-statement': '/about#our-mission-statement',
175176
'thunderbird.careers': '/careers',
@@ -387,3 +388,5 @@
387388
'US': ('United States', 'en'),
388389
'VN': ('Vietnam', 'vi'),
389390
}
391+
392+
LAST_SAFE_VERSION = 102

start-page/_base-resp.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<title>{% filter striptags|e %}{% block title %}{% endblock %}{% endfilter %}</title>
1111
{{ l10n_css() }}
1212
<link href="/media/css/start-style.css" rel="stylesheet" type="text/css" />
13+
{% block additional_head %}{% endblock %}
1314
</head>
1415
<body class="start-bg">
1516
<main>

start-page/outdated/index.html

Lines changed: 107 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,122 @@
11
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
4-
5-
<!DOCTYPE html>
6-
<html lang="{{ LANG|replace('en-US', 'en') }}" dir="{{ DIR }}">
7-
<head>
8-
<meta charset="utf-8">
9-
<meta name="robots" content="noindex">
10-
<title>{% block title %}{{ _('Your Thunderbird is Not Up-to-Date!') }}{% endblock %}</title>
11-
{{ l10n_css() }}
12-
<!-- Fontawesome added below -->
13-
<link href="/media/css/fontawesome-all.css" rel="stylesheet">
14-
<!--<script defer src="/media/js/fontawesome-all.js"></script>-->
15-
<style>
16-
body {
17-
background-color: #D46A6A;
18-
text-align: center;
19-
}
20-
</style>
21-
</head>
22-
<body>
23-
<main>
24-
<h1><b><i class="fas fa-exclamation-triangle fa-3x" style="color:#0060df"></i> {{ self.title() }}</b></h1>
25-
<h2 id="duration">{{ _('Your version, $vers, is no longer a supported Thunderbird release and hasn’t received updates in at least $mon months.') }}</h2>
26-
<p class="fa-lg">{{ _('We <b>strongly recommend</b> downloading the <a href="%(download_url)s">latest stable version of Thunderbird</a>.')|format(download_url='https://thunderbird.net') }}</p>
27-
<p class="fa-lg">{{ _('For more information, please check this <a href="%(support_url)s">support article</a> on upgrading old versions.')|format(support_url='https://support.mozilla.org/en-US/products/thunderbird') }}</p>
28-
</main>
29-
</body>
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
4+
5+
{% extends "_base-resp.html" %}
6+
7+
{% block channel %}release{% endblock %}
8+
{% block title %}{{ _('Your Thunderbird is Not Up-to-Date!') }}{% endblock %}
9+
10+
{% block additional_head %}
11+
<style>
12+
body {
13+
background-image: none;
14+
background-color: #991b1b;
15+
color: #f1f3fa;
16+
text-shadow: 1px 1px 0 black;;
17+
text-align: center;
18+
}
19+
20+
.main-content {
21+
display: block;
22+
}
23+
24+
#outdated-message {
25+
text-align: center;
26+
}
27+
.outdated-warning-icon {
28+
display: inline-block;
29+
position: relative;
30+
top: 8px;
31+
width: 32px;
32+
height: 32px;
33+
color: #88ccfc;
34+
}
35+
a {
36+
text-decoration: underline !important;
37+
color: #88ccfc;
38+
}
39+
a:visited {
40+
color: #88ccfc;
41+
text-decoration: underline !important;
42+
}
43+
#duration {
44+
text-align: center;
45+
margin: auto;
46+
width: 75%;
47+
}
48+
</style>
49+
{% endblock %}
50+
51+
{% block main %}
52+
<div class="main-content">
53+
<section id="outdated-message">
54+
<h1><b><span class="outdated-warning-icon">{{ svg('warning') }}</span> {{ self.title() }}</b></h1>
55+
<h2 id="duration">{{ _('Thunderbird $vers is no longer supported and hasn’t received security updates in at least $time.') }}</h2>
56+
<p>{{ _('We <b>strongly recommend</b> downloading the
57+
<a href="%(download_url)s">latest stable version of Thunderbird</a>.')|format(download_url='https://thunderbird.net') }}
58+
</p>
59+
<p>{{ _('For more information, please check this
60+
<a href="%(support_url)s">support article</a> on upgrading old versions.')|format(support_url=url('support.old-version-upgrade')) }}
61+
</p>
62+
</section>
63+
</div>
3064
<script>
65+
// Date of last security release for each major version.
66+
version_dates = {{ get_outdated_versions() }}
67+
68+
function getVersionDate(version) {
69+
return new Date(version_dates[version]);
70+
}
3171

32-
// Date of last security release for each major version.
33-
version_dates = {
34-
24: new Date(2014, 8, 2),
35-
31: new Date(2015, 6, 17),
36-
38: new Date(2016, 4, 4),
37-
45: new Date(2017, 2, 7),
38-
52: new Date(2018, 6, 10),
39-
60: new Date(2019, 10, 5)
40-
}
41-
42-
function monthDiff(dateFrom, dateTo) {
43-
return dateTo.getMonth() - dateFrom.getMonth() +
44-
(12 * (dateTo.getFullYear() - dateFrom.getFullYear()))
45-
}
46-
47-
function get_browser() {
48-
var ua=navigator.userAgent,tem,M=ua.match(/(firefox|thunderbird(?=\/))\/?\s*(\d+)/i) || [];
49-
M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
50-
if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);}
72+
function monthDiff(dateFrom, dateTo) {
73+
return dateTo.getMonth() - dateFrom.getMonth() +
74+
(12 * (dateTo.getFullYear() - dateFrom.getFullYear()))
75+
}
76+
77+
function get_browser() {
78+
var ua = navigator.userAgent, tem, M = ua.match(/(firefox|thunderbird(?=\/))\/?\s*(\d+)/i) || [];
79+
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
80+
if ((tem = ua.match(/version\/(\d+)/i)) != null) {
81+
M.splice(1, 1, tem[1]);
82+
}
5183
return {
5284
name: M[0],
5385
version: M[1]
5486
};
55-
}
87+
}
88+
89+
// Clamp the version number to the closest among version_dates.
90+
function get_version(vers) {
91+
// This instead of Object.keys() for compatibility with old versions.
92+
var versions = [], i = 0;
93+
for (versions[i++] in version_dates) {
94+
}
5695

57-
// Clamp the version number to the closest among version_dates.
58-
function get_version(vers) {
59-
// This instead of Object.keys() for compatibility with old versions.
60-
var versions = [], i = 0;
61-
for (versions[i++] in version_dates) {}
96+
var closest = versions.reduce(function (prev, curr) {
97+
return (Math.abs(curr - vers) < Math.abs(prev - vers) ? curr : prev);
98+
});
6299

63-
var closest = versions.reduce(function(prev, curr) {
64-
return (Math.abs(curr - vers) < Math.abs(prev - vers) ? curr : prev);
65-
});
100+
return closest;
101+
}
66102

67-
return closest;
68-
}
103+
// browser.name = 'Thunderbird', browser.version = '60'
104+
var browser = get_browser();
105+
clamped_version = get_version(browser.version);
69106

70-
// browser.name = 'Thunderbird', browser.version = '60'
71-
var browser=get_browser();
72-
clamped_version = get_version(browser.version);
107+
var rel_date = getVersionDate(clamped_version) || new Date();
108+
var num_time = monthDiff(rel_date, new Date()) || 12;
109+
var time_unit = 'months';
73110

74-
var rel_date = version_dates[clamped_version] || new Date();
75-
var num_months = monthDiff(rel_date, new Date()) || 12;
111+
if (num_time > 12) {
112+
num_time = Math.round(num_time / 12);
113+
time_unit = num_time > 1 ? 'years' : 'year';
114+
}
76115

77-
duration = document.getElementById('duration').innerHTML;
78-
document.getElementById('duration').innerHTML = duration.replace('$mon', num_months).replace('$vers', browser.version);
116+
// Can't use template literal :(
117+
var time_string = num_time + " " + time_unit;
79118

119+
duration = document.getElementById('duration').innerHTML;
120+
document.getElementById('duration').innerHTML = duration.replace('$time', time_string).replace('$vers', browser.version);
80121
</script>
81-
</html>
122+
{% endblock %}

0 commit comments

Comments
 (0)