Skip to content

Commit eeaf4a7

Browse files
committed
Add a helper function to get outdated versions in json format
Throw the old outdated page into the new template, and grab the version/dates (on site builds.) Add a helper function to get outdated versions in json format Throw the old outdated page into the new template, and grab the version/dates (on site builds.) Fix up styling on outdated page
1 parent 2109e89 commit eeaf4a7

5 files changed

Lines changed: 147 additions & 66 deletions

File tree

helper.py

Lines changed: 27 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
@@ -481,5 +483,30 @@ def is_calendarific_free_tier():
481483
def f(s, *args, **kwargs):
482484
return s.format(*args, **kwargs)
483485

486+
@jinja2.contextfunction
487+
def get_outdated_versions(ctx):
488+
""" Get a JSON str of versions and dates of the last released minor version for outdated versions. """
489+
versions = product_details.thunderbird_desktop.list_releases()
490+
last_stable_release = {}
491+
last_safe_release = float(settings.LAST_SAFE_VERSION)
492+
493+
for version in versions:
494+
# major is a float, minor is a string
495+
major_version = version[0]
496+
minor_versions = version[1]['minor']
497+
498+
if len(minor_versions) > 0:
499+
last_version = minor_versions[-1]
500+
else:
501+
last_version = str(major_version)
502+
503+
# Don't include safe versions
504+
if major_version >= last_safe_release:
505+
continue
506+
507+
release_date = product_details.thunderbird_desktop.get_release_date(last_version)
508+
last_stable_release[major_version] = release_date
509+
510+
return json.dumps(last_stable_release)
484511

485512
contextfunctions = dict(inspect.getmembers(sys.modules[__name__], inspect.isfunction))

settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,3 +387,5 @@
387387
'US': ('United States', 'en'),
388388
'VN': ('Vietnam', 'vi'),
389389
}
390+
391+
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/_new-base-resp.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{# 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') }}" data-channel="{% block channel %}{% endblock %}" dir="{{ DIR }}">
7+
<head>
8+
<meta charset="utf-8">
9+
<meta name="robots" content="noindex">
10+
<title>{% filter striptags|e %}{% block title %}{% endblock %}{% endfilter %}</title>
11+
{{ l10n_css() }}
12+
<link href="/media/css/new-start-style.css" rel="stylesheet" type="text/css" />
13+
{% block additional_head %}{% endblock %}
14+
</head>
15+
<body class="start-bg">
16+
<main>
17+
{% block main %}{% endblock %}
18+
</main>
19+
<div class="logo-wireframe-light">
20+
{{ svg('logo-wireframe-light') }}
21+
</div>
22+
<div class="logo-wireframe-dark">
23+
{{ svg('logo-wireframe-dark') }}
24+
</div>
25+
</body>
26+
</html>

start-page/outdated/index.html

Lines changed: 91 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,106 @@
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>
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-warning-icon {
25+
display: inline-block;
26+
position: relative;
27+
top: 8px;
28+
width: 32px;
29+
height: 32px;
30+
color: #88ccfc;
31+
}
32+
a {
33+
text-decoration: underline !important;
34+
color: #88ccfc;
35+
}
36+
a:visited {
37+
color: #88ccfc;
38+
text-decoration: underline !important;
39+
40+
}
41+
</style>
42+
{% endblock %}
43+
44+
{% block main %}
45+
<div class="main-content">
46+
<section id="outdated-message">
47+
<h1><b><span class="outdated-warning-icon">{{ svg('warning') }}</span> {{ self.title() }}</b></h1>
2548
<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>
49+
<p>{{ _('We <b>strongly recommend</b> downloading the
50+
<a href="%(download_url)s">latest stable version of Thunderbird</a>.')|format(download_url='https://thunderbird.net') }}
51+
</p>
52+
<p>{{ _('For more information, please check this
53+
<a href="%(support_url)s">support article</a> on upgrading old versions.')|format(support_url=url('support.old-version-upgrade')) }}
54+
</p>
55+
</section>
56+
</div>
3057
<script>
58+
// Date of last security release for each major version.
59+
version_dates = {{ get_outdated_versions() }}
60+
61+
function getVersionDate(version) {
62+
return new Date(version_dates[version]);
63+
}
3164

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]);}
65+
function monthDiff(dateFrom, dateTo) {
66+
return dateTo.getMonth() - dateFrom.getMonth() +
67+
(12 * (dateTo.getFullYear() - dateFrom.getFullYear()))
68+
}
69+
70+
function get_browser() {
71+
var ua = navigator.userAgent, tem, M = ua.match(/(firefox|thunderbird(?=\/))\/?\s*(\d+)/i) || [];
72+
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
73+
if ((tem = ua.match(/version\/(\d+)/i)) != null) {
74+
M.splice(1, 1, tem[1]);
75+
}
5176
return {
5277
name: M[0],
5378
version: M[1]
5479
};
55-
}
56-
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) {}
80+
}
6281

63-
var closest = versions.reduce(function(prev, curr) {
64-
return (Math.abs(curr - vers) < Math.abs(prev - vers) ? curr : prev);
65-
});
82+
// Clamp the version number to the closest among version_dates.
83+
function get_version(vers) {
84+
// This instead of Object.keys() for compatibility with old versions.
85+
var versions = [], i = 0;
86+
for (versions[i++] in version_dates) {
87+
}
6688

67-
return closest;
68-
}
89+
var closest = versions.reduce(function (prev, curr) {
90+
return (Math.abs(curr - vers) < Math.abs(prev - vers) ? curr : prev);
91+
});
6992

70-
// browser.name = 'Thunderbird', browser.version = '60'
71-
var browser=get_browser();
72-
clamped_version = get_version(browser.version);
93+
return closest;
94+
}
7395

74-
var rel_date = version_dates[clamped_version] || new Date();
75-
var num_months = monthDiff(rel_date, new Date()) || 12;
96+
// browser.name = 'Thunderbird', browser.version = '60'
97+
var browser = get_browser();
98+
clamped_version = get_version(browser.version);
7699

77-
duration = document.getElementById('duration').innerHTML;
78-
document.getElementById('duration').innerHTML = duration.replace('$mon', num_months).replace('$vers', browser.version);
100+
var rel_date = getVersionDate(clamped_version) || new Date();
101+
var num_months = monthDiff(rel_date, new Date()) || 12;
79102

103+
duration = document.getElementById('duration').innerHTML;
104+
document.getElementById('duration').innerHTML = duration.replace('$mon', num_months).replace('$vers', browser.version);
80105
</script>
81-
</html>
106+
{% endblock %}

0 commit comments

Comments
 (0)