favicon now changing based on review app or staging (#8156)

* favicon now changing based on review app or staging

* passing tests

* Removing blank lines

* updated to use template for prefix

* Update network-api/networkapi/settings.py

Co-authored-by: Pomax <pomax@nihongoresources.com>

* Updated to use tag

* updated environment_prefix to now be mofo_common

* updated environment_prefix to now be mofo_common

Co-authored-by: Daniel Miranda <daniel@mozillafoundation.org>
Co-authored-by: Pomax <pomax@nihongoresources.com>
This commit is contained in:
Daniel Miranda 2022-02-01 14:32:45 -08:00 коммит произвёл GitHub
Родитель 229a5e2529
Коммит 00db875ef6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 66 добавлений и 17 удалений

Просмотреть файл

@ -8,6 +8,9 @@ TARGET_DOMAINS=foundation.mozilla.org
# network-api environment:
ALLOWED_HOSTS=*
# APP_ENVIRONMENT is used to prepend [S] or [RA] to page tab title & change favicon color,
# choices are "Review" and "Staging" and are set in Heroku.
APP_ENVIRONMENT=
ASSET_DOMAIN=network.mofoprod.net
CONTENT_TYPE_NO_SNIFF=True
CORS_ALLOWED_ORIGINS=*

Просмотреть файл

@ -1,9 +1,10 @@
{% extends "mozfest/mozfest-base.html" %}
{% load i18n %}
{% load i18n mofo_common %}
{% block page_title %}
{% blocktrans %}Mozilla Festival - Page Not Found{% endblocktrans %}
{% environment_prefix %}
{% blocktrans %}Mozilla Festival - Page Not Found{% endblocktrans %}
{% endblock %}
{% block body_id %}{% endblock %}

Просмотреть файл

@ -1,5 +1,5 @@
{% extends "pages/base.html" %}
{% load wagtailcore_tags wagtailimages_tags homepage_tags card_tags wagtailmetadata_tags custom_image_tags i18n static %}
{% load wagtailcore_tags wagtailimages_tags homepage_tags card_tags wagtailmetadata_tags custom_image_tags i18n static mofo_common %}
{% block web_monetization %}
@ -18,7 +18,8 @@
{% block page_title %}
{% blocktrans %}Mozilla Festival{% endblocktrans %}{% if page.specifics.seo_title %} - {{ page.specifics.seo_title }}{% else %} - {{ page.title }}{% endif %}
{% environment_prefix %}
{% blocktrans %}Mozilla Festival{% endblocktrans %}{% if page.specifics.seo_title %} - {{ page.specifics.seo_title }}{% else %} - {{ page.title }}{% endif %}
{% endblock %}
{% block org_schema %}

Просмотреть файл

@ -1,7 +1,10 @@
{% extends "./mozfest-base.html" %}
{% load wagtailcore_tags %}
{% load wagtailcore_tags mofo_common %}
{% block page_title %}{{page.title}}{% endblock%}
{% block page_title %}
{% environment_prefix %}
{{page.title}}
{% endblock%}
{% block mozfest_body_id %}home{% endblock %}
{% block bodyclass %}mozfest {% if banner_video_type %}banner-type-{{banner_video_type}}{% endif %}{% endblock %}

Просмотреть файл

@ -30,6 +30,7 @@ env = environ.Env(
AIRTABLE_BASE_URL=(str, ''),
AIRTABLE_ENABLED=(bool, False),
ALLOWED_HOSTS=(list, []),
APP_ENVIRONMENT=(str, ''),
ASSET_DOMAIN=(str, ''),
AWS_LOCATION=(str, ''),
BASKET_URL=(str, ''),
@ -120,6 +121,7 @@ if SENTRY_DSN:
# At True when running on a review app
REVIEW_APP = env('REVIEW_APP', default=False)
APP_ENVIRONMENT = env('APP_ENVIRONMENT')
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = root()
@ -337,6 +339,7 @@ TEMPLATES = [
'card_tags': 'networkapi.wagtailpages.templatetags.card_tags',
'class_tags': 'networkapi.wagtailpages.templatetags.class_tags',
'debug_tags': 'networkapi.wagtailpages.templatetags.debug_tags',
'mofo_common': 'networkapi.utility.templatetags.mofo_common',
'homepage_tags': 'networkapi.wagtailpages.templatetags.homepage_tags',
'localization': 'networkapi.wagtailpages.templatetags.localization',
'mini_site_tags': 'networkapi.wagtailpages.templatetags.mini_site_tags',

Просмотреть файл

@ -1,7 +1,10 @@
{% extends "pages/base.html" %}
{% load i18n %}
{% load i18n mofo_common %}
{% block page_title %}{% trans "Page Not Found" %}{% endblock %}
{% block page_title %}
{% environment_prefix %}
{% trans "Page Not Found" %}
{% endblock %}
{% block web_monetization %}{% endblock %}

Просмотреть файл

@ -0,0 +1,16 @@
{% load static mofo_common %}
{% environment_prefix as env_prefix %}
{% if env_prefix == '[S]' %}
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="{% static "_images/favicons/favicon-staging.svg" %}">
<link rel="icon" type="image/png" sizes="196x196" href="{% static "_images/favicons/favicon-staging.svg" %}">
<link rel="shortcut icon" href="{% static "_images/favicons/favicon-staging.svg" %}">
{% elif env_prefix == '[RA]' %}
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="{% static "_images/favicons/favicon-reviewapp.svg" %}">
<link rel="icon" type="image/png" sizes="196x196" href="{% static "_images/favicons/favicon-reviewapp.svg" %}">
<link rel="shortcut icon" href="{% static "_images/favicons/favicon-reviewapp.svg" %}">
{% else %}
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="{% static "_images/favicons/apple-touch-icon-180x180@2x.png" %}">
<link rel="icon" type="image/png" sizes="196x196" href="{% static "_images/favicons/favicon-196x196@2x.png" %}">
<link rel="shortcut icon" href="{% static "_images/favicons/favicon.ico" %}">
{% endif %}

Просмотреть файл

@ -1,4 +1,4 @@
{% load wagtailmetadata_tags i18n localization settings_value wagtailuserbar static %}
{% load wagtailmetadata_tags i18n localization settings_value wagtailuserbar static mofo_common %}
{% get_current_language as lang_code %}
@ -6,7 +6,12 @@
<html lang="{{ lang_code }}">
<head>
<meta charset="utf-8">
<title>{% block page_title %}{% trans "Mozilla Foundation" %} - {% if page.specifics.seo_title %}{{ page.specifics.seo_title }}{% else %}{{ page.title }}{% endif %}{% endblock %}</title>
<title>
{% block page_title %}
{% environment_prefix %}
{% trans "Mozilla Foundation" %} - {% if page.specifics.seo_title %}{{ page.specifics.seo_title }}{% else %}{{ page.title }}{% endif %}
{% endblock %}
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
@ -45,9 +50,7 @@
{% block extended_head %}{% endblock %}
{% block icons %}
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="{% static "_images/favicons/apple-touch-icon-180x180@2x.png" %}">
<link rel="icon" type="image/png" sizes="196x196" href="{% static "_images/favicons/favicon-196x196@2x.png" %}">
<link rel="shortcut icon" href="{% static "_images/favicons/favicon.ico" %}">
{% include "fragments/favicons.html" %}
{% endblock %}
{% block hreflang %}

Просмотреть файл

@ -0,0 +1,15 @@
from django import template
from django.conf import settings
register = template.Library()
@register.simple_tag(takes_context=True)
def environment_prefix(context):
env_prefix = ''
app_env = settings.APP_ENVIRONMENT
if app_env == 'Staging':
env_prefix = '[S]'
elif app_env == 'Review':
env_prefix = '[RA]'
return env_prefix

Просмотреть файл

@ -1,10 +1,11 @@
{% extends "pages/base.html" %}
{% load bg_nav_tags localization i18n static wagtailroutablepage_tags wagtailmetadata_tags debug_tags %}
{% load bg_nav_tags localization i18n static wagtailroutablepage_tags wagtailmetadata_tags debug_tags mofo_common %}
{% get_current_language as lang_code %}
{% block page_title %}
{% environment_prefix %}
{% if pageTitle %}{{ pageTitle }}
{% else %}{% blocktrans context "“*privacy not included” can be localized. This is a reference to the “*batteries not included” mention on toys." %}*privacy not included | Shop smart and safe{% endblocktrans %} | Mozilla Foundation{% endif %}
{% endblock %}
@ -36,9 +37,7 @@
{% block icons %}
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="{% static "_images/favicons/apple-touch-icon-180x180@2x.png" %}">
<link rel="icon" type="image/png" sizes="196x196" href="{% static "_images/favicons/favicon-196x196@2x.png" %}">
<link rel="shortcut icon" href="{% static "_images/favicons/favicon.ico" %}">
{% include "fragments/favicons.html" %}
{% endblock %}

Просмотреть файл

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 68 68"><defs><style>.cls-1{fill:#ff4f5e;}.cls-2{fill:#fff;}</style></defs><rect class="cls-1" width="68" height="68"/><path class="cls-2" d="M57.9,42.6h3.9V49H49.5V32.4c0-5.1-1.7-7-5-7-4,0-5.6,2.9-5.6,6.9V42.5h3.9v6.4H30.5V32.4c0-5.1-1.7-7-5-7-4,0-5.6,2.9-5.6,6.9V42.5h5.6v6.4H7.5V42.5h3.9V26H7.5V19.6H19.8V24a9.78,9.78,0,0,1,8.9-5c4.2,0,8.1,2,9.5,6.3A9.74,9.74,0,0,1,47.7,19c5.3,0,10.1,3.2,10.1,10.1V42.6Z"/></svg>

После

Ширина:  |  Высота:  |  Размер: 501 B

Просмотреть файл

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 68 68"><defs><style>.cls-1{fill:#595cf3;}.cls-2{fill:#fff;}</style></defs><rect class="cls-1" width="68" height="68"/><path class="cls-2" d="M57.9,42.6h3.9V49H49.5V32.4c0-5.1-1.7-7-5-7-4,0-5.6,2.9-5.6,6.9V42.5h3.9v6.4H30.5V32.4c0-5.1-1.7-7-5-7-4,0-5.6,2.9-5.6,6.9V42.5h5.6v6.4H7.5V42.5h3.9V26H7.5V19.6H19.8V24a9.78,9.78,0,0,1,8.9-5c4.2,0,8.1,2,9.5,6.3A9.74,9.74,0,0,1,47.7,19c5.3,0,10.1,3.2,10.1,10.1V42.6Z"/></svg>

После

Ширина:  |  Высота:  |  Размер: 501 B