Skip to content

Commit

Permalink
Use server side yandex redirect (fixes mozilla#10607)
Browse files Browse the repository at this point in the history
  • Loading branch information
maureenlholland committed Oct 26, 2021
1 parent 35e60ae commit 7152b89
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 603 deletions.
24 changes: 1 addition & 23 deletions bedrock/firefox/templates/firefox/new/desktop/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,7 @@
{%- endmacro %}

{% block sub_navigation %}
<nav class="c-sub-navigation">
<div class="mzp-l-content">
<div class="c-sub-navigation-content">
<h2 class="c-sub-navigation-title">{{ ftl('sub-navigation-firefox-for-desktop', fallback='navigation-firefox-browser-for-desktop') }}</h2>
<ul class="c-sub-navigation-list">
<li class="c-sub-navigation-item">
<a href="{{ url('firefox.features.index') }}" data-link-type="nav" data-link-position="subnav" data-link-name="Features">{{ ftl('sub-navigation-features', fallback='navigation-features') }}</a>
</li>
<li class="c-sub-navigation-item">
<a href="https://support.mozilla.org/products/firefox/{{ referrals }}" data-link-type="nav" data-link-position="subnav" data-link-name="Support">{{ ftl('sub-navigation-support', fallback='navigation-support') }}</a>
</li>
<li class="c-sub-navigation-item">
<a href="https://addons.mozilla.org/firefox/{{ referrals }}" data-link-type="nav" data-link-position="subnav" data-link-name="Addons">{{ ftl('sub-navigation-add-ons', fallback='sub-navigation-addons') }}</a>
</li>
<li class="c-sub-navigation-item">
<a href="{{ url('firefox.all') }}" data-link-type="nav" data-link-position="subnav" data-link-name="All Languages">{{ ftl('sub-navigation-all-languages', fallback='download-button-systems-languages') }}</a>
</li>
</ul>
</div>
</div>
</nav>
{% include 'firefox/new/desktop/includes/sub_nav.html' %}
{% endblock %}

{% block content %}
Expand All @@ -71,8 +51,6 @@ <h2 class="c-sub-navigation-title">{{ ftl('sub-navigation-firefox-for-desktop',
<div class="mzp-c-notification-bar mzp-t-warning" data-nosnippet="true">{{ ftl('firefox-desktop-download-mozilla-no-longer-provides', fallback='firefox-desktop-download-youre-using-an-insecure-outdated', url='https://support.mozilla.org/kb/end-support-windows-xp-and-vista') }}</div>
<![endif]-->

{% block yandex %}{% endblock%}

<section id="desktop-banner" class="c-block t-intro show-else mzp-has-media-hide-on-sm">
<div class="c-block-container">
<div class="c-block-body">
Expand Down
131 changes: 73 additions & 58 deletions bedrock/firefox/templates/firefox/new/desktop/download_yandex.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,86 @@
file, You can obtain one at https://mozilla.org/MPL/2.0/.
#}

{% from "macros-protocol.html" import call_out_compact with context %}
{% from "macros-protocol.html" import call_out_compact, picto, split with context %}

{% extends "firefox/new/desktop/download.html" %}
{% extends "firefox/new/desktop/base.html" %}

{% block extrahead %}
{{ super() }}
{{ css_bundle('firefox_new_download_yandex') }}
{% endblock %}

{% block string_data %}
{{ super() }}
data-page-title="Firefox с Яндексом"
data-page-desc="Версия браузера Firefox с сервисами Яндекса на русском языке доступна для пользователей в России. Сейчас в браузер встроены Дзен, Советник и Визуальные закладки. Основная версия браузера Firefox на русском языке доступна для пользователей по всему миру."
{% block string_data %}{% endblock %}

{% block page_title_full %}Firefox с Яндексом{% endblock %}
{% block page_desc %}Версия браузера Firefox с сервисами Яндекса на русском языке доступна для пользователей в России. Сейчас в браузер встроены Дзен, Советник и Визуальные закладки. Основная версия браузера Firefox на русском языке доступна для пользователей по всему миру.{% endblock %}

{% block sub_navigation %}
{% include 'firefox/new/desktop/includes/sub_nav.html' %}
{% endblock %}

{% block content %}
<main class="t-yandex" role="main" {% if v %}data-variant="{{ v }}"{% endif %}>
{% call split(
block_id='desktop-banner',
block_class='show-else mzp-l-split-hide-media-on-sm-md',
image_url='img/firefox/new/yandex/yandex.jpg',
include_highres_image=True
)%}
<div class="mzp-c-wordmark mzp-t-wordmark-md mzp-t-product-firefox"><h1>{{ ftl('firefox-desktop-download-firefox') }}</h1></div>
<h2>Firefox с Яндексом</h2>

<p>Скачать версию Firefox с сервисами Яндекса на русском языке</p>

<div>
<p><a class="mzp-c-button mzp-t-product" href="https://yandex.ru/firefox/mozilla/">Скачать Firefox с Яндексом</a></p>
<p><small>Для обеспечения работы этих сервисов Яндекс собирает сведения о действиях при просмотре веб-страниц и некоторые дополнительные данные. Для получения дополнительной информации обратитесь к Политике конфиденциальности Яндекса.</small></p>

{% block yandex %}
<div class="t-yandex">
<section id="desktop-banner" class="c-block t-intro show-else mzp-has-media-hide-on-sm">
<div class="c-block-container">
<div class="c-block-body">
<h1 class="c-logo t-browser-word-hor-xs">{{ ftl('firefox-desktop-download-firefox') }}</h1>
<h2>Firefox с Яндексом</h2>

<p>Скачать версию Firefox с сервисами Яндекса на русском языке</p>

<div class="c-intro-download">
<p><a class="mzp-c-button mzp-t-product" href="https://yandex.ru/firefox/mozilla/">Скачать Firefox с Яндексом</a></p>
<p><small>Для обеспечения работы этих сервисов Яндекс собирает сведения о действиях при просмотре веб-страниц и некоторые дополнительные данные. Для получения дополнительной информации обратитесь к Политике конфиденциальности Яндекса.</small></p>

</div>
</div>
<div class="c-block-media l-v-center">
<div class="c-block-img">
<div class="c-noodles">
<div class="noodle-browser"></div>
</div>
</div>
</div>
</div>
</section>
</div>
{% endcall %}

<section class="mzp-l-content t-releases">
<div class="mzp-c-emphasis-box js-animate">
<ul class="c-trio">
<li>
<img src="{{ static('protocol/img/icons/reader-mode.svg') }}" height="64" width="64">
<h3 class="mzp-u-title-xs">Дзен</h3>
<ul class="mzp-l-columns mzp-t-columns-three">
{#
Zen
Service of personal recommendations based on machine learning technologies. Zen forms a feed of publications, automatically adjusting to the interests of the user.
#}
{% call picto(
title='Дзен',
base_el='li',
image_url='protocol/img/icons/reader-mode.svg',
body=True
) %}
<p>Сервис персональных рекомендаций на основе технологий машинного обучения. Дзен формирует ленту публикаций, автоматически подстраиваясь под интересы пользователя.</p>
</li>
{#
Zen
Service of personal recommendations based on machine learning technologies. Zen forms a feed of publications, automatically adjusting to the interests of the user.
#}
<li>
<img src="{{ static('protocol/img/icons/turbo-mode.svg') }}" height="64" width="64">
<h3 class="mzp-u-title-xs">Советник</h3>
{% endcall %}

{#
Counselor
A service that allows you to compare prices for goods and select the offer with the lowest price.
#}
{% call picto(
title='Советник',
base_el='li',
image_url='protocol/img/icons/turbo-mode.svg',
body=True
) %}
<p>Сервис, позволяющий сравнить цены на товары и выбрать предложение с наименьшей ценой.</p>
{#
Counselor
A service that allows you to compare prices for goods and select the offer with the lowest price.
#}
</li>

<li>
<img src="{{ static('protocol/img/icons/top-sites.svg') }}" height="64" width="64">
<h3 class="mzp-u-title-xs">Визуальные закладки</h3>
{% endcall %}

{#
Visual bookmarks
Browser extension that converts saved bookmarks into a graphical panel on the browser start page.
#}
{% call picto(
title='Визуальные закладки',
base_el='li',
image_url='protocol/img/icons/top-sites.svg',
body=True
) %}
<p>Браузерное расширение, которое преобразует сохраненные закладки в графическое панно на стартовой странице браузера.</p>
{#
Visual bookmarks
Browser extension that converts saved bookmarks into a graphical panel on the browser start page.
#}
</li>
{% endcall %}
</ul>
</div>
</section>
Expand All @@ -88,13 +95,21 @@ <h3 class="mzp-u-title-xs">Визуальные закладки</h3>
{{ download_firefox(alt_copy='Скачать Firefox без Яндекса', dom_id='download-secondary', locale_in_transition=True, download_location='secondary cta') }}
{% endcall %}

</div>
</main>
{% endblock %}


{% block sticky_promo %}{% endblock %}

{% block js %}
{{ super() }}
{{ js_bundle('firefox_new_download_yandex') }}
{% endblock %}

{% block structured_data %}
{
"@context": "https://schema.org/",
"@graph": [
{% include 'includes/structured-data/software/firefox-browser-software.json' %}
]
}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{#
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 https://mozilla.org/MPL/2.0/.
#}

<nav class="c-sub-navigation">
<div class="mzp-l-content">
<div class="c-sub-navigation-content">
<h2 class="c-sub-navigation-title">{{ ftl('sub-navigation-firefox-for-desktop', fallback='navigation-firefox-browser-for-desktop') }}</h2>
<ul class="c-sub-navigation-list">
<li class="c-sub-navigation-item">
<a href="{{ url('firefox.features.index') }}" data-link-type="nav" data-link-position="subnav" data-link-name="Features">{{ ftl('sub-navigation-features', fallback='navigation-features') }}</a>
</li>
<li class="c-sub-navigation-item">
<a href="https://support.mozilla.org/products/firefox/{{ referrals }}" data-link-type="nav" data-link-position="subnav" data-link-name="Support">{{ ftl('sub-navigation-support', fallback='navigation-support') }}</a>
</li>
<li class="c-sub-navigation-item">
<a href="https://addons.mozilla.org/firefox/{{ referrals }}" data-link-type="nav" data-link-position="subnav" data-link-name="Addons">{{ ftl('sub-navigation-add-ons', fallback='sub-navigation-addons') }}</a>
</li>
<li class="c-sub-navigation-item">
<a href="{{ url('firefox.all') }}" data-link-type="nav" data-link-position="subnav" data-link-name="All Languages">{{ ftl('sub-navigation-all-languages', fallback='download-button-systems-languages') }}</a>
</li>
</ul>
</div>
</div>
</nav>
24 changes: 17 additions & 7 deletions bedrock/firefox/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,11 @@ def test_thanks_amo_experiment_locales(self, render_mock):
template = render_mock.call_args[0][1]
assert template == ["firefox/new/desktop/thanks.html"]

# begin yandex - issue 5635
# begin yandex - issue 5635 & 10607

@patch.dict(os.environ, SWITCH_FIREFOX_YANDEX="True")
def test_yandex_download(self, render_mock):
req = RequestFactory().get("/firefox/new/")
req = RequestFactory().get("/firefox/new/", HTTP_CF_IPCOUNTRY="RU")
req.locale = "ru"
view = views.NewView.as_view()
view(req)
Expand All @@ -533,7 +533,7 @@ def test_yandex_download(self, render_mock):
@patch.dict(os.environ, SWITCH_FIREFOX_YANDEX="True")
@patch.object(views, "ftl_file_is_active", lambda *x: True)
def test_yandex_show_to_ru(self, render_mock):
req = RequestFactory().get("/firefox/new/")
req = RequestFactory().get("/firefox/new/", HTTP_CF_IPCOUNTRY="RU")
req.locale = "ru"
view = views.NewView.as_view()
view(req)
Expand All @@ -542,8 +542,18 @@ def test_yandex_show_to_ru(self, render_mock):

@patch.dict(os.environ, SWITCH_FIREFOX_YANDEX="True")
@patch.object(views, "ftl_file_is_active", lambda *x: True)
def test_yandex_hide_not_ru(self, render_mock):
req = RequestFactory().get("/firefox/new/")
def test_yandex_hide_not_ru_country(self, render_mock):
req = RequestFactory().get("/firefox/new/", HTTP_CF_IPCOUNTRY="CA")
req.locale = "ru"
view = views.NewView.as_view()
view(req)
template = render_mock.call_args[0][1]
assert template == ["firefox/new/desktop/download.html"]

@patch.dict(os.environ, SWITCH_FIREFOX_YANDEX="True")
@patch.object(views, "ftl_file_is_active", lambda *x: True)
def test_yandex_hide_not_ru_locale(self, render_mock):
req = RequestFactory().get("/firefox/new/", HTTP_CF_IPCOUNTRY="RU")
req.locale = "de"
view = views.NewView.as_view()
view(req)
Expand All @@ -553,14 +563,14 @@ def test_yandex_hide_not_ru(self, render_mock):
@patch.dict(os.environ, SWITCH_FIREFOX_YANDEX="False")
@patch.object(views, "ftl_file_is_active", lambda *x: True)
def test_yandex_hide_switch_off(self, render_mock):
req = RequestFactory().get("/firefox/new/")
req = RequestFactory().get("/firefox/new/", HTTP_CF_IPCOUNTRY="RU")
req.locale = "ru"
view = views.NewView.as_view()
view(req)
template = render_mock.call_args[0][1]
assert template == ["firefox/new/desktop/download.html"]

# end yandex - issue 5635
# end yandex - issue 5635 & 10607

@patch.dict(os.environ, EXP_CONFIG_FX_NEW="de:100")
def test_experiment_redirect(self, render_mock):
Expand Down
4 changes: 3 additions & 1 deletion bedrock/firefox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import querystringsafe_base64
from product_details.version_compare import Version

from bedrock.base.geo import get_country_from_request
from bedrock.base.urlresolvers import reverse
from bedrock.base.views import GeoRedirectView
from bedrock.base.waffle import switch
Expand Down Expand Up @@ -775,14 +776,15 @@ def get_context_data(self, **kwargs):

def get_template_names(self):
locale = l10n_utils.get_locale(self.request)
country = get_country_from_request(self.request)
variant = self.request.GET.get("v", None)
experience = self.request.GET.get("xv", None)

# ensure variant matches pre-defined value
if variant not in self.variations:
variant = None

if locale == "ru" and switch("firefox-yandex"):
if country == "RU" and locale == "ru" and switch("firefox-yandex"):
template = "firefox/new/desktop/download_yandex.html"
elif ftl_file_is_active("firefox/new/desktop") and experience != "basic":
template = "firefox/new/desktop/download.html"
Expand Down
Loading

0 comments on commit 7152b89

Please sign in to comment.