Skip to content

Commit

Permalink
Update outdated-page's style and warning with a link to a support art…
Browse files Browse the repository at this point in the history
…icle.
  • Loading branch information
MelissaAutumn committed Nov 24, 2023
1 parent 2109e89 commit c5f889c
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 66 deletions.
29 changes: 29 additions & 0 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import json
import markdown
import re

import product_details
import settings
import sys
import translate
Expand Down Expand Up @@ -470,6 +472,33 @@ def get_form_assembly_localization_url(ctx):
return "https://mozillafoundation.tfaforms.net/wForms/3.11/js/localization-{locale}.js?v=75513df1680ccc55e2c889a1b1dff356256982a6".format(locale=fa_locale)


@jinja2.pass_context
def get_outdated_versions(ctx):
""" Get a JSON str of versions and dates of the last released minor version for outdated versions. """
versions = product_details.thunderbird_desktop.list_releases()
last_stable_release = {}
last_safe_release = float(settings.LAST_SAFE_VERSION)

for version in versions:
# major is a float, minor is a string
major_version = version[0]
minor_versions = version[1]['minor']

if len(minor_versions) > 0:
last_version = minor_versions[-1]
else:
last_version = str(major_version)

# Don't include safe versions
if major_version >= last_safe_release:
continue

release_date = product_details.thunderbird_desktop.get_release_date(last_version)
last_stable_release[major_version] = release_date

return json.dumps(last_stable_release)


def is_calendarific_free_tier():
"""Returns if we're expecting to use the Calendarific free tier"""
try:
Expand Down
2 changes: 2 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,5 @@
'US': ('United States', 'en'),
'VN': ('Vietnam', 'vi'),
}

LAST_SAFE_VERSION = 102
1 change: 1 addition & 0 deletions start-page/_base-resp.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<title>{% filter striptags|e %}{% block title %}{% endblock %}{% endfilter %}</title>
{{ l10n_css() }}
<link href="/media/css/start-style.css" rel="stylesheet" type="text/css" />
{% block additional_head %}{% endblock %}
</head>
<body class="start-bg">
<main>
Expand Down
157 changes: 91 additions & 66 deletions start-page/outdated/index.html
Original file line number Diff line number Diff line change
@@ -1,81 +1,106 @@
{# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}

<!DOCTYPE html>
<html lang="{{ LANG|replace('en-US', 'en') }}" dir="{{ DIR }}">
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<title>{% block title %}{{ _('Your Thunderbird is Not Up-to-Date!') }}{% endblock %}</title>
{{ l10n_css() }}
<!-- Fontawesome added below -->
<link href="/media/css/fontawesome-all.css" rel="stylesheet">
<!--<script defer src="/media/js/fontawesome-all.js"></script>-->
<style>
body {
background-color: #D46A6A;
text-align: center;
}
</style>
</head>
<body>
<main>
<h1><b><i class="fas fa-exclamation-triangle fa-3x" style="color:#0060df"></i> {{ self.title() }}</b></h1>
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}

{% extends "_base-resp.html" %}

{% block channel %}release{% endblock %}
{% block title %}{{ _('Your Thunderbird is Not Up-to-Date!') }}{% endblock %}

{% block additional_head %}
<style>
body {
background-image: none;
background-color: #991b1b;
color: #f1f3fa;
text-shadow: 1px 1px 0 black;;
text-align: center;
}

.main-content {
display: block;
}

.outdated-warning-icon {
display: inline-block;
position: relative;
top: 8px;
width: 32px;
height: 32px;
color: #88ccfc;
}
a {
text-decoration: underline !important;
color: #88ccfc;
}
a:visited {
color: #88ccfc;
text-decoration: underline !important;

}
</style>
{% endblock %}

{% block main %}
<div class="main-content">
<section id="outdated-message">
<h1><b><span class="outdated-warning-icon">{{ svg('warning') }}</span> {{ self.title() }}</b></h1>
<h2 id="duration">{{ _('Your version, $vers, is no longer a supported Thunderbird release and hasn’t received updates in at least $mon months.') }}</h2>
<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>
<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>
</main>
</body>
<p>{{ _('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>
<p>{{ _('For more information, please check this
<a href="%(support_url)s">support article</a> on upgrading old versions.')|format(support_url=url('support.old-version-upgrade')) }}
</p>
</section>
</div>
<script>
// Date of last security release for each major version.
version_dates = {{ get_outdated_versions() }}

function getVersionDate(version) {
return new Date(version_dates[version]);
}

// Date of last security release for each major version.
version_dates = {
24: new Date(2014, 8, 2),
31: new Date(2015, 6, 17),
38: new Date(2016, 4, 4),
45: new Date(2017, 2, 7),
52: new Date(2018, 6, 10),
60: new Date(2019, 10, 5)
}

function monthDiff(dateFrom, dateTo) {
return dateTo.getMonth() - dateFrom.getMonth() +
(12 * (dateTo.getFullYear() - dateFrom.getFullYear()))
}

function get_browser() {
var ua=navigator.userAgent,tem,M=ua.match(/(firefox|thunderbird(?=\/))\/?\s*(\d+)/i) || [];
M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);}
function monthDiff(dateFrom, dateTo) {
return dateTo.getMonth() - dateFrom.getMonth() +
(12 * (dateTo.getFullYear() - dateFrom.getFullYear()))
}

function get_browser() {
var ua = navigator.userAgent, tem, M = ua.match(/(firefox|thunderbird(?=\/))\/?\s*(\d+)/i) || [];
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != null) {
M.splice(1, 1, tem[1]);
}
return {
name: M[0],
version: M[1]
};
}

// Clamp the version number to the closest among version_dates.
function get_version(vers) {
// This instead of Object.keys() for compatibility with old versions.
var versions = [], i = 0;
for (versions[i++] in version_dates) {}
}

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

return closest;
}
var closest = versions.reduce(function (prev, curr) {
return (Math.abs(curr - vers) < Math.abs(prev - vers) ? curr : prev);
});

// browser.name = 'Thunderbird', browser.version = '60'
var browser=get_browser();
clamped_version = get_version(browser.version);
return closest;
}

var rel_date = version_dates[clamped_version] || new Date();
var num_months = monthDiff(rel_date, new Date()) || 12;
// browser.name = 'Thunderbird', browser.version = '60'
var browser = get_browser();
clamped_version = get_version(browser.version);

duration = document.getElementById('duration').innerHTML;
document.getElementById('duration').innerHTML = duration.replace('$mon', num_months).replace('$vers', browser.version);
var rel_date = getVersionDate(clamped_version) || new Date();
var num_months = monthDiff(rel_date, new Date()) || 12;

duration = document.getElementById('duration').innerHTML;
document.getElementById('duration').innerHTML = duration.replace('$mon', num_months).replace('$vers', browser.version);
</script>
</html>
{% endblock %}

0 comments on commit c5f889c

Please sign in to comment.